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?
edit:: btw, I'm referring to the BiQuad filters.
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)
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;
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;
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.
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 )
if G >=0
b = [ b0,b1]
a = [ a0,a1]
Most Users Ever Online: 152
Currently Browsing this Page:
Guest Posters: 1
Newest Members:Alex, oneday, Phelan Kane, audiocoder, agel, Makai, Abyz, Nonlinear, IgorVish, Arjuna
Moderators: W Pirkle: 470
Administrators: Tom: 74, JD Young: 80, Will Pirkle: 0, W Pirkle: 470