We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am trying to create a music visualizer using the FFT in Minim. For my calculations, I need getAvg() to return a number between 0 and 1, which I can then convert to dBA. However, it seems to give me numbers between 0 and some other number like 27 when I play a file with full amplitude noise created in Audacity. So what is getAvg() actually returning and how can I get it to be between 0 and 1?
I have this in my setup function:
fft = new FFT(song.bufferSize(), song.sampleRate());
fft.logAverages(22, bandsPerOctave);
and this in my draw function:
fft.forward(song.mix);
for(int i = 0; i < fft.avgSize(); i++)
{
float amplitude = fft.getAvg(i);
println(amplitude);
}
Answers
https://Processing.org/reference/norm_.html
Okay, I found an article on StackOverflow that answers my question: https://stackoverflow.com/questions/20408388/how-to-filter-fft-data-for-audio-visualisation
To break down the bits of answers above as an aid to future forum-goers with similar questions:
log10()
, which is described on thelog()
reference page:norm()
-- for non-normal range mapping (such as to a particular range of y pixel height on the screen) usemap()
:getAvg() doesn't seem to be directly described in Minim's documentation. The describe the concept. There is more information looking at getAverageBandwidth() and associated functions that are shown in the example next:
http://code.compartmental.net/minim/fft_method_getaveragebandwidth.html
http://code.compartmental.net/minim/fft_method_linaverages.html
Kf