IDEA: fractional delay line using sample rate conversion techniques?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
my earlier point of integer sample dealy for the treble because that's just a delay line which simply works amounts to mixing in a few "fir" stages

and then implementing any fractional delay for the low passed lower frequency drivers - which possibly could be all pass iir biquads - but could also be short (asymmetric, "time interpolating") fir because you only need flat response up to the lower XO frequencies

The OP needs to be careful in that many biquad IIR's have a built-in fractional sample delay themselves.
 
my earlier point of integer sample dealy for the treble because that's just a delay line which simply works amounts to mixing in a few "fir" stages

and then implementing any fractional delay for the low passed lower frequency drivers - which possibly could be all pass iir biquads - but could also be short (asymmetric, "time interpolating") fir because you only need flat response up to the lower XO frequencies

If you really know what you are doing you can certainly do things like you describe. But for tools that are intended for a more general audience, it's just not a good idea to put forth something that only works at certain frequencies.
 
The OP needs to be careful in that many biquad IIR's have a built-in fractional sample delay themselves.

Hi, OP here... what you are stating is the opposite of what I have observed (at least for the code I have seen). Can you point me to these fractional delay IIR sections? And how does that perform frequency-response wise?

If there is public domain IIR fractional delay code available I would sure like to know about it. I am currently wading into how to code this myself and that would save me some trouble...
 
I think Scott's point is that a IIR group delay will be a smooth, continuous function of the (continuous) filter prototype - there is also a fixed integer sample time part due to the discrete calculation steps too

but any small coefficient change within your word length, round off error, IIR intermediate accumulators word size will give a small linear group delay change - its not discretized into integer sample times
 
Last edited:
I think Scott's point is that a IIR group delay will be a smooth, continuous function of the (continuous) filter prototype - there is also a fixed integer sample time part due to the discrete calculation steps too

but any small coefficient change within your word length, round off error, IIR intermediate accumulators word size will give a small linear group delay change - its not discretized into integer sample times

There are essentially two kinds of delay in the IIR digital realm:
1. delay caused by phase lag/rotation inherent to the IIR filter
2. delay line type delay, where you use a FIFO buffer to spit out the sample that came N periods ago.

So, your stated facts correct, but I don't really understand what you mean or are trying to say.

With a continuous group delay coming from (1) above you don't necessarily get "flat" delay, e.g. the same delay independent of frequency like you do with (2). But you can get pretty close, the delay being the same until the very highest audio frequencies (e.g. above 10kHz) and the amplitude remaining unchanged using higher order IIR allpass. That is what I am currently coding (the Thiran AP). But practically speaking you need to use a higher order filter, and then choose a fractional delay that is near the order of the filter (the delay is specified in terms of sample periods instead of milliseconds). This is where the N-0.5 to N+0.5 comes in. This insures that the AP group delay has the properties that are desirable, e.g. flat group delay before any deviation.
 
Charlie think about the impulse response of an IIR lowpass, a0 is usually normalized to 1 so the second point is larger and then the decay starts. In a real lowpass the peak is always at the origin. In the IIR there is a virtual peak between point 0 and point 1 which depends on the frequencies and sample rate, simply a computational artifact. It's a good exercise in any case as a sanity check to run your coefficients on an impulse and FFT the result, the phase deviation between the analog prototype and the IIR will have a linear with frequency deviation representing a small delay. I could make a picture to illustrate.

Bob Orban of Orban Associates pointed this out (at least the first time I saw it), his facility with signal processing math is equaled by few.
 
Last edited:
Charlie think about the impulse response of an IIR lowpass, a0 is usually normalized to 1 so the second point is larger and then the decay starts. In a real lowpass the peak is always at the origin. In the IIR there is a virtual peak between point 0 and point 1 which depends on the frequencies and sample rate, simply a computational artifact. It's a good exercise in any case as a sanity check to run your coefficients on an impulse and FFT the result, the phase deviation between the analog prototype and the IIR will have a linear with frequency deviation representing a small delay. I could make a picture to illustrate.

Bob Orban of Orban Associates pointed this out (at least the first time I saw it), his facility with signal processing math is equaled by few.

I'm not used to thinking about the impulse response... I typically only think in terms of the frequency domain vis a vis amplitude and phase, and therefore group delay. If there are sample rate dependent behaviors I would love to learn a bit more about them... meaning these "sampling rate dependent computational artifacts" that you mentioned. Can you provide some links or references to that?
 
You can find at this link:
http://users.spa.aalto.fi/vpv/publications/vesan_vaitos/ch3_pt3_allpass.pdf
detailed info about using the Thiran allpass for fractional delay. It's easy and computationally light to implement it using IIR. The AP provides flat group delay to pretty high in the audio spectrum and has unity amplitude gain for all frequencies.

