Firstly, I am new to DSP and have no real education in it, but I am developing an audio visualization program and I am representing an FFT array as vertical bars as in a typical frequency spectrum visualization.
The problem I had was that the audio signal values changed too rapidly to produce a pleasing visual output if I just mapped the FFT values directly:
So I apply a simple function to the values in order to "smooth out" the result:
// pseudo-code
delta = fftValue - smoothedFftValue;
smoothedFftValue += delta * 0.2;
// 0.2 is arbitrary - the lower the number, the more "smoothing"
In other words, I am taking the current value and comparing it to the last, and then adding a fraction of that delta to the last value. The result looks like this:
So my question is:
Is this a well-established pattern or function for which a term already exsits? Is so, what is the term? I use "smoothing" above but I am aware that this means something very specific in DSP and may not be correct. Other than that it seemed maybe related to a volume envelope, but also not quite the same thing.
Are there better approaches or further study on solutions to this which I should look at?
Thanks for your time and apologies if this is a stupid question (reading other discussions here, I am aware that my knowledge is much lower than the average it seems).
Answer
What you've implemented is a single-pole lowpass filter, sometimes called a leaky integrator. Your signal has the difference equation:
$$ y[n] = 0.8 y[n-1] + 0.2 x[n] $$
where $x[n]$ is the input (the unsmoothed bin value) and $y[n]$ is the smoothed bin value. This is a common way of implementing a simple, low-complexity lowpass filter. I've written about them several times before in previous answers; see [1] [2] [3].
No comments:
Post a Comment