Page 1 of 1

2th Order Allpass Fractional Delay

PostPosted: Tue Apr 11, 2023 11:55 pm
by Tepeix
Here's a 2th allpass interpolation delay !)

But it's a very rough draft.. The coefficient are calculated in a very unconventional and approximate way...
If someone have a better way to calculate them don't hesitate to improve this !)

The 2th order help to improve the linear phase (or linear group delay) for some frequency.
I think that generally the coefficient are chosen to get the best phase for the bass.
I tried more to get the less possible phase distortion for the wider possible frequency.
Inevitably, the high of the signal will get more and more phase distortion in those two way..
But it seams that there's some choice of compromise..

(Maybe a way to achieve a even more perfect phase response would be to calculate 2 delay,
one with perfect bass and the other with perfect high then to mix them.. ...)

What do you think of it ?

Re: 2th Order Allpass Fractional Delay

PostPosted: Wed Apr 12, 2023 12:02 pm
by Tepeix
A very little optimization.
There was 2 unnecessary multiply in the interpolation.

(c2*y0) + (c1*y1) + y2 - (out*c1) - (prevout*c2) could become (c2*(y0-prevout)) + (c1*(y1-out)) +y2.

Re: 2th Order Allpass Fractional Delay

PostPosted: Wed Apr 12, 2023 4:52 pm
by Tepeix
And now a 3th order allpass delay !)
The barbarious design of the coefficient is even more simple here.
But they might exist more precise formula !

Re: 2th Order Allpass Fractional Delay

PostPosted: Wed Apr 12, 2023 7:47 pm
by martinvicanek
What you describe sounds like Thiran allpass interpolators.
https://www.dsprelated.com/freebooks/pa ... ators.html

Re: 2th Order Allpass Fractional Delay

PostPosted: Wed Apr 12, 2023 9:42 pm
by Tepeix
Thanks ! Searching with this base i find some other way to calculate the coefficients.

But it's a little tricky..
For a 3 order the frac must be +2, and it will give a delay from 2 to 3 sample (+base delay)

So if D = frac+2 we could use as coefficient :
C1= -3*(d-3)/(D+1) C2 = 3(D-2)*(D-3)/(D+1)*(D+2) C3= -(D-1)*(D-2)*(D-3)/(D+1)*(D+2)*(D+3)

I was thinking that it doesn't work in my allpass type because i tested first with a D<2 and in this case the filter is unstable.

Using this we get the 3th Thiran allpass. Very more precise than my approximation !

Re: 2th Order Allpass Fractional Delay

PostPosted: Fri Apr 14, 2023 3:07 pm
by Tepeix
A very little optimization for the thiran delay.
I discover that we could reverse the way the allpass are connected.
Using out(x)-sample(x) instead of sample(x)-out(x) make just the coefficient to reverse to produce the same effect.
So there's no need to make the coefficient negative, (just getting 4 sub less in the code..)

I also seen that this kind of allpass need other coefficient design. Here for higher order, the coefficient could not go from -1 to 1 or it become unstable, depending of the first coefficient, the next might have slower value.
(for example c1 = 0.5 and c2 = -0.5 is unstable but c1 = 0.5 c2 = -0.45 is ok)

Re: 2th Order Allpass Fractional Delay

PostPosted: Fri Apr 14, 2023 8:44 pm
by Tepeix
Finally i could not resist to try this one.
The optimal delay.. But it's just a name. it's difficult to know if a particular design is optimized..
Particularly for a simple delay..
This one is mono and a 4th order allpass.
Using sse it's possible to load 4 sample in one time. and also get 4 sample from out.
The coefficient are very simple, giving more phase distortion in bass..
I've seen that every new allpass order could give more precision, but like what i read from thiran allpass,
the more you already have, the less you gain adding more.
(just get a hard debug time, when i was trying to reverse the sse out order instead of the sample delay order..)

Re: 2th Order Allpass Fractional Delay

PostPosted: Mon Apr 17, 2023 2:02 pm
by Tepeix
Here's an allpass delay library that regroup all of those current research.
Just added 2 more, a 2th thiran and a 8th with naive coefficient..

The allpass seams a perfect solution to keep every frequency at the same level, but they have problem with transiant when the delay is changing..
I don't know how fast it might change and in which situation it provoke those problem.. For example for digital waveguide modeling they are some studies to diminish this problem of transient..

Downside is also the phase distortion that would occur at higher frequency.
Bass would be shifted slowly from 0 to 1 frac delay, and more linearly,
but the last higher frequency would always jump from 0 to 1 like they are no interpolation at all !
(but we don't hear it..)

Using higher order we could have a more linear shift for every frequency,
but the real improvement is more for the last octave of the sound..
When you switch to log view, you could see that it doesn't change so much to have higher order (excepting for more precise application)