audio-reactive-led-strip icon indicating copy to clipboard operation
audio-reactive-led-strip copied to clipboard

Unit on x-axis in Filterbank Output

Open nxdefiant opened this issue 6 years ago • 3 comments

I would like to know what is the unit on the x-axis in the Filterbank Output. Asking because when I generate a 500Hz tone with speaker-test -t sin -f 500 the peak is around 2000.

nxdefiant avatar Dec 17 '17 10:12 nxdefiant

Try increasing the number of fft bins to increase the "resolution" of the x axis. You can do this by looking in config.py, line 85, N_FFT_BINS The units will be in Hz, but due to the way the frequencies are split into bins, you get peaks for a certain range of values. Increasing the number of bins reduces this range, giving more resolution.

not-matt avatar Dec 17 '17 20:12 not-matt

Still no change, tried with 256 which should be enough for a resolution of 50Hz on a scale of 10kHz. Also have not understood that value completely since it does not seem to be passed to numpy.fft.rfft().

nxdefiant avatar Dec 17 '17 20:12 nxdefiant

If I remember correctly, the x-axis has units of Mels. The Mel frequency scale is used because it is perceptually linear to the human ear, which has important implications for audio visualization.

The steps performed by the program are:

  • Take the FFT of a windowed segment of the audio signal
  • Map the powers of the FFT spectrum onto the Mel frequency scale, using a triangular overlapping filterbank
  • Normalize the amplitudes of the resulting Mel scale FFT bins

scottlawsonbc avatar Dec 25 '17 06:12 scottlawsonbc