On Sun, Dec 20, 2020 at 05:58:22PM +0200, Paul Irofti wrote:
> Hi,
>
> Interesting diff.
>
> I did not have time to look at it thoroughly, but here are a few
> observations:
>
Hi,
Thanks for looking at this.
- why do you keep the symmetric filter coefficients? (this could halve your
> while-loop computations too, right?)
>
The filter function is indeed symetric:
h(t) = h(-t)
but they are used at points that are not symetric, we need:
...
h(-2 + x)
h(-1 + x)
h(0 + x)
h(1 + x)
h(2 + x)
...
h(-1 + x) is not the same as h(1 + x), so using the symetry to save
CPU cycles is not easy
I also tried to store only half of the static table to save few bytes;
this makes the code larger (and messy) so the benefit is not that
important for such a small filter order.
> - the diff's mainlobe look kind of strange at the end, why is that? What
> kind of filter did you use?
> the side-lobes seem also a bit strange as they
> do not decrease monotonically nor are the first sidelobes small and then
> increasing
To measure the response, we're supposed to apply the filter to a
peak. But on the link I sent the plot it the result of the whole
8k->48k conversion, so the peak is not really peak anymore and the
result is harder to understand.
Here's plot of the Fourier transform of the coefficients in the code:
https://vm.caoua.org/src/coef-dft.png
which should look way more familiar (x-axis is multiples of the
Nyquist frequency, y-axis is the Fourier transform amplitude in dB)
The filter is an ideal "sinc" low-pass with the cut-off frequency set
to 0.75 of the Nyquist frequency, multiplied by a Blackman window of
length 8:
h(t) = 0.75 * sinc(0.75 * pi * t) * win(t / 8)
where win(t) is the Blackman window function with a = 0.16, defined as:
win(t) = 0.5 * ((1 - a) + cos(2 * pi * x) + a * cos(4 * pi * x))
At 48kHz, the transition band starts at 0.75 * 24kHz = 18kHz. Besides
preserving audible frequencies, with this choice the ideal filter's
impulse response (the pure sinc function) crosses zero at the edges of
the window, which makes the result smoother (derivative is 0) and in
turn improves the roll-off.
> - would be nice to see some SNR comparisons if you can to better show the
> effects of your anti-aliasing effort
>
Here's an array of measurements I did.
https://vm.caoua.org/src/sweeps.html
The signal and the aliasing amplitudes are represented for each
frequency for various conversion ratios. Anything except the
increasing white curve (the signal, 0dB) is aliasing, the color indicates
its strength.