0
$\begingroup$

I am coding a program which uses a FFT to process audio data. I need to aggregate the FFT output into three bins ("bass", "mid", and "treb") determined by two arbitrary frequency values. The end-goal is, more or less, a spectrum analyzer with 3 variable-size frequency bands.

As the magnitude of the complex numbers obtained from the FFT is bounded above by a known number B, it seems to me that the most intuitive method to aggregate the data would be to calculate average magnitude within a band and then convert the average to decibels referencing B.

This method leaves me with a serious concern, however... Since there are fewer measurements at lower frequencies, it serves to reason that there will exist a higher degree of spectral leakage in a low-frequency octaves than in high-frequency octaves. I fear that this will cause the average for the "bass" bin to trend higher than that of the "mid" and "treb" bins, thus causing a disconnect between the presented data and what is actually perceived. I am already applying a window function to incoming audio samples, but tests of my program suggest that this might still be an issue. As illustration (graph of several window functions, vertical gridlines at each octave, input is simple sinusoid):

Low freq spectral leakage

Low freq spectral leakage

High freq spectral leakage

High freq spectral leakage

Is averaging as stated above the de facto standard for aggregating audio data in an application like the one I've described? Are there alternatives that may be better suited to my use-case?

Is the concern I mentioned well-founded? If so, are there any standard tactics to mitigate the problem?

$\endgroup$
  • $\begingroup$ Regardless of spectral leakage, what inputs do you expect? In normal audio, bass already is more powerful (in W/Hz). $\endgroup$ – MSalters Apr 16 '15 at 8:02
  • $\begingroup$ @MSalters I'm by no means knowledgeable with regard to audio processing/DSP - I just happen to need this for a pet project I'm working on. Anything I've thrown together has been learned within the past week, so it's quite likely that if you folks don't see this as abnormal there is actually no problem. $\endgroup$ – user15465 Apr 17 '15 at 4:41
  • $\begingroup$ It's more about expected output than input... The output data will be fed into another portion of the program where it will be used to manipulate a visualizer. Given that this doesn't require precise, accurate measurement I'm thinking I might just add a user-controlled compressor to the data after the fft frames are averaged. Can I assume from your lack of "wth are you doing?!" that I am aggregating my magnitude values appropriately? $\endgroup$ – user15465 Apr 17 '15 at 4:44
  • $\begingroup$ It helps to realize that these numbers have physical meaning. The magnitude of your FFT bins represents energy at that frequency. Aggregating energy is a perfectly valid operation. $\endgroup$ – MSalters Apr 17 '15 at 7:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy