Hello
I need to create a digital filter that mimics the analog filter shown below.
(s*Tz)^2 + s*Tz/Qz + 1
G(s) = Go * ----------------------
(s*Tp)^2 + s*Tp/Qp + 1
-
where Tz=1/(2*pi*fz) Tp=1/(2*pi*fp)
and fz=32 Qz=0.795 fp=15 Qp=0.65
Go = (Tp/Tz)^2
Using a circuit simulator the analog filter creates the frequency response below with around 12dB of boost at 10Hz and maximum 0.28dB attenuation at around 65Hz :-
According to minidsp LT calculator this yields the following coefficients [b0,b1,b2,a1,a2]
1.000281127314030
-1.999244425945940
0.998964394840831
-1.999244853617290
0.999245094483513
According to the same spreadsheet yields a frequency response which confirms the frequency response of the digital filter with 12 dB boost at 10Hz.
Now I plug the same coefficients into Audioweaver Biquad Cascade (HP) and this is the frequency response I am getting with only 10dB boost at 10Hz and maximum -0.08dB attenuation so the question is, is there a bug in the frequency response calculation or is there something wrong with the way Audioweaver implements the biquad ?
5:52pm
Hey DSPDude,
Using Audio Weaver, I can reproduce the 10 dB boost frequency response for your Biquad module using a 192 KHz sampling rate and the provided coefficients. However, if I use MATLAB and reproduce the plot using the full double-precision coefficients, I see the expected ~12 dB boost. So the single-precision coefficients used by the module are not able to reproduce the filter designed with double-precision in mind.
The main issue here is that with a 10 Hz cutoff frequency and a 192 KHz sampling rate, the poles and zero's of the filter are very close to the real axis of the unit circle, and so the coefficients are highly susceptible to quantization issues. Using a single-precision system, the coefficient quantization has a noticeable impact on the frequency response of this filter.
While the desired filter is not implementable as a Biquad filter on a single-precision system, a possible way to mitigate the coefficient quantization issue is to decimate to a lower frequency.
I hope this helps
-Axel
10:13pm
Hi Axel
So are you saying that minidsp don't achieve this response on their single precision SHARC dsp hardware even though the double precision of the spreadsheet says otherwise ?
Lets say you implement the analog version of the filter but also offer the prewarp frequency as a parameter, would that help making the response closer to the desired response ?
Regards
David
2:02am
Hi Axel
I tried the downsampling/upsampling trick and downsampled to 12KHz (divide by 16) and recalculated the coefficients accordingly. So yes the frequency response is much much better ;) However when I play audio through that channel I get this squeaky distorted sound. I tried the decimator and interpolator but the same result. Any tricks using this ?
EDIT: If I remove the Biquad in between the Down-Sampler and Up-Sampler I still get the same distorted scratchy/squeeky sound.
Regards
David
9:21pm
Hi David,
You'll need to use the FIRDecimator and the FIRInterpolater modules to avoid the aliasing that you're hearing. The rule of thumb for the FIR filter length is decimation factor * 16, so a 256 tap filter should be used for you 16 X decimation. Also keep in mind that you probably don't need to decimate by 16 to achieve the filter that you want - 4 X might be Ok. The more decimation, the more expensive the FIRs and the more delay you have to account for in your system.
A debug tip for when you run into things like this in the future: setup a sink module at the input and output of the part of the system in question, and compare the frequency plot at the two sinks. In the case with the Upsampler and Downsampler modules, it would have shown that the output of the Upsampler (Sink1 below) had signs of aliasing:
-Axel
9:40pm
Hi Axel
Yes you are right. Resampling at 12KHz means I still have the baseband signal convolved to 12K, 24K, 36K, 48K.... spectras, some of it which I can still hear of course although a woofer would have trouble reproducing these out of band signals !
Anyway I decided to decimate down by 4 to 48KHz and the frequency response is much more accurate than at 192KHz and I don't have problems with the aliasing junk !
Regards
David