1
$\begingroup$

I'm trying to downscale a 1D FFT (for displaying an audio spectrogram, like this: courtesy of https://stackoverflow.com/questions/18628773/what-is-on-the-y-axis-of-a-spectrogram-produced-by-pylabs-specgram-function

My question is: assuming I have a 512 bands spectrum, what would be the recommended interpolation algorithm to rescale the spectrum to 20 bands, for user visualization? Is a simple bilinear filter good enough?

To make my question clearer: I am interested in what the state of the art is regarding this today: what professional tools are used? An answer mentions sinc interpolation which will likely be high quality, but also maybe computationally expensive? Is it the best trade-off for a generic audio visualization tool?

$\endgroup$
8
  • 1
    $\begingroup$ Why don't you simply average every 16 bins, from the high resolution FFT, to get the each new bin of the 32 bins of the low resolution display...? $\endgroup$
    – Fat32
    Mar 18, 2022 at 23:31
  • $\begingroup$ That would probably be computationally simpler, as you don't have to deal with color values at that point, but just magnitudes $\endgroup$ Mar 18, 2022 at 23:59
  • $\begingroup$ Are your 20 bands you want to keep, are they uniformly sized in terms of linear frequency? or equal-sized in log frequency? $\endgroup$ Mar 19, 2022 at 1:29
  • $\begingroup$ @Fat32 just averaging bands 16-by-16 would be a very crude way to go at it. There should at least be some amount of windowing with overlap, and that leads us to this question :-) $\endgroup$ Mar 19, 2022 at 16:43
  • $\begingroup$ @robertbristow-johnson I'll have both cases. $\endgroup$ Mar 19, 2022 at 16:43

2 Answers 2

-1
$\begingroup$

For visual purposes, I assume that good image scaling methods are a decent starting point. Nothing (?) about a general spectrogram makes it totally unlike a general image in this respect, I think.

Bilinear is not a good algorithm for 20x downscale. For those factors it is going to perform ~ as well as nearest neighbour. A scaling kernel that at least lets all input pixels contribute to the output is a better bet. Lanczos? Gaussian? Triangular?

$\endgroup$
-1
$\begingroup$

Downscaling and downsampling are similar concepts.

Sinc interpolation, with the Sinc being a low pass filter kernel appropriate for the new sample rate, is a good method for downsampling interpolation with minimal information loss. Use a windowed Sinc for a reasonable length approximation filter. You can calculate the Sinc kernel on the fly, or pre-calculate a polyphase table of FIR filter coefficients.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.