Page 1 of 1

LPF doesn't work as supposed

Posted: Sat Jun 06, 2020 7:18 am
by juha_tp
1st order LPF implementation schematic can be found from here does not give correct response when exported to VST (VST Analyzer software). What I get are these responses:

LPF1_issue.png
LPF1_issue.png (40.71 KiB) Viewed 26181 times


(lower response after normalizing a0=1)
(NOTE: red curve is for high shelf filter )

Filter is designed using Octave:

Code: Select all

%% Butterworth LPF1 approximation for Linkwitz crossfeed use 
%% fc @ 700Hz
function [b, a] = LR_crossfeed_LPF1(x)
% x = fs 
switch x
  case { 44100, 88200, 176400, 352800 }
    b(1) = -1.27962418247E-17*x^3+8.46647384248E-12*x^2-1.743160919708E-06*x+0.131910297106252;
    b(2) = b(1);
    a(1) = -1.63998176028E-17*x^3+1.089084487604E-11*x^2-2.2605860763131E-06*x+2.17451639264416;
    a(2) = -1.97934198689E-17*x^3+1.3055959391E-11*x^2-2.669817551786E-06*x-1.80141773027551;
  case { 48000, 96000, 192000, 384000 }
    b(1) = -9.12314114159E-18*x^3+6.56981379479E-12*x^2-1.472180284138E-06*x+0.121238164126997;
    b(2) = b(1);
    a(1) = -1.17911077076E-17*x^3+8.51964831143E-12*x^2-1.9232664955434E-06*x+2.16129807049821;
    a(2) = -1.40130321601E-17*x^3+1.00625912303E-11*x^2-2.240688152629E-06*x-1.81838475852698;
  otherwise % other fs ... do nothing
    b = [1 0 ];
    a = [1 0 ];
endswitch

endfunction


and it gives this response in Octave (and in all other software I've tested so far):

lpf1.png
lpf1.png (16.02 KiB) Viewed 26164 times


(green = target response, blue thin -- = BLT version, Earlevel plot https://i.postimg.cc/j27DLqVg/earlevel-LPF1.png)

In comparison, 1st order high shelf filter implementation there in plot and schematic gives same response on both software.

Any suggestions on possible culprits for the issue?

Re: LPF doesn't work as supposed

Posted: Sat Jun 06, 2020 4:45 pm
by martinvicanek
Check your coefficients. In the Ruby box you have the suspicious line

a21 = a20/a20

which could be a typo.

Re: LPF doesn't work as supposed

Posted: Sat Jun 06, 2020 5:37 pm
by juha_tp
Hmm... I think it's OK that way (I don't have access to schematic ATM so I can't check if all coefficients are divided by a20 there) ... meaning as a21 = a20 and you scale by a20 then a21 = 1 (i.e. a21=a20/a20) ... actually, this can be checked with attached Octave listing as well if you scale by b(1) there it results following coefficients:

Code: Select all

a = [ 1   1 ]
b= [ 29.7506663062669  -26.9222391815198 ]


which are OK as seen in plot: https://i.postimg.cc/4NhvmXwC/lpf-earlevel.png

Re: LPF doesn't work as supposed

Posted: Sat Jun 06, 2020 6:39 pm
by martinvicanek
The instruction a21 = a20/a20 looked weird to me, but if a21 = 1 is correct then you have a pole at z = -1. That means your filter rings with Nyquist frequency forever! For a stable filter all poles must lie inside the unit circle on the z-plane. Maybe you have the a and b coefficients interchanged?

Re: LPF doesn't work as supposed

Posted: Sat Jun 06, 2020 7:23 pm
by juha_tp
Thanks,
probably it's related to what you suggest because of I can replicate that mirrored response (showing in my 1st post image) by swapping a and b... but, IIRC, I tried swapping coefficients earlier in FS code and the result was not OK in VST analyzer (actually no response at all (checked from -3000dB...3000dB range) so maybe it resulted a blown filter then). (NOTE: I'm running FS on 64-bit W10 ... and also VST Analyzer is an old 32-bit software now running in same PC so maybe something is not fully trusty anymore...).

So, I'll have to re-try by swapping the coefficients in FS ... .

Re: LPF doesn't work as supposed

Posted: Sun Jun 07, 2020 9:07 am
by adamszabo
You dont have to use vst analyzer, you can have an impulse as your input, and connect the filter output to a transfer function windows and you can see the same graph live in FlowStone

Re: LPF doesn't work as supposed

Posted: Tue Jun 09, 2020 5:05 pm
by juha_tp
OK, got the LPF working by swapping coefficients as MV suggested.