Write a method that will blend 3 sounds. Start with one sound for 20,000 samples then blend the first and second sound for 20,000 samples, then the second and third sound for 20,000 samples and then the third sound for 20,000 samples.

What will be an ideal response?

```
/**
* Method to o v e r l a p or b l end 3 sounds . S t a r t
* by copying the f i r s t 20 ,000 samples from sound1 into
* the end sound then copy the sum of half
* of the sound1 v a lue and h a l f o f the sound2 value for
* 20 ,000 samples . Then copy the sum of h a l f o f
* the sound2 v a lue and h a l f o f the sound3 v a lue
* f o r the ne x t 20 ,000 samples end wi th the
* ne x t 20 ,000 samples from sound3 .
*/
public static Sound blend3Sounds ( ) {
Sound endSound = new Sound ( 8 0 0 0 0 ) ;
Sound sound1 =
new Sound ( Fi l eChoos e r . getMediaPath ( "aah .wav" ) ) ;
Sound sound2 =
new Sound ( Fi l eChoos e r . getMediaPath ( " bassoon¡c4 .wav" ) ) ;
Sound sound3 =
new Sound ( Fi l eChoos e r . getMediaPath ( "g4 .wav" ) ) ;
int value = 0 ;
// copy the f i r s t 20 ,000 samples from sound1 int o t a r g e t
for ( int index=0; index < 20000; index++)
endSound . setSampleValueAt ( index ,
sound1 . getSampleValueAt ( index ) ) ;
// copy the ne x t 20 ,000 samples from sound1 and b l end t h a t
// wi th the f i r s t 20 ,000 samples from sound2
for ( int index = 0 ; index < 20000; index++) f
value = ( int ) ( ( sound1 . getSampleValueAt ( index + 20000) ¤
0 . 5 ) +
( sound2 . getSampleValueAt ( index ) * 0 . 5 ) ) ;
endSound . setSampleValueAt ( index + 20000 , value ) ;
}
// copy the ne x t 20 ,000 samples from sound2 and b l end t h a t
// wi th the f i r s t 20 ,000 samples from sound3
for ( int index = 0 ; index < 20000; index++) f
value = ( int ) ( ( sound2 . getSampleValueAt ( index + 20000) ¤
0 . 5 ) +
( sound3 . getSampleValueAt ( index ) ¤ 0 . 5 ) ) ;
endSound . setSampleValueAt ( index + 40000 , value ) ;
}
// copy the ne x t 20 ,000 samples from sound3 int o the t a r g e t
for ( int index=20000; index < 40000; index++)
endSound . setSampleValueAt ( index + 40000 ,
sound3 . getSampleValueAt ( index ) ) ;
return endSound ;
}
```

Computer Science & Information Technology

You might also like to view...

A section ________ marks where one section ends and the next begins

A) break B) close C) stop D) separator

Computer Science & Information Technology

Which of the following is the broadcast address for subnet 192.168.10.32 with subnet mask 255.255.255.240

A. 192.168.10.63 B. 192.168.10.47 C. 192.168.10.23 D. 192.168.10.95

Computer Science & Information Technology