Hi all, I’m trying to get the frequency from each band using ofSoundGetSpectrum
.
Looking at the SoundPlayerFFTExample I’ve copied this
void ofApp::setup(){
soundPlayer.load("dig.mp3");
nBandsToGet = 128;
fftSmoothed = new float[8192];
for (int i = 0; i < 8192; i++){
fftSmoothed[i] = 0;
}
soundPlayer.play();
}
void ofApp::update(){
ofSoundUpdate();
float * val = ofSoundGetSpectrum(nBandsToGet);
for (int i = 0;i < nBandsToGet; i++){
// let the smoothed value sink to zero:
fftSmoothed[i] *= 0.96f;
// take the max, either the smoothed or the incoming:
if (fftSmoothed[i] < val[i]) fftSmoothed[i] = val[i];
}
}
In the tutorial written by @admsyn it is written that to obtain the frequency of a band i should use this formula
frequency = (binIndex * sampleRate) / totalSampleCount
My question are:
- which is the sampleRate? can I assume that it is 44100?
- How should i calculate the totalSampleCount value?
I do not want to use, for now, ofMaxim, ofxFFT or ofxFft (at the moment), any suggestion is welcome.