The motivation for choosing to use delay, D, that obeys N-0.5 <= D <= N+0.5 where N is the order of the AP filter is given in equation 3.137 on the last page. Stability and low error are the basis for this relationship.
 
Slide 5 in this presentation, the phase comes back to 0 at fs/2. consider that a real analog filter is almost 90 degrees at fs/2 the difference turns out to be linear with frequency and represents a fractional sample delay.

http://www.ti.com/ww/cn/uprogram/share/ppt/c5000/15iir_v102.ppt

I understand your fractional delay allpass, but you can't assume the rest of the filters have only integer sample delays.
 
Last edited:
Slide 5 in this presentation, the phase comes back to 0 at fs/2. consider that a real analog filter is almost 90 degrees at fs/2 the difference turns out to be linear with frequency and represents a fractional sample delay.

http://www.ti.com/ww/cn/uprogram/share/ppt/c5000/15iir_v102.ppt

But this behavior is not independent of frequency, and thus not very useful AND its for a low pass filter! The whole idea is to be able to modify phase without modifying amplitude...

Are we even talking about the same thing here?

EDIT: OK I see what you are saying, that the phase difference is linear with frequency and thus is a delay. But again, how is this useful? It's a lowpass filter...
 
Last edited:
EDIT: OK I see what you are saying, that the phase difference is linear with frequency and thus is a delay. But again, how is this useful? It's a lowpass filter...

I'm only saying that when you compute your allpass correction you need to factor in the built-in delays of your crossover IIR's to make the net what you want.

Getting this done with an R-Pi is a good thing, just trying to help. BTW the Pi is for Python another good thing.
 
I'm only saying that when you compute your allpass correction you need to factor in the built-in delays of your crossover IIR's to make the net what you want.

Getting this done with an R-Pi is a good thing, just trying to help. BTW the Pi is for Python another good thing.

Pi = Python, huh. Ah did not know that. What about the raspberry part of the name???

Don't worry, I can "take into account" everything very nicely using ACD. Have you looked that:
the Active Crossover Designer web page
ACD = "Active Crossover Designer" In a nutshell it's a complete set of tools for specifying active analog or IIR digital filter chains for loudspeaker crossovers. There is an add-on that shows the relative phase angle between drivers and the system group delay is provided (mentioning these since they are germane to what we have been talking about). The responses of the drivers are imported as FRD files. The user can take into account the spatial offsets of the drivers and create a very accurate model of the loudspeaker as seen at the microphone.

I initially designed ACD with the miniDSP products in mind, which I was using at the time. I am currently writing some code to implement all the ACD IIR filters in Linux via LADSPA plugins. The last things left to create are for delay, and this is where the Thiran AP and delay line routines will be used.
 
What you want to do is create a lowpass filter with a fractional delay.

My cheap/easy way of doing it: Use Matlab's fdatool or some other program to generate a lowpass FIR filter with a suitable passband/stopband response, but with a sample rate say 64x of the audio sampling freqency. You'll create a filter with an ungodly amount of taps, don't worry about it... nudge the filter characteristics around until you get a tap count that's divisible by 64. Then break the filter into 64 different filters:

generated taps 0, 64, 128, 192... = first filter (most delay)
generated taps 63, 127, 191, 255... = last filter (least delay)

The first filter will have a fractional delay that's 63/64 samples more than the last filter.
 
What you want to do is create a lowpass filter with a fractional delay.

My cheap/easy way of doing it: Use Matlab's fdatool or some other program to generate a lowpass FIR filter with a suitable passband/stopband response, but with a sample rate say 64x of the audio sampling freqency. You'll create a filter with an ungodly amount of taps, don't worry about it... nudge the filter characteristics around until you get a tap count that's divisible by 64. Then break the filter into 64 different filters:

generated taps 0, 64, 128, 192... = first filter (most delay)
generated taps 63, 127, 191, 255... = last filter (least delay)

The first filter will have a fractional delay that's 63/64 samples more than the last filter.

I'm looking for a "filter" that is all pass... that doesn't sound like what you are describing. But that is an interesting approach...

Using an IIR allpass filter I can get very fine (essentially infinitely fine) control of the delay. The only real concern is with how high in frequency the "flat" region extends up from DC - the higher the filter order the higher in frequency. Even with a modest order (e.g. 8th order) the "flat' group delay region extends well above 10kHz, and this is more than adequate for adjusting the relative delay between drivers in a loudspeaker crossover. That is all I was hoping to achieve. For more complex frequency and phase manipulation FIR filter are definitely the tool of choice, but I am looking to implement IIR filters only at this time.
 
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.