// Analize and display the FFT Frequency Spectrum values for the microphone input.
void setup(){
size(512,200);
Sonia.start(this);
LiveInput.start(256); // start the LiveInput engine, and return 256 FFT bins (frequencies)
}
void loop(){
background(0,20,0);
strokeWeight(0);
stroke(0,230,0);
LiveInput.getSpectrum(); // Populates the LiveInput.spectrum[] array with latest FFT data.
// Use the LiveInput.spectrum[] to display the FFT data
for ( int i = 0; i < LiveInput.spectrum.length; i++){
line(i*2, height, i*2, height - LiveInput.spectrum[i]/10);
}
}
public void stop(){
Sonia.stop();
super.stop();
}
|