This a method for create the tone.
private double[] tone(double hz, double duration) {
int N = (int) (StdAudio.SAMPLE_RATE * duration);
double[] a = new double[N+1];
for (int i = 0; i <= N; i++) { a[i] = Math.sin(2 * Math.PI * i * hz / StdAudio.SAMPLE_RATE); } return a; }
After make that method, we just call the variable that using the tone method, and play it with play method in StdAudio class. The example for implementation is below:
double[] a = tone(frek, dur);
StdAudio.play(a);
The capture of application
For more source you can download here ( Sorry for using this link, because there is no tools for uploading a file in my blog ). I use netbeans for develop it.
Tidak ada komentar:
Posting Komentar