# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# Variable Fractional Delay

Delay input by time-varying fractional number of sample periods

## Library

Signal Operations

dspsigops

## Description

The Variable Fractional Delay block delays each element of the discrete-time N-D input array, u, by a variable number of sample intervals. The input delay values can be integer or noninteger values. The block provides three different interpolation modes: Linear, FIR, and Farrow.

The block computes the value for each channel of the output based on the stored samples in memory most closely indexed by the Delay input, v, and the interpolation method specified by the Interpolation mode parameter.

• In Linear interpolation mode, the block stores the Dmax+1 most recent samples received at the In port for each channel, where Dmax is the value you specify for the Maximum delay (Dmax) in samples parameter.

• In FIR interpolation mode, the block stores the Dmax+P+1 most recent samples received at the In port for each channel, where P is the value you specify for the Interpolation filter half-length (P) parameter.

• In Farrow interpolation mode, the block stores the Dmax+$\frac{N}{2}$+1 most recent samples received at the In port for each channel, where N is the value you specify for the Farrow filter length (N) parameter.

The Variable Fractional Delay block assumes that the input values at the Delay port are between Dmin and Dmax, where Dmin appears in the Valid delay range section on the Main pane of the block mask, and Dmax is the value of the Maximum delay (Dmax) in samples parameter. The block clips delay values less than Dmin to Dmin and delay values greater than Dmax to Dmax.

You must consider additional factors when selecting valid Delay values for the FIR and Farrow interpolation modes. For more information about these considerations, refer to FIR Interpolation Mode or Farrow Interpolation Mode, respectively.

The Variable Fractional Delay block is similar to the Variable Integer Delay block, in that they both store a minimum of Dmax+1 past samples in memory. The Variable Fractional Delay block differs only in the way that these stored samples are accessed; a fractional delay requires the computation of a value by interpolation from the nearby samples in memory.

### Sample-Based Processing

When you set the Input processing parameter to Elements as channels (sample based), the block treats each element of the N-D input array, u, as an independent channel. The input to the Delay port, v, must either be an N-D array of the same size and dimension as the input u, or be a scalar value, such that DminvDmax.

For example, consider an M-by-N input matrix. The block treats each of the M*N matrix elements as independent channels. The input to the Delay port can be an M-by-N matrix of floating-point values in the range DminvDmax that specifies the number of sample intervals to delay each channel of the input, or it can be a scalar floating-point value, DminvDmax, by which to equally delay all channels.

In sample-based processing mode, the block treats an unoriented vector input as an M-by-1 matrix. In this mode, the output is also an unoriented vector.

The Initial conditions parameter specifies the values in the block's memory at the start of the simulation in the same manner as the Variable Integer Delay block. See the Variable Integer Delay block reference page for more information.

### Frame-Based Processing

When you set the Input processing parameter to Columns as channels (frame based), the block treats each of the N input columns as an independent channel containing Mi sequential time samples.

The input to the Delay port, v, contains floating-point values that specify the number of sample intervals to delay the current input.

The input to the Delay port can be a scalar value to uniformly delay every sample in every channel. It can also be a length-M column vector, containing one delay for each sample in the input frame. The block applies the set of delays contained in the vector identically to every channel of a multichannel input. The Delay port entry can also be a length-N row vector, containing one delay for each channel. Finally, the Delay port entry can be an M-by-N matrix, containing a different delay for each corresponding element of the input.

For example, if v is the Mi-by-1 matrix [v(1) v(2) ... v(Mi)]', the earliest sample in the current frame is delayed by v(1) fractional sample intervals, the following sample in the frame is delayed by v(2) fractional sample intervals, and so on. The block applies the set of fractional delays contained in v identically to every channel of a multichannel input.

The Initial conditions parameter specifies the values in the block's memory at the start of the simulation in the same manner as the Variable Integer Delay block. See the Variable Integer Delay block reference page for more information.

### Interpolation Modes

