#### Howdy, Stranger!

We are about to switch to a new forum software. Until then we have removed the registration on this forum.

# What range does getAvg() return in Minim?

edited January 2017

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);
}
``````
Tagged:

• edited January 2017 Answer ✓

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:

1. What range does minim's FFT.getAvg() return? It is broad, and it depends -- on your input data / FFT bands. This is documented on minim's FFT class reference page:
2. How do you graph FFT data? Fourier Transforms / FFTs are generally visually graphed on a log scale, and in this case we can use the formula for decibels -- see the StackOverflow answer:
3. Implement the decibel scale formula in processing using `log10()`, which is described on the `log()` reference page:
4. How would you adjust any range (such as as you decibels log scale, once it has been adjusted, or anything else) to normalize it to the 0-1 range? As @GoToLoop linked, use `norm()` -- for non-normal range mapping (such as to a particular range of y pixel height on the screen) use `map()`:
• 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