Main Content

Fractional Delay Filters

This example shows how to implement fractional delay filters for hardware, including a variable fractional delay filter that uses a Farrow algorithm.

Fractional delay filters shift a digital sequence by a noninteger value by using interpolation and resampling combined into a single convolution filter. Consider the delay of a digital signal, $y\left\lbrack n\right\rbrack = x\left\lbrack n-D\right\rbrack$, where $D$ is an integer. This operation can be represented as a convolution filter, $y = h*x$ with a finite impulse response $h\left\lbrack n\right\rbrack =\delta \left\lbrack n-D\right\rbrack$. Delaying a sequence $x\left\lbrack n-D\right\rbrack$ is not defined whenever $D$ is not an integer. To make fractional delays realizable, filters add an intermediate $D/A$ interpolation stage that samples the output on the continuous domain. That is, $y\left\lbrack n\right\rbrack =\hat{\;x_n } \left(n-D\right)$ where $\hat{\;x_n }$ denotes some $D/A$ interpolation of the input sequence. The $D/A$ interpolating function depends on $n$, and can be thought of as a representation of an underlying analog signal model from which the sequence was sampled. This strategy is also used in other resampling problems such as rate conversion.

This example implements the filters from the Design Fractional Delay FIR Filters example for hardware. There are two example models.

  • FIRFracDelay.slx -- Sinc-based interpolation, which shows bandlimited reconstruction with an FIR filter.

  • farrowFracDelay.slx -- Lagrange-based interpolation, which shows polynomial reconstruction with a Farrow Filter.

The sinc-based filter can be more accurate but uses more hardware resources and is not programmable. The Farrow filter uses fewer resources and is programmable, allowing for variable fractional delays. The Farrow filter is therefore usually a better choice for hardware implementations.

Bandlimited Sinc Fixed Fractional Delay Filter

The Shannon-Whittaker interpolation formula $\hat{\;x} \left(t\right)=\sum_k \;x\left\lbrack k\right\rbrack \mathrm{sinc}\left(t-k\right)$ models bandlimited signals. That is, the immediate $D/A$ conversion $\hat{\;x}$ is a bandlimited reconstruction of the input sequence. For a delay value $D$, the fractional delay $y\left\lbrack n\right\rbrack =\hat{\;x} \left(n-D\right)$, can be represented as a convolutional filter. This filter is called the ideal bandlimited fractional delay filter and its impulse response is given by $h\left\lbrack k\right\rbrack = sinc\left\lbrack k-D\right\rbrack$. This ideal filter has an infinite, non-causal impulse response and therefore we need to window and truncate the response to realize the filter.

Generate the ideal filter sequence and a FIR filter approximation, and plot the filter coefficients.

D = 0.4;
hIdeal = @(k) sinc(k-D);
N = 6;
idxWindow = (-floor((N-1)/2):floor(N/2))';
i0 = -idxWindow(1);   % Causal latency
hApprox = hIdeal(idxWindow);

Use the DSP System Toolbox™ filter design functions to generate coefficients. The example model implements the filter by using the Discrete FIR Filter block from the DSP HDL Toolbox™ library.

FD = 44.1/48; % audio rate conversion
N = 10;
hFIR = designFracDelayFIR(FD,N);
model = 'FIRFracDelay';

Simulate the model and plot the filter output.

simout = sim(model);
plot(simout.FIRInput(1:length(simout.FIRFracDelay)-ceil(N/2)), 'o-'); %compare to length of FIR output
hold on
plot(simout.FIRFracDelay(ceil(N/2)+1:end), 'o-'); % remove transient samples
title('Fractional Delay using Bandlimited Sinc Filter')
xlabel('Sample Index');

Farrow Variable Fractional Delay Filter

The bandlimited sinc filter design requires a new set of coefficients for each fractional delay. However, a variable fractional delay can be implemented efficiently by using Lagrangian coefficients implemented with a Farrow structure. Because most of the Lagrangian coefficients are either 1, -1, or a power of two, the Farrow filter does not use many multipliers, making it suitable for hardware.

h = [ -1/6, 1/2, -1/3, 0; 1/2, -1, -1/2, 1; -1/2, 1/2, 1, 0; 1/6, 0, -1/6, 0 ]; % Lagrangian coefficients

The top level of the model contains a data source and the Farrow Fractional Delay subsystem.

model = 'farrowFracDelay';

The Farrow filter consists of a filter bank, and a sum-product stage. The filtering section is implemented using Discrete FIR Filter blocks. The Delay blocks account for the different latencies of each filter. Each filter implements one row of the Lagrangian coefficient matrix.

open_system('farrowFracDelay/Farrow Fractional Delay/Filter Bank')

The sum-product stage implements the fractional delay by multiplying the filter outputs with the fractional delay value.

open_system('farrowFracDelay/Farrow Fractional Delay/Sum Product Chain')

Simulate the model and plot the filter output.

simout = sim(model);
hold on
title('Fractional Delay using Farrow Filter')
xlabel('Sample Index');


The bandlimited sinc filter requires 10 multiply-adds to implement the convolution. The Farrow filter has many power of two, 1, or -1 coefficients and therefore only requires 6 multiply-adds. Furthermore, the Farrow filter allows for the fractional delay to change during runtime. To implement a variable fractional delay with the bandlimited sinc filter, the design would have to include a programmable FIR with several sets of coefficients stored in memory, and logic to determine which coefficients to use for each input fractional delay. Due to the low hardware cost, and the ability to perform variable fractional delay, the Farrow Filter is a more suitable architecture for variable fractional delay implementation in hardware.

See Also

Related Topics