The delay value specified at the Delay port serves as an index into the block's memory, U, which stores, at a minimum, the Dmax+1 most recent samples received at the In port for each channel. For example, an integer delay of 5 on a scalar input sequence retrieves and outputs the fifth most recent input sample from the block's memory, U(6). The block computes fractional delays by interpolating between stored samples; the three available interpolation modes are Linear, FIR and Farrow.

#### Linear Interpolation Mode

For noninteger delays, at each sample time, the Linear Interpolation mode uses the two samples in memory nearest to the specified delay to compute a value for the sample at that time. If v is the specified fractional delay for a scalar input, the output sample, y, is computed as follows.

vi = floor(v)					% vi = integer delay
vf = v-vi					% vf = fractional delay
y = (1-vf)*U(vi+1) + vf*U(vi)

#### FIR Interpolation Mode

In FIR Interpolation mode, the block provides a discrete set of fractional delays described by:

If v is less than P-1, the block's behavior depends on the setting of the For small input delay values parameter. You can specify the block's behavior when the input delay value is too small to center the kernel (less than P-1), by setting the For small input delay values parameter:

• If you select Clip to the minimum value necessary for centered kernel, the block remains in FIR interpolation mode by clipping small input delay values to the smallest value necessary to center the kernel.

To determine the minimum delay value, select Clip to the minimum value necessary for centered kernel, and click Apply on the block mask. All input delay values less than the value displayed for Dmin will be clipped to Dmin.

• If you select Switch to linear interpolation if kernel cannot be centered, the block computes fractional delays using linear interpolation when the input delay value is less than P-1.

To add an extra delay to the minimum possible delay value, select the Disable direct feedthrough by increasing minimum possible delay by one check box. Checking this box prevents algebraic loops from occurring when you use the block inside a feedback loop.

In FIR Interpolation mode, the block implements a polyphase structure to compute a value for each sample at the desired delay. Each arm of the structure corresponds to a different delay value and the output computed for each sample corresponds to the output of the arm with a delay value nearest to the desired input delay. Thus, only a discrete set of delays is actually possible. The number of coefficients in each of the L filter arms of the polyphase structure is 2P. In most cases, using values of P between 4 and 6 will provide you with reasonably accurate interpolation values.

In this mode, the Signal Processing Toolbox™ intfilt function computes an FIR filter for interpolation.

For example, when you set the parameters on the block mask to the following values:

• Interpolation filter half-length (P): 4

• Interpolation points per input sample: 10

• Normalized input bandwidth: 1

The filter coefficients are given by:

b = intfilt(10,4,1);
The block then implements this filter as a polyphase structure, as described previously.

Increasing the Interpolation filter half length (P) increases the accuracy of the interpolation, but also increases the number of computations performed per input sample, as well as the amount of memory needed to store the filter coefficients. Increasing the Interpolation points per input sample (L) increases the number of representable discrete delay points, but also increases the simulation's memory requirements and does not affect the computational load per sample.

The Normalized input bandwidth (0 to 1) parameter allows you to take advantage of the bandlimited frequency content of the input. For example, if you know that the input signal does not have frequency content above Fs/4, you can specify a value of 0.5 for the Normalized input bandwidth (0 to 1) to constrain the frequency content of the output to that range.

 Note   You can consider each of the L interpolation filters to correspond to one output phase of an "upsample-by-L" FIR filter. Thus, the Normalized input bandwidth (0 to 1) value improves the stopband in critical regions, and relaxes the stopband requirements in frequency regions where there is no signal energy.

#### Farrow Interpolation Mode

In Farrow interpolation mode, the block uses the LaGrange method to interpolate values.

To increase the minimum possible delay value, select the Disable direct feedthrough by increasing minimum possible delay by one check box. Checking this box prevents algebraic loops from occurring when you use the block inside a feedback loop.

To specify the block's behavior when the input delay value is too small to center the kernel (less than -1), set the For small input delay values parameter:

• If you select Clip to the minimum value necessary for centered kernel, the block clips small input delay values to the smallest value necessary to keep the kernel centered. This increases Dmin but yields more accurate interpolation values.

