All Pass Filter coefficient formula
-
- KVRian
- Topic Starter
- 911 posts since 1 Dec, 2003 from tejas
For a given sample rate, the standard implementation of a 2 stage all pass filter produces a 180 phase shift around some frequency.
Is there a formula that accurately predicts this frequency for a given sample rate and coefficient?
I have been doing this empirically and it is making me nuts. More nuts than usual I might add ...
peace,
pj
Is there a formula that accurately predicts this frequency for a given sample rate and coefficient?
I have been doing this empirically and it is making me nuts. More nuts than usual I might add ...
peace,
pj
-
- Banned
- 12368 posts since 30 Apr, 2002 from i might peeramid
grab epm from my front page.
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.
-
- KVRian
- Topic Starter
- 911 posts since 1 Dec, 2003 from tejas
epm - "not found"xoxos wrote:grab epm from my front page.
Thanks anyway though ...
To be more clear, I'm simply looking for the formula - not a VSTi
(I have already done a couple of phaser effects)
peace,
pj
-
- Banned
- 12368 posts since 30 Apr, 2002 from i might peeramid
aah - now that i check, i published the "elements of physical modeling" pdf before i got that..
you should be able to deconstruct this to your application (phase calculation is used to shorten tuned delay line, the += function in the last line applies a negative value).
Code: Select all
c = *in9; // allpass coeff -1 to +1
af = 6.28318530717958647f / l; // l is length of tuned delay line in samples
ac = cos(af);
aa = -c * ac + 1.f;
ad = sin(af);
ab = -c * ad;
ac -= c;
theta = atan2((ab * ac - aa * ad),(aa * ac + ab * ad));
l += (float)(polestr + 1) * l * theta * .159154943091895f; // .5f * (1/pi)
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.
-
- KVRist
- 150 posts since 25 Jan, 2008 from Oregon, USA
That formula seems like it would work only at a particular sample rate. Also, stylistically, it is generally not a good idea to have code samples with variables named lower case l because it looks an awfully lot like the int 1, which I actually initially though, "why is he dividing two pi by one?"
-
- Banned
- 12368 posts since 30 Apr, 2002 from i might peeramid
i'm similarly at a loss with people who write out the entire variable name 'l' is much faster to type and i've never had difficulty identifying it visually in my own, condensed, concise, and thus readily legible code. there's no reason to criticise someone's style
oc that's not my code, and i apologise for not remembering (i get a bit blank under extended obstacles) it's probably madbrain or nollock.
i probably have at least 3 dozen pdfs on allpass coefficients if OP prefers one-stop shopping
oc that's not my code, and i apologise for not remembering (i get a bit blank under extended obstacles) it's probably madbrain or nollock.
i probably have at least 3 dozen pdfs on allpass coefficients if OP prefers one-stop shopping
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.
-
- KVRist
- 150 posts since 25 Jan, 2008 from Oregon, USA
So in the first two lines of the code snippet:
Does the value of c range from negative one to positive one or from negative ell to positive ell?
Also, it still seems very dependent on sample rate.
Code: Select all
c = *in9; // allpass coeff -1 to +1
af = 6.28318530717958647f / l; // l is length of tuned delay line
Also, it still seems very dependent on sample rate.
-
- Banned
- 12368 posts since 30 Apr, 2002 from i might peeramid
i'd expect you're right about sample rate. i don't think about filters.. i do other things, i'm sharing the only information i've been able to implement in ~3 years of searching and begging
if you want to pick it apart, i usually do sample rate modification using a 44100/samplerate ratio. perhaps without a comprehensive understanding of the algorithm, such a method would provide some advantage.
it's all sticks and rocks and pieces of string when you haven't had knowing better bought for you
if you want to pick it apart, i usually do sample rate modification using a 44100/samplerate ratio. perhaps without a comprehensive understanding of the algorithm, such a method would provide some advantage.
it's all sticks and rocks and pieces of string when you haven't had knowing better bought for you
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.
-
- KVRian
- Topic Starter
- 911 posts since 1 Dec, 2003 from tejas
Thanks to this thread I was able to get pretty close to calculating the gain coefficient for a given Fc phase transition.
The thing is I needed to apply a small (but not constant!) fudge factor to the equation to get the phaser output to actually cancel the frequency of interest, so ...
At this point I have the following formula for a two node phaser ( a single 180 degree shift ) :
Where rFudgeFactor was empirically found to be as follows :
These values are "pretty" close - but I need to know how to compute the gain coefficient exactly
Any thoughts?
peace,
pj
The thing is I needed to apply a small (but not constant!) fudge factor to the equation to get the phaser output to actually cancel the frequency of interest, so ...
At this point I have the following formula for a two node phaser ( a single 180 degree shift ) :
Code: Select all
rD = 2.0 * rFudgeFactor * rFreq * rInvSmplRate;
rGn = (1.0 - rD) / (1.0 + rD) ;
Code: Select all
48K sample rate
rFreq rFudgeFactor
110 1.1107
220 1.1108
440 1.1110
880 1.1120
1760 1.1156
96K sample rate
rFreq rFudgeFactor
110 1.1107
220 1.1108
440 1.1108
880 1.1110
1760 1.1119
Any thoughts?
peace,
pj
-
- Banned
- 12368 posts since 30 Apr, 2002 from i might peeramid
gain --> allpass --> 1.f
afaik
afaik
you come and go, you come and go. amitabha neither a follower nor a leader be tagore "where roads are made i lose my way" where there is certainty, consideration is absent.
-
- KVRian
- Topic Starter
- 911 posts since 1 Dec, 2003 from tejas
Yessir !xoxos wrote:gain --> allpass --> 1.f
afaik
But in the "classic phaser effect" configuration of summing the allpass signal with the dry signal there is a response null at the 180 degree phase shift frequency (this 180 degree phase shift is produced by the two-allpass-nodes-in-series configuration)
It is the relationship between this frequency and the allpass gain coeffient I wish to characterize.
I will probably do some more tests at a few more frequencies and sample rates to try to get a better feel for what is going on - but I still feel very much in the dark
peace,
pj
-
- KVRist
- 499 posts since 11 Jul, 2004 from Southern California, USA
In the following I assume that your allpass filter follows the design from http://ccrma.stanford.edu/~jos/waveguid ... Combs.html
or
http://crca.ucsd.edu/~msp/techniques/la ... de150.html
Assuming a pole at g and a zero at 1/g, the response is and the phase response isSetting this to π we getIndeed, substituting z = exp(i∙0) = 1 into the first expression gives H = -1, and graphing the phase response I've given shows that φ = 0 is the only solution. (Even though inverse tangent has multiple solutions, we take the tangent of both sides when solving for φ, so all of those multiple solutions collapse back to one value.) So if you're able to get phase inversion near some frequency other than 0, there may be a problem with your implementation.
or
http://crca.ucsd.edu/~msp/techniques/la ... de150.html
Assuming a pole at g and a zero at 1/g, the response is
Code: Select all
H = (1/z - 1/g) / (1/z - g)
Code: Select all
arg H = π - φ + 2∙arctan[(sin φ) / (g + cos φ)]
Code: Select all
-φ + 2∙arctan[(sin φ) / (g + cos φ)] = 0
(sin φ) / (g + cos φ) = tan(φ / 2)
= (1 - cos φ) / (sin φ)
sin² φ = g + (1-g)∙cos φ - cos² φ
1 = g + (1-g)∙cos φ
(1-g)/(1-g) = 1 = cos φ
φ = 0
-
- KVRist
- 499 posts since 11 Jul, 2004 from Southern California, USA
The previous post assumed g was real. If g is not real, there are three frequencies φ where the phase is inverted: φ = 0, ±arg(g-1). I can provide the derivation if you're interested.
Last edited by MackTuesday on Sat Jun 13, 2009 2:52 am, edited 1 time in total.
-
- KVRian
- Topic Starter
- 911 posts since 1 Dec, 2003 from tejas
Thanks Mack! - I'm doing some more empirical tests and I'll post the results later - briefly g is real and I can cancel an arbitrary single frequency with my test code from 27.5Hz to 14080Hz
-pj
-pj
-
- KVRist
- 499 posts since 11 Jul, 2004 from Southern California, USA
AAAAARRGH I made a mistake early in my calculations and EVERYTHING I'VE SAID IS WRONG.