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, , where is an integer. This operation can be represented as a convolution filter, with a finite impulse response . Delaying a sequence is not defined whenever is not an integer. To make fractional delays realizable, filters add an intermediate interpolation stage that samples the output on the continuous domain. That is, where denotes some interpolation of the input sequence. The interpolating function depends on , 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 models bandlimited signals. That is, the immediate conversion is a bandlimited reconstruction of the input sequence. For a delay value , the fractional delay , can be represented as a convolutional filter. This filter is called the ideal bandlimited fractional delay filter and its impulse response is given by . 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); plot_causal_fir("Sinc",D,N,i0,hApprox,hIdeal); 

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'; open_system(model) set_param(model,'SimulationCommand','Update') 

Simulate the model and plot the filter output.

simout = sim(model); figure 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') ylabel('Magnitude'); 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'; open_system(model) set_param(model,'SimulationCommand','Update') 

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); figure plot(simout.farrowInput(1:length(simout.farrowOutput)-3),'o-'); hold on plot(simout.farrowOutput(4:end),'o-'); title('Fractional Delay using Farrow Filter') ylabel('Magnitude'); xlabel('Sample Index'); 

Results

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.