I have the need to adjust the differential delay between two audio streams by a value less than one sampling period. So I thought to delay one stream by a fixed amount N, let's say 128 samples, and the other by a variable amount N+d, where d can range between -0.5 and +0.5 The ideal approach seemed to be the Thiran allpass filter, which is guaranteed stable for a fractional delay greater than N - 1. I coded it in C, using doubles, but I have problems with stability.... I cannot use N greater than 16, and even with this value, d cannot be greater (in absolute value) than 0.475, otherwise the filter diverges. Has anybody words of wisdom on this subject ? Before you ask, I would like to use large values for N, to bring the flatness of the delay error the nearest possible to Nyquist. Matlab simulations showed that N = 128 could be what the doctor ordered. TIA, Alberto
Is anybody familiar with the Thiran allpass filter ?
Started by ●December 21, 2003
Reply by ●December 22, 20032003-12-22
On 21 Dec 2003 12:38:06 -0800, adibene@yahoo.com (Alberto) wrote:>I have the need to adjust the differential delay between two audio >streams by a value less than one sampling period. So I thought to >delay one stream by a fixed amount N, let's say 128 samples, and the >other by a variable amount N+d, where d can range between -0.5 and >+0.5 > >The ideal approach seemed to be the Thiran allpass filter, which is >guaranteed stable for a fractional delay greater than N - 1. > >I coded it in C, using doubles, but I have problems with stability.... >I cannot use N greater than 16, and even with this value, d cannot be >greater (in absolute value) than 0.475, otherwise the filter diverges. > >Has anybody words of wisdom on this subject ? Before you ask, I would >like to use large values for N, to bring the flatness of the delay >error the nearest possible to Nyquist. Matlab simulations showed that >N = 128 could be what the doctor ordered. > >TIA, AlbertoHi, Wow. I'd be afraid to try to implement a Thiran approximation for N greater than, say, 2 or 3. Using N = 16 is like trying to build a 16th-order IIR filter. :-( Why not us an external delay of 126 samples, cascaded with a 2nd-order Thiran filter. By the way, those filters have a flatter group delay when d is negative than when d is positive. So if you need a delay of 128.5 samples, use an external delay of 127 samples with a 2nd(N=2)-order Thiran with d = -0.5. That will be better than using an external delay of 126 samples with a 2nd(N=2)-order Thiran with d = +0.5. Also, their delay is flat but only at low frequencies relative to the Fs sample rate. So having a high Fs helps keep you operating in the freq range where the Thiran group delay is flat. Good Luck, [-Rick-]
Reply by ●December 22, 20032003-12-22
"Alberto" <adibene@yahoo.com> wrote in message news:e9aa0d73.0312211238.6b2be62c@posting.google.com...> I have the need to adjust the differential delay between two audio > streams by a value less than one sampling period. So I thought to > delay one stream by a fixed amount N, let's say 128 samples, and the > other by a variable amount N+d, where d can range between -0.5 and > +0.5 > > The ideal approach seemed to be the Thiran allpass filter, which is > guaranteed stable for a fractional delay greater than N - 1. > > I coded it in C, using doubles, but I have problems with stability.... > I cannot use N greater than 16, and even with this value, d cannot be > greater (in absolute value) than 0.475, otherwise the filter diverges. > > Has anybody words of wisdom on this subject ? Before you ask, I would > like to use large values for N, to bring the flatness of the delay > error the nearest possible to Nyquist. Matlab simulations showed that > N = 128 could be what the doctor ordered. > > TIA, AlbertoHi Alberto, While I do not have much experience with Thiran filters, I have used Lagrange (FIR) filters for fractional delay approximation. They are really simple to implement and understand. There are no stability problems as with IIR filters. Lagrange filters are lowpass, so the filter order is decided by how much audio signal bandwidth you want to retain after filtering. If you don't care for frequencies above 5 kHz for a signal sampled at 44.1 kHz, choose a filter order whose magnitude response is 'high enough' at 0.11 norm-Hz. If you are not already aware of it, here is an excellent reference : "Splitting the unit delay", Laakso, T.I.; Valimaki, V.; Karjalainen, M.; Laine, U.K.; Signal Processing Magazine, IEEE , Volume: 13 Issue: 1 , Jan. 1996 ,Page(s): 30 -60 Use the hlagr2.m file to create your Lagrange FD filter from this toolset: http://www.acoustics.hut.fi/software/fdtools/ HTH Siddharth
Reply by ●December 23, 20032003-12-23
r.lyons@REMOVE.ieee.org (Rick Lyons) wrote in message news:<3fe71729.5131500@news.west.earthlink.net>...> Hi, > Wow. I'd be afraid to try to implement > a Thiran approximation for N greater than, say, > 2 or 3. Using N = 16 is like trying to build a > 16th-order IIR filter. :-( >Rick, thanks for your answer. Yes, you are right, pretending to go so high with the order of an IIR filter, even if stability is algorithmically guaranteed, would require much more than the 64-bit precision that C doubles offer.... :-( I have to rethink my choices, and maybe a FIR approach is more indicated.> Why not us an external delay of 126 samples, > cascaded with a 2nd-order Thiran filter. >The reason is that I need a flatness of the group delay that extends as near as possible to Nyquist. A 2nd-order Thiran filter doesn't fullfill this requirement.> Also, their delay is flat but only at > low frequencies relative to the Fs sample rate. > So having a high Fs helps keep you operating > in the freq range where the Thiran group delay > is flat. >Yes, that's why I chose in the first instance a 128th-order Thiran filter, but now I have seen it is unrealizable...> Good Luck,Thanks, I need it... :-) Alberto
Reply by ●December 23, 20032003-12-23
"Siddharth Mathur" <smathur@removethis.softhome.net> wrote in message news:<bs7jas$ndh$1@oasis.ccit.arizona.edu>...> > Hi Alberto, > > While I do not have much experience with Thiran filters, I have used > Lagrange (FIR) filters for fractional delay approximation. They are really > simple to implement and understand. There are no stability problems as with > IIR filters. Lagrange filters are lowpass, so the filter order is decided by > how much audio signal bandwidth you want to retain after filtering. If you > don't care for frequencies above 5 kHz for a signal sampled at 44.1 kHz, > choose a filter order whose magnitude response is 'high enough' at 0.11 > norm-Hz. >Hi Siddarth, as you have probably read in my previous answer to Rick, I am convincing myself that in effect a FIR approach, Lagrange or otherwise, is a better solution to my problem.> Use the hlagr2.m file to create your Lagrange FD filter from this toolset: > http://www.acoustics.hut.fi/software/fdtools/I have seen that, but I have to dynamically recompute the filter on the fly, based on user input, so Matlab is useful only to do simulations. But the computation of a Lagrange interpolator is so easy that there are no problems in doing it in C in real time.> If you are not already aware of it, here is an excellent reference : > "Splitting the unit delay", Laakso, T.I.; Valimaki, V.; Karjalainen, M.; > Laine, U.K.; > Signal Processing Magazine, IEEE , Volume: 13 Issue: 1 , Jan. 1996 ,Page(s): > 30 -60 >I keep reading references to that article, but I am unable to find it on Internet. I suspect that I have to be an IEEE member to get access to it, which I am not, and I can't justify the subscription for just reading a single article... would it be a terrible and unjustifiable breaking of the law if someone would send me a PDF copy ? The software I am developing will be distributed free of charge on Internet, so I cannot afford to spend much money for developing it... Alberto
Reply by ●December 24, 20032003-12-24
On 23 Dec 2003 09:39:53 -0800, adibene@yahoo.com (Alberto) wrote:>"Siddharth Mathur" <smathur@removethis.softhome.net> wrote in message news:<bs7jas$ndh$1@oasis.ccit.arizona.edu>... >> >> Hi Alberto, >> >> While I do not have much experience with Thiran filters, I have used >> Lagrange (FIR) filters for fractional delay approximation. They are really >> simple to implement and understand. There are no stability problems as with >> IIR filters. Lagrange filters are lowpass, so the filter order is decided by >> how much audio signal bandwidth you want to retain after filtering. If you >> don't care for frequencies above 5 kHz for a signal sampled at 44.1 kHz, >> choose a filter order whose magnitude response is 'high enough' at 0.11 >> norm-Hz. >> > Hi Siddarth, > as you have probably read in my previous answer to Rick, I am >convincing myself that in effect a FIR approach, Lagrange or >otherwise, is a better solution to my problem. > >> Use the hlagr2.m file to create your Lagrange FD filter from this toolset: >> http://www.acoustics.hut.fi/software/fdtools/ > > I have seen that, but I have to dynamically recompute the filter on >the fly, based on user input, so Matlab is useful only to do >simulations. But the computation of a Lagrange interpolator is so easy >that there are no problems in doing it in C in real time. > >> If you are not already aware of it, here is an excellent reference : >> "Splitting the unit delay", Laakso, T.I.; Valimaki, V.; Karjalainen, M.; >> Laine, U.K.; >> Signal Processing Magazine, IEEE , Volume: 13 Issue: 1 , Jan. 1996 ,Page(s): >> 30 -60 >> > I keep reading references to that article, but I am unable to find it >on Internet. I suspect that I have to be an IEEE member to get access >to it, which I am not, and I can't justify the subscription for just >reading a single article... would it be a terrible and unjustifiable >breaking of the law if someone would send me a PDF copy ? The software >I am developing will be distributed free of charge on Internet, so I >cannot afford to spend much money for developing it... > >AlbertoHi, am sorry to say but I don't have a copy of that paper. Just to make your life more complicated, I've heard that "Farrow" filters are useful for achieving a time delay. I don't know a thing about Farrow filters, but you might look into them. Good Luck, [-Rick-]
Reply by ●December 26, 20032003-12-26
I am wondering why nobody has suggested interpolating within a 2-sample delay line after suitable band limiting. The other stream could have a fixed 1-sample delay to centre it with respect to the 1st stream. Is this because of possible harmonic distortion? Hoping to learn something. Jim Adamthwaite
Reply by ●December 26, 20032003-12-26
"Jim Adamthwaite" <secad@netspace.net.au> wrote in message news:bshf91$2v0e$1@otis.netspace.net.au...> I am wondering why nobody has suggested interpolating within a 2-sample > delay line after suitable band limiting. The other stream could have a > fixed 1-sample delay to centre it with respect to the 1st stream. Is this > because of possible harmonic distortion?There are lots of ways to do what you suggest, although the delays have to be longer to accommodate good low-pass linear phase filters. Siddharth's suggestion is one of the common methods.
Reply by ●December 26, 20032003-12-26
Hello Alberto, You can use a Taylor's method to generate adjustable delay. Just operate a bank of several filters, I.e., a delay, a differentiator, a 2nd order differentiator etc. And then just use Taylor's theorem. f(x+h) = f(x)+h*f'(x)+h^2*f''(x)/2 + ... Where f(x) is the output of the delay, f'(x) is the output of the differentiator, and f''(x) is the output of the 2nd order differentiator and of course h is the fractional sample delay. This method requires a lot of terms when |h| gets near 0.5, so you can just make a simple poly phase filter that splits a unit delay into 4 or so phases and then use a Taylor's approach to 1st order to finish off the compensation. For example use a 4 phase polyphase filter where only one phase is used depending on your value of h. Then the output of the selected filter is then run into a delay and a differentiator where a range reduced value of h is used to handle the variable delay. Also you can generate polyphase versions of both a delay and a differentiator and then use h to select the phase and a range reduced h to be the multiplier when combining the outputs of the filters. IHTH, Clay "Alberto" <adibene@yahoo.com> wrote in message news:e9aa0d73.0312211238.6b2be62c@posting.google.com...> I have the need to adjust the differential delay between two audio > streams by a value less than one sampling period. So I thought to > delay one stream by a fixed amount N, let's say 128 samples, and the > other by a variable amount N+d, where d can range between -0.5 and > +0.5 > > The ideal approach seemed to be the Thiran allpass filter, which is > guaranteed stable for a fractional delay greater than N - 1. > > I coded it in C, using doubles, but I have problems with stability.... > I cannot use N greater than 16, and even with this value, d cannot be > greater (in absolute value) than 0.475, otherwise the filter diverges. > > Has anybody words of wisdom on this subject ? Before you ask, I would > like to use large values for N, to bring the flatness of the delay > error the nearest possible to Nyquist. Matlab simulations showed that > N = 128 could be what the doctor ordered. > > TIA, Alberto
Reply by ●December 28, 20032003-12-28
Thanks to all who offered further advices. I read the Laakso article and, taking also in consideration the fact that I must be able to recompute on the fly the h coefficients several times per second (when the user moves a slider on a panel), the solution that seems optimal for my needs is a 127 taps FIR filter whose coefficients are computed using the LS windowed sinc method. At least I don't risk divergences... and the flatness of the group delay as a function of the frequency is very good for this number of taps. TNX all Alberto






