I want to do a fast fourier transform (fft) with 2^15 = 32768 bands. Even if it basically works I get often crashes while starting the sektch : Java(TM) Platform SE binary does not function So I need to start the same sketch 2 - 3 times before it runs. I am worrying because of stability issues?
A further question is: how can I determine when a new value for a frequency (fft - bin) is computed and available? this sketch gives every 1500 ms a new value because with 2^15 bands one fft frame computation needs 2*bands/sampleRate = 2 * 2^15 /44100 = 1.486 sec = 1486 ms. with frameRate 30 this is achieved within 45 frames so 1500 ms. Is there any event Detection for a new FFT frame or need I to count frames?
import processing.sound.*;
FFT fft;
AudioIn in;
int bands = 32768;
float[] spectrum = new float[bands];
void setup()
{
size(500, 300);
// Create an Input stream which is routed into the Amplitude analyzer
fft = new FFT(this, bands);
in = new AudioIn(this, 0);
// start the Audio Input
in.start();
// patch the AudioIn
fft.input(in);
}
void draw() {
fft.analyze(spectrum);
println("spectrum["+149+"]: "+spectrum[149]+" time: "+millis());
}