Rewrite the echo method to generate two echoes back, each delay samples previous. Hint: Start your index loop at 2*delay, then access one echo sample at index-delay and another at index - 2*delay.
What will be an ideal response?
```
/**
* Method to add two echoes to a sound
* @param d e l a y the number of samples b e f o r e
* the echo s t a r t s
*/
public void echo2 ( int de lay )
f
// make a copy of the o r i g i n a l sound
Sound s = new Sound ( this . getFi leName ( ) ) ;
int value = 0 ;
// loop from d e l a y to end of sound
for ( int i = 2¤ de lay ; i < this . getLength ( ) ; i++) {
/* g e t the v a lue back by d e l a y samples from the
* copy of the sound and make i t f a i n t e r
*/
value = ( int ) ( s . getSampleValueAt ( --de lay ) *
0 . 4 ) +
( int ) ( s . getSampleValueAt ( i ¡ (2 * de lay ) ) * 0 . 2 ) ;
/* s e t the v a lue at the cur r ent inde x to the sum
* of the cur r ent v a lue and the echo
*/
this . setSampleValueAt ( i ,
s . getSampleValueAt ( i ) +
value ) ;
}
}
```
You might also like to view...
Footnotes are single-spaced by default, regardless of the line spacing of the document text
Indicate whether the statement is true or false
Which of the following statements initializes the unsigned int variable counter to 10?
a. unsigned int counter = 10; b. unsigned int counter = {10}; c. unsigned int counter{10}; d. All of the above.