I'm trying to simulate the dispersion effect of a stiff string in a digital waveguide system, by using second-order all-pass filters.
I use a second order all-pass filter with this transfer function:
H(z) = a2 + a1 * z^-1 + z^-2
--------------------------
1 + a1 * z^-1 + a2 * z^-2
Let's suppose the filter coefficients are:
a1 = -1.86377279
a2 = 0.86982215
With the above coefficients, if I insert the 2nd order All-Pass filter inside a digital waveguide loop with a delay line of 168 samples (=> 262.5 Hz if the playback rate is 44100), I get a nice dispersion effect (a little exaggerated to study the phenomenon) but I get a big delay too in the output signal, so now my note is detuned.
A little simplified schema:
impulse --> (+) -------------------------------+-----> output
^ |
| |
very much v
detuned! |DELAY LINE|
| |168 smpls |
| |
+---------|2nd ord.|<-------------+
|ALL-PASS|
I noticed that if I manually modify the delay line length (by subtracting 41 samples from it) to compensate for the delay induced by the All-Pass filter, I could get the right tuning of the original note (about 262.5 Hz).
Now my question is:
- is there a formula to know exactly how much I should modify the delay line length to compensate for the delay generated from the 2nd order All-Pass filter with arbitrary a1, a2 coefficients?