To determine the minimum delay value, select Clip to the minimum value necessary for centered kernel, and click Apply on the block mask. All input delay values less than the value displayed for Dmin will be clipped to Dmin.

• If you select Use off-centered kernel, the block computes fractional delays using a Farrow filter with an off-centered kernel. This mode does not increase Dmin, but if there are input delay values less than -1, the results are less accurate than the results achieved by keeping the kernel centered.

### Fixed-Point Data Types

The diagrams in the following sections show the data types used within the Variable Fractional Delay block for fixed-point signals.

Although you can specify most of these data types on the Data Types pane of the block mask, the following data types are computed internally by the block and cannot be directly specified on the block mask.

Data TypeWord LengthFraction Length
vf data typeSame word length as the CoefficientsSame as the word length
HoldInteger data typeSame word length as the input delay value0 bits
Integer data type32 bits0 bits

 Note:   When the block input is fixed point, all internal data types are signed fixed point.

To compute the integer (vi) and fractional (vf) parts of the input delay value (v), the Variable Fractional Delay block uses the following equations:

#### Linear Interpolation Mode

The following diagram shows the fixed-point data types used by the Linear interpolation mode of the Variable Fractional Delay block.

#### FIR Interpolation Mode

The following diagram illustrates how the Variable Fractional Delay block selects the arm of the polyphase filter structure that most closely matches the fractional delay value (vf).

See the Fixed-Point Data Types section of the FIR Interpolation reference page for a diagram showing the fixed-point data types used by the Variable Fractional Delay block in FIR interpolation mode.

#### Farrow Interpolation Mode

The following diagram shows the fixed-point data types used by the Farrow interpolation mode of the Variable Fractional Delay block where:

• Farrow filter length (N) = 4

• For small input delay values = Clip to the minimum value necessary to for centered kernel

The following diagram shows the fixed-point data types used by the Farrow interpolation mode of the Variable Fractional Delay block where:

• Farrow filter length (N) = 4

• For small input delay values = Use off-centered kernel

Diff is computed from the integer part of the delay value (vi) and the Farrow filter length (N) according to the following equation:

$\begin{array}{l}Diff={v}_{i}-\left(\frac{N-1}{2}\right)\\ Diff\ge 0⇒Diff=0\\ Diff<0⇒Diff=-Diff\end{array}$

The following diagram shows the fixed-point data types used by the Digital Filter block's FIR direct form filter.

## Dialog Box

The Main pane of the Variable Fractional Delay block dialog appears as follows.

Interpolation mode

The method by which to interpolate between adjacent stored samples to obtain a value for the sample indexed by the input at the Delay port.

Interpolation filter half-length (P)

Half the number of input samples to use in the FIR interpolation filter. This parameter is only visible when the Interpolation mode is set to FIR.

Farrow filter length (N)

The number of input samples to use in the Farrow interpolation filter. This parameter is only visible when the Interpolation mode is set to Farrow.

Interpolation points per input sample

The number of points per input sample, L, at which a unique FIR interpolation filter is computed. This parameter is only visible when the Interpolation mode is set to FIR.

Normalized input bandwidth (0 to 1)

The bandwidth to which the interpolated output samples should be constrained. The value must be a real scalar between 0 and 1. A value of 1 specifies half the sample frequency. This parameter is only visible when the Interpolation mode is set to FIR.

Maximum delay (Dmax) in samples

The maximum delay that the block can produce, Dmax. Input delay values exceeding this maximum are clipped to Dmax.

Input processing

Specify how the block should process the input. You can set this parameter to one of the following options:

• Columns as channels (frame based) — When you select this option, the block treats each column of the input as a separate channel.

• Elements as channels (sample based) — When you select this option, the block treats each element of the input as a separate channel.

 Note:   The Inherited (this choice will be removed - see release notes) option will be removed in a future release. See Frame-Based Processing in the DSP System Toolbox™ Release Notes for more information.
Initial conditions

The values with which the block's memory is initialized. See the Variable Integer Delay block for more information.

Disable direct feedthrough by increasing minimum possible delay by one

