import processing.sound.*;
FFT fft;
AudioIn in;
int bands = 512;
float[] spectrum = new float[bands];
void setup() {
size(512, 360);
background(255);
// 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() {
background(255);
fft.analyze(spectrum);
for(int i = 0; i < bands; i++){
// The result of the FFT is normalized
// draw the line for frequency band i scaling it up by 5 to get more amplitude.
line( i, height, i, height - spectrum[i]*height*5 );
}
}
You should be able to generate some kind of similarity score by comparing the 2 spectra. I don't think that it is time sensitive... i.e. the same sound forwards and backwards will have the same fft (I'm just guessing on that though. my math is a little rusty. could someone confirm or falsify?)
Answers
I think it would be easier to compare frequencies using the audio file instead. Do you have access to that?
Yes
Ok then you should check out this fft example:
https://www.processing.org/reference/libraries/sound/FFT.html
You should be able to generate some kind of similarity score by comparing the 2 spectra. I don't think that it is time sensitive... i.e. the same sound forwards and backwards will have the same fft (I'm just guessing on that though. my math is a little rusty. could someone confirm or falsify?)
for a more complicated but more complete discussion of similarity check out this thread: http://www.dsprelated.com/showthread/comp.dsp/103820-1.php