I'm trying to run an spectrum analysis on a file. Since the file that I'd like to analyse can be quite long (40 min or so), analysing this in real time is not really an option for me.
I'm currently using Minin's FFT class, but it looks like I can only run a song that's already playing. I've also looked at the ess library, but I understood that also is limited to having a realtime stream.
Is there a way to just iterate through an audio file in small chunks and then run the fft on that data?
Here's a simplified version of what I have now:
void setup()
{
minim = new Minim(this);
frameRate(30);
song = minim.loadFile("../shortfile.mp3", 1024);
song.loop();
fft = new FFT(song.bufferSize(), song.sampleRate());
background(#ffffff);
}
void draw()
{
fft.forward(song.mix);
for(int i = 0; i < height/2; i++)
{
intensity = constrain((log(fft.getBand(i)*1.4) / log(1.15)), 0, 40);
intensity = int(map(intensity, 0 , 40, 0, 255));
stroke(strokeColour(int(intensity)));
point(framecount, i);
}
}