7:57 am

November 19, 2015

Hi all,

I've gone through and implemented most of the filters in chapter 6 but cannot get the 2nd order all pass filter working. The phase response is pretty much a straight line. I've contacted Will and he says the equations are correct, so has anyone else gotten the 2nd order APF working? (BTW, changing the tan function to tan(pi * fc / (Q * fs)) gives a phase response that looks like it should: -180 at fc -360 at nyquist. Not saying that's right but at least the freq and phase response graphs look correct)

Also, through searching for APFs on the web I came across the Audio EQ cookbook http://www.musicdsp.org/files/.....okbook.txt It has 2nd order equations for most of the filters in ch 6, but the coefficient equations are different from the book (except the LPF & HPF). The equations seems simple enough using the substitutions at the bottom of that page but again produce different coeffs from the book.

So my questions are

1) Did anyone get the 2nd order APF working?

2) Where did Will get the equations in the book? (I'd love to see a complete math work through for the BSF, BPF, or APF)

3) Why are the coefficient equations different from the Audio EQ cookbook?

thanks!

Derek

edit:: btw, I'm referring to the BiQuad filters.

7:40 pm

January 28, 2017

Hello

1) the APFs work fine. I just coded both filters for a new/updated module that I was working on. In fact, these are the identical equations as the APF in the Modules menu item in RAFX. Choose Modules -> Allpass Filters and that is the same algorithm. If you open the block diagram window you can see the coefficient calculations which change as you move the sliders. You can compare those coefficients to your own to see if your calculations are off (this is one of the reasons that I included these Modules with block diagrams populated). Use the analyzer and hit the Phase button (with no audio streaming) to see the phase response.

2) almost all of the IIR filters came from: the Lane et al source, Lane& Hillman, or the original Motorola App Notes (all the authors of Lane et. al. were employees at Motorola in the 1980's and they did the derivations - two of them were classmates of mine in grad school, so I am somewhat "loyal" to the Motorola versions). The Constant Q Peaking filter is from Zöler. The Direct-Z-Plane designs are from F.R.Moore. The all-pole first order filters are from Dodge and Jerse. The APFs actually came from a really OLD Regalia-Mitra paper that is copied here (this reference is incorrectly missing from the References; I will need to add it to the 2nd Edition)

http://www.ece.rochester.edu/~.....ric_EQ.pdf

3) the equations don't match the RBJ book because I did not use the RBJ book when writing the FX book - in fact, I've not implemented any of the RBJ cookbook filters personally (nothing against them, I've just always had my own algorithms).

There are multiple ways to synthesize IIR Digital Filters. So, you might find slightly different algorithms that produce the same result, in a similar way that there are multiple analog filter realizations that produce the same frequency response. In some cases, after doing some algebra, you realize the algorithms are identical. For example, the Regalia-Mitra paper above shows how to synthesize low shelving and peaking filters in an entirely different way than either the Lane et. al, or other sources.

The APFs I just coded use the following coefficient calculations (m_LeftFilter is a CBiQuad filter) - you can verify that these match the book code.

float theta_c = 2.0*pi*m_fFc/fs;

FOR APF1:

float fAlphaNumerator = tan((pi*m_fFc)/fs) - 1.0;

float fAlphaDenominator = tan((pi*m_fFc)/fs) + 1.0;

float fAlpha = fAlphaNumerator/fAlphaDenominator;

m_LeftFilter.m_f_a0 = fAlpha;

m_LeftFilter.m_f_a1 = 1.0;

m_LeftFilter.m_f_a2 = 0.0;

m_LeftFilter.m_f_b1 = fAlpha;

m_LeftFilter.m_f_b2 = 0.0;

FOR APF2 Note: m_fBW is the same thing as Q - for the 2nd Order APF, Q really means BandWidth (the range of frequencies over which the phase is adjusted):

float fAlphaNumerator = tan((pi*m_fBW)/fs) - 1.0;

float fAlphaDenominator = tan((pi*m_fBW)/fs) + 1.0;

float fAlpha = fAlphaNumerator/fAlphaDenominator;

float fBeta = -1.0*cos(theta_c);

m_LeftFilter.m_f_a0 = -1.0*fAlpha;

m_LeftFilter.m_f_a1 = fBeta*(1.0 - fAlpha);

m_LeftFilter.m_f_a2 = 1.0;

m_LeftFilter.m_f_b1 = fBeta*(1.0 - fAlpha);

m_LeftFilter.m_f_b2 = -1.0*fAlpha;

- Will

11:30 pm

November 19, 2015

Thanks Will!

I see the issue now. In the 2nd order APF you're using Q to mean BW (BW silder is in the APF module of RackAFX).

This requires an input range of some low number to several thousand for the BW, the module uses 0 to 10K.

I was using Q as the same range as the other filters, in a range of 0.1 to 20. In that case band width can still be calculated by Fc / Q.

(e.g. Fc of 1000 and Q of 0.25 gives a BW of 4000). The only difference with that implementation is the BW changes if you modulate Fc while keeping Q constant.

I'm clipping to just below pi / 2 so the BW never exceeds nyquist.

Please do add that distinction in the 2nd Edition. I think using the BW variable in the 2nd order APF tan equation (vs. Q) would keep the book more consistent.

I'll check out those references, thanks.

12:21 am

January 26, 2016

Hallo everyone

thank you for accepting me as member of this forum i have a code which implements a 1 order lowshelving filter using a 1 order allpass filter

but i have some questions can i make some questions the code is thisone some parts of this code are from a book, some parts are my

Now can i ask some questions????????????????

function [ Hd] = lowshelving( x,Wc,G )

V0=10^(G/20);

H0=V0-1;

H01=H0/2;

if G >=0

c=(tan(pi*Wc/2)-1)/(tan(pi*Wc/2)+1); %b

else

c=(tan(pi*Wc/2)-V0)/(tan(pi*Wc/2)+V0); %c

end;

xh=0;

for n=1:length(x)

xh_new=x(n)-c*xh;

ap_y=c*xh_new+xh;

xh=xh_new;

y(n)=0.5*H0*(x(n)+ap_y)+x(n);

end;

b0=1+(1+c)*H01

b1=c+(1+c)*H01

a0=1

a1=c

b = [ b0,b1]

a = [ a0,a1]

[sos,g]=tf2sos(b,a);

Hd=dfilt.df2sos(sos,g);

Most Users Ever Online: 55

Currently Online:

4 Guest(s)

Currently Browsing this Page:

1 Guest(s)

Top Posters:

Skyler: 48

Derek: 46

Peter: 41

Frodson: 40

clau_ste: 39

Gwen: 32

JimmyM: 30

TheSmile: 28

EZB: 24

lppier: 23

Member Stats:

Guest Posters: 1

Members: 525

Moderators: 1

Admins: 4

Forum Stats:

Groups: 11

Forums: 31

Topics: 550

Posts: 2158

Newest Members:

LamebrainEddy, SteveThackery, rawbirdtoe, Bill, hill william, NAUN_SONAR, sufy, Diane, Richard, drvenkmanModerators: W Pirkle: 259

Administrators: Tom: 67, JD Young: 80, Will Pirkle: 0, W Pirkle: 259