Select this box to disable direct feedthrough by increasing the minimum possible delay value. When you set the Input processing parameter to Columns as channels (frame based), the block increases the minimum possible delay value by frame size  – 1. Similarly, when you set the Input processing parameter to Elements as channels (sample based), the block increases the minimum possible delay value by one sample.

Checking this box allows you to use the Variable Fractional Delay block in feedback loops.

For small input delay values

Specify the block's behavior when the input delay values are too small to center the kernel. This parameter is only visible when the Interpolation mode is set to FIR or Farrow.

You can specify how the block handles input delay values that are too small for the kernel to be centered using one of the following choices:

• In both FIR and Farrow interpolation modes, you can select Clip to the minimum value necessary for centered kernel. This option forces the block to increase Dmin to the smallest value necessary to keep the kernel centered.

• In FIR interpolation mode, you can select Switch to linear interpolation if kernel cannot be centered. This option forces the block to preserve the value of Dmin and compute all interpolated values using Linear interpolation.

• In Farrow interpolation mode, you can select Use off-centered kernel. This option forces the block to preserve the value of Dmin and compute the interpolated values using a farrow filter with an off-centered kernel.

Valid delay range

The values displayed in this section of the Main pane are calculated (in samples) by the block based on the current parameter settings.

• Dmin is the smallest possible valid delay value (in samples) based on the current settings of the block parameters. The block clips all input delay values less than Dmin to Dmin.

• Dmax is the maximum valid delay value (in samples) based on the current settings of the block parameters. The block clips all input delay values greater than Dmax to Dmax.

The Data Types pane of the Variable Fractional Delay block dialog appears as follows.

Rounding mode

Select the rounding mode for fixed-point operations.

Overflow mode

Select the overflow mode for fixed-point operations.

Coefficients

Choose how you specify the word length and fraction length of the filter coefficients.

• When you select Same word length as input, the word length of the filter coefficients match that of the input to the block. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

• When you select Specify word length, you can enter the word length of the coefficients, in bits. In this mode, the fraction length of the coefficients is automatically set to the binary-point only scaling that provides you with the best precision possible given the value and word length of the coefficients.

Product output

Use this parameter to specify how you would like to designate the product output word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the product output, in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output. This block requires power-of-two slope and a bias of zero.

Accumulator

Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the accumulator data type in this block:

• When you select Same as product output, these characteristics match those of the product output.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator, in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator. This block requires power-of-two slope and a bias of zero.

Product output polyval

Choose how you specify the word length and fraction length of the product output polyval data type. This parameter is only visible when the Interpolation mode is set to Farrow.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the product output polyval in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the product output polyval. This block requires power-of-two slope and a bias of zero.

Accumulator polyval

Choose how you specify the word length and fraction length of the accumulator polyval data type. This parameter is only visible when the Interpolation mode is set to Farrow.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the accumulator polyval in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the accumulator polyval. This block requires power-of-two slope and a bias of zero.

Multiplicand polyval

Choose how you specify the word length and fraction length of the multiplicand polyval data type. This parameter is only visible when the Interpolation mode is set to Farrow.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the multiplicand polyval, in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the multiplicand polyval. This block requires power-of-two slope and a bias of zero.

Output

Choose how you specify the output word length and fraction length:

• When you select Same as accumulator, these characteristics match those of the accumulator.

• When you select Same as first input, these characteristics match those of the first input to the block.

• When you select Binary point scaling, you can enter the word length and the fraction length of the output, in bits.

• When you select Slope and bias scaling, you can enter the word length, in bits, and the slope of the output. This block requires power-of-two slope and a bias of zero.

Lock data type settings against changes by the fixed-point tools

Select this parameter to prevent the fixed-point tools from overriding the data types you specify on the block mask.

## Supported Data Types

PortSupported Data Types

Input

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed and unsigned)

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Delay

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed and unsigned)

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers

Output

• Double-precision floating point

• Single-precision floating point

• Fixed point (signed and unsigned)

• 8-, 16-, and 32-bit signed integers

• 8-, 16-, and 32-bit unsigned integers