Documentation Center 
Delay input by timevarying fractional number of sample periods
The Variable Fractional Delay block delays each element of the discretetime ND 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 D_{max}+1 most recent samples received at the In port for each channel, where D_{max} is the value you specify for the Maximum delay (Dmax) in samples parameter.
In FIR interpolation mode, the block stores the D_{max}+P+1 most recent samples received at the In port for each channel, where P is the value you specify for the Interpolation filter halflength (P) parameter.
In Farrow interpolation mode, the block stores the D_{max}+ +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 D_{min} and D_{max}, where D_{min} appears in the Valid delay range section on the Main pane of the block mask, and D_{max} is the value of the Maximum delay (Dmax) in samples parameter. The block clips delay values less than D_{min} to D_{min} and delay values greater than D_{max} to D_{max}.
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 D_{max}+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.
When you set the Input processing parameter to Elements as channels (sample based), the block treats each element of the ND input array, u, as an independent channel. The input to the Delay port, v, must either be an ND array of the same size and dimension as the input u, or be a scalar value, such that D_{min} ≤ v ≤ D_{max}.
For example, consider an MbyN input matrix. The block treats each of the M*N matrix elements as independent channels. The input to the Delay port can be an MbyN matrix of floatingpoint values in the range D_{min} ≤ v ≤ D_{max} that specifies the number of sample intervals to delay each channel of the input, or it can be a scalar floatingpoint value, D_{min} ≤ v ≤ D_{max}, by which to equally delay all channels.
In samplebased processing mode, the block treats an unoriented vector input as an Mby1 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.
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 M_{i} sequential time samples.
The input to the Delay port, v, contains floatingpoint 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 lengthM 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 lengthN row vector, containing one delay for each channel. Finally, the Delay port entry can be an MbyN matrix, containing a different delay for each corresponding element of the input.
For example, if v is the M_{i}by1 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.
The delay value specified at the Delay port serves as an index into the block's memory, U, which stores, at a minimum, the D_{max}+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.
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 = vvi % vf = fractional delay y = (1vf)*U(vi+1) + vf*U(vi)
In FIR Interpolation mode, the block provides a discrete set of fractional delays described by:
If v is less than P1, 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 P1), 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 D_{min} will be clipped to D_{min}.
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 P1.
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 halflength (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 F_{s}/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 "upsamplebyL" 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. 
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 D_{min} 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 D_{min} will be clipped to D_{min}.
If you select Use offcentered kernel, the block computes fractional delays using a Farrow filter with an offcentered kernel. This mode does not increase D_{min}, but if there are input delay values less than 1, the results are less accurate than the results achieved by keeping the kernel centered.
The diagrams in the following sections show the data types used within the Variable Fractional Delay block for fixedpoint 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 Type  Word Length  Fraction Length 

vf data type  Same word length as the Coefficients  Same as the word length 
HoldInteger data type  Same word length as the input delay value  0 bits 
Integer data type  32 bits  0 bits 
To compute the integer (v_{i}) and fractional (v_{f}) parts of the input delay value (v), the Variable Fractional Delay block uses the following equations:
The following diagram shows the fixedpoint data types used by the Linear interpolation mode of the Variable Fractional Delay block.
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 (v_{f}).
See the FixedPoint Data Types section of the FIR Interpolation reference page for a diagram showing the fixedpoint data types used by the Variable Fractional Delay block in FIR interpolation mode.
The following diagram shows the fixedpoint 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 fixedpoint 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 offcentered kernel
Diff is computed from the integer part of the delay value (v_{i}) and the Farrow filter length (N) according to the following equation:
The following diagram shows the fixedpoint data types used by the Digital Filter block's FIR direct form filter.
The dspaudioeffectsdspaudioeffects example illustrates three audio effects applied to a short segment of music. When you set the Audio effect of the Effect block to Flanging, the model uses the Variable Fractional Delay block to mix the original signal with a delayed version of itself.
To see the Flanging subsystem, rightclick the Effect block, and select Diagram > Mask > Look Under Mask. Next, doubleclick the Flanging block in the Effect block subsystem that just opened. The Flanging subsystem opens, and you can see the parameters of the Variable Fractional Delay block.
The Main pane of the Variable Fractional Delay block dialog appears as follows.
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.
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.
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.
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.
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.
The maximum delay that the block can produce, D_{max}. Input delay values exceeding this maximum are clipped to D_{max}.
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 FrameBased Processing in the DSP System Toolbox™ Release Notes for more information. 
The values with which the block's memory is initialized. See the Variable Integer Delay block for more information.
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.
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 D_{min} 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 D_{min} and compute all interpolated values using Linear interpolation.
In Farrow interpolation mode, you can select Use offcentered kernel. This option forces the block to preserve the value of D_{min} and compute the interpolated values using a farrow filter with an offcentered kernel.
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.
Select the rounding mode for fixedpoint operations.
Select the overflow mode for fixedpoint operations.
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 binarypoint 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 binarypoint only scaling that provides you with the best precision possible given the value and word length of the coefficients.
Use this parameter to specify how you would like to designate the product output word and fraction lengths. See FixedPoint 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 poweroftwo slope and a bias of zero.
Use this parameter to specify how you would like to designate the accumulator word and fraction lengths. See FixedPoint 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 poweroftwo slope and a bias of zero.
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 poweroftwo slope and a bias of zero.
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 poweroftwo slope and a bias of zero.
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 poweroftwo slope and a bias of zero.
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 poweroftwo slope and a bias of zero.
Select this parameter to prevent the fixedpoint tools from overriding the data types you specify on the block mask.
Port  Supported Data Types 

Input 

Delay 

Output 
