Create a method that will create a pyramid shaped sound wave.

What will be an ideal response?

```
/¤¤
¤ Method to c r e a t e a one second pyramid
¤ ( cut o f f t r i a n g l e ) wave sound
¤ wi th the g i v en f r e quenc y and maximum ampl i tude
¤ @param f r e q the d e s i r e d f r e quenc y
¤ @param maxAmplitude the maximum ampl i tude
¤ @return the new sound
¤/
public s tat ic Sound createPyramidWave ( int f r eq ,
int maxAmplitude )
f
Sound s =
new Sound ( Fi l eChoos e r . getMediaPath ( " s e c 1 s i l e n c e .wav" ) ) ;
double sampl ingRate = s . getSampl ingRate ( ) ;
int value = 0 ;
double i n t e r v a l = 1 . 0 / f r e q ; // l e n g t h o f c y c l e in seconds
double samplesPerCycle = i n t e r v a l * sampl ingRate ;
int numSamplesInSixth = ( int ) ( samplesPerCycle / 6 ) ;
int increment =
( int ) (maxAmplitude / numSamplesInSixth ) ;
int s i gn = 1 ;
// loop through the sound
for ( int soundIndex = 0 ;
soundIndex < s . getLength ( ) ;
soundIndex++, value = value + increment )
{
// check i f the v a lue i s e qua l to the d e s i r e d max
i f ( value >= maxAmplitude j j
value <= maxAmplitude *-1)
{
value = maxAmplitude * s i gn ;
// loop f o r a s i x t h of the samples in a c y c l e
for ( int i = 0 ; i < numSamplesInSixth ; i++, soundIndex++)
{
s . setSampleValueAt ( soundIndex , value ) ;
}
// f l i p the s i gn and increment
s i gn = s i gn * -1;
increment = increment * -1;
soundIndex--;
}
else
{
s . setSampleValueAt ( soundIndex , value ) ;
}
}
return s ;
}
```

Computer Science & Information Technology

You might also like to view...

________ management focuses on the best way to not only identify and fulfill a customer's need, but also how to provide the best customer experience possible

A) Intranet B) Value chain C) Enterprise system D) Supply chain

Computer Science & Information Technology

The ________ function adds the cells in a range that meet a specified condition

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology