Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review-Fall 2007: Manipulating Sounds

Back to Midterm Exam 1 Review-Fall 2007
Ask your questions here...


How does this look? I'm not even sure what the question is asking... Someone help!
public void putInZeros(int start, int skip, int value){
    
    int v = 0;

    for (int source=skip, target=start;
         source < this.getLength();
         source++, target++){
      v = this.getSampleValueAt(source);
      this.setSampleValueAt(target,v);
     }
    
 
    int gap = skip-start;
    for (int i=1; i <= gap ; i++){
      this.setSampleValueAt(this.getLength()-i,value);
    }
  }

Instead of writing / posting code first take time to understand the question. What do you think the problem is asking? If you have a sound (mySound) with an underlying array of
0123456789
and you call mySound.putInZeros(2, 2, 20)...what do you think the resulting array will be? -Joel Uthe


I think this is the answer but it seems really simple so I'm not sure...
public void putInZeros(int start, int skip, int value)
{
  for(int i = start; i < this.getLength()-1; i = i +skip)
  {
    this.setSampleValueAt(i, value)
  }
}


Since it's kind of late I'm not sure if any of the TAs will even see that code, so if they do can they just say something...even if it's right you don't have to say that, just let me know you saw it. Thanks!

I thought that if an array had say 10 elements then the length would be 10, but the last index would be 9. Thus, I thought you would only want to go to the last index in the array. So if what I have is not correct, I would guess it would be either "this.getLength() - skip" or "this.getLength()". Thanks.




Link to this Page