I am trying to create a void play(double duration) reference class. This plays t
ID: 3551043 • Letter: I
Question
I am trying to create a void play(double duration) reference class. This plays the frequency for the number of seconds specified by the duration parameter. Here is what I have put together so far but I have error markings on my code:
public void play(double duration){
final int sliceCount(int)(stdAudio.SAMPLE_RATE * duration);
final double[] slices = new double[sliceCount + 1];
for(int i = 0; i < sliceCount; i++){
slices[i] = Math.sin(2 * Math.PI * i * this.frequency / StdAudio.SAMPLE_RATE);
}
It gives me an error markings on all the lines exept the last one. Could you give me a hint as to what I could be missing?
Thank you
Explanation / Answer
You need to post the main code, but from what you posted, you forgot the = sign in line two.
final int sliceCount=(int)(stdAudio.SAMPLE_RATE * duration);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.