Contents

FIR Rate Conversion

Upsample, filter, and downsample input signals

Library

Filtering / Multirate Filters

dspmlti4

Description

The FIR Rate Conversion block resamples the discrete-time input such that its sample period is K/L times the input sample period (Tsi). K is the integer value you specify for the Decimation factor parameter, and L is the integer value you specify for the Interpolation factor parameter.

The block treats each column of the input as a separate channel, and resamples the data in each channel independently over time. To do so, the block implements a polyphase filter structure and performs the following operations:

  1. Upsamples the input to a higher rate by inserting L-1 zeros between input samples.

  2. Passes the upsampled data through a direct-form II transpose FIR filter.

  3. Downsamples the filtered data to a lower rate by discarding K-1 consecutive samples following each sample that the block retains.

The polyphase filter implementation is more efficient than a straightforward upsample-filter-decimate algorithm. See Orfanidis [1] for more information.

Specifying the Resampling Rate

You specify the resampling rate of the FIR Rate Conversion block using the Decimation factor and Interpolation factor parameters. For an Mi-by-N matrix input, the Decimation factor, K, and the Interpolation factor, L, must satisfy the following requirements:

  • K and L must be relatively prime integers; that is, the ratio K/L cannot be reduced to a ratio of smaller integers.

  • KL=MiMo, where Mi and Mo are the integer frame sizes of the input and output, respectively.

You can satisfy the second requirement by setting the Decimation factor, K, equal to the input frame size, Mi. When you do so, the output frame size, Mo, equals the Interpolation factor, L.

By changing the frame size in this way, the block is able to hold the frame period constant (Tfi = Tfo) and achieve the desired conversion of the sample period, such that

Tso=KL×Tsi

where Tso is the output sample period.

Specifying the FIR Filter Coefficients

You can specify the FIR filter coefficients in one of two ways:

  • To specify the coefficients on the dialog, select the Dialog parameters option in the Coefficient source group box.

  • To specify the coefficients using an mfilt object, select the Multirate filter object (MFILT) option in the Coefficient source group box.

When you select the Dialog parameters option, you use the FIR filter coefficients parameter to specify the numerator coefficients of the FIR filter transfer function H(z).

H(z)=B(z)=b1+b2z1++bmz(m1)

You can generate the FIR filter coefficient vector, [b(1) b(2) ... b(m)], using one of the Signal Processing Toolbox™ filter design functions (such as intfilt).

The coefficient vector you specify must have a length greater than the interpolation factor (m>L). The FIR filter must be a lowpass filter with a normalized cutoff frequency, no greater than min(1/L,1/K). The block internally initializes all filter states to zero.

Fixed-Point Data Types

The following diagram shows the data types used within the FIR Rate Conversion block for fixed-point signals.

You can set the coefficient, product output, accumulator, and output data types in the block dialog box as discussed in Dialog Box. The diagram shows that input data is stored in the input buffer in the same data type and scaling as the input. Filtered data resides in the output buffer in the output data type and scaling that you set in the block dialog. The block stores any initial conditions in the output buffer using the output data type and scaling that you set in the block dialog box.

The output of the multiplier is in the product output data type when at least one of the inputs to the multiplier is real. When both of the inputs to the multiplier are complex, the result of the multiplication is in the accumulator data type. For details on the complex multiplication performed, see Multiplication Data Types.

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

Examples

Example 1

The following figure shows how the FIR Rate Conversion block converts a 4-by-1 input with a sample period of 3/4, to a 3-by-1 output with a sample period of 1. The frame period (Tf) of 3 remains constant.

Example 2

The ex_audio_srcex_audio_src model provides a simple illustration of one way to convert a speech signal from one sample rate to another. In this model, the data is first sampled at 22,050 Hz and then resampled at 8000 Hz. If you listen to the output, you can hear that the high frequency content has been removed from the signal, although the speech sounds basically the same.

Dialog Box

Coefficient Source

The FIR Rate Conversion block can operate in two different modes. Select the mode in the Coefficient source group box. If you select

  • Dialog parameters, you enter information about the filter such as structure and coefficients in the block mask.

  • Multirate filter object (MFILT), you specify the filter using an mfilt object.

Different items appear on the FIR Rate Conversion block dialog depending on whether you select Dialog parameters or Multirate filter object (MFILT) in the Coefficient source group box. See the following sections for details:

Specify Filter Characteristics in Dialog

The Main pane of the FIR Rate Conversion block dialog appears as follows when Dialog parameters is selected in the Coefficient source group box.

Interpolation factor

Specify the integer factor, L, by which to upsample the signal before filtering.

FIR filter coefficients

Specify the FIR filter coefficients in descending powers of z.

Decimation factor

Specify the integer factor, K, by which to downsample the signal after filtering.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the filter defined in the block. For more information on FVTool, see the Signal Processing Toolbox documentation.

    Note:   If you specify a filter in the Multirate filter variable parameter, you must apply the filter by clicking the Apply button before using the View filter response button.

The Data Types pane of the FIR Rate Conversion block dialog appears as follows when Dialog parameters is specified in the Coefficient source group box.

Rounding mode

Select the rounding mode for fixed-point operations. The filter coefficients do not obey this parameter; they always round to Nearest.

    Note:   The Rounding mode and Overflow mode settings have no effect on numerical results when all the following conditions exist:

    • Product output data type is Inherit: Inherit via internal rule

    • Accumulator data type is Inherit: Inherit via internal rule

    • Output data type is Inherit: Same as accumulator

    With these data type settings, the block is effectively operating in full precision mode.

Overflow mode

Select the overflow mode for fixed-point operations. The filter coefficients do not obey this parameter; they are always saturated.

Coefficients data type

Specify the coefficients data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the coefficients data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same word length as input

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Coefficients data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Product output data type

Specify the product output data type. See Fixed-Point Data Types and Multiplication Data Types for illustrations depicting the use of the product output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Product output data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Accumulator data type

Specify the accumulator data type. See Fixed-Point Data Types for illustrations depicting the use of the accumulator data type in this block. You can set this parameter to:

  • A rule that inherits a data type, for example, Inherit: Inherit via internal rule

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Accumulator data type parameter.

See Specify Data Types Using Data Type Assistant for more information.

Output data type

Specify the output data type. See Fixed-Point Data Types for illustrations depicting the use of the output data type in this block. You can set it to:

  • A rule that inherits a data type, for example, Inherit: Same as accumulator

  • An expression that evaluates to a valid data type, for example, fixdt(1,16,0)

Click the Show data type assistant button to display the Data Type Assistant, which helps you set the Output data type parameter.

See Specify Block Output Data Types for more information.

Minimum

Specify the minimum value that the block should output. The default value is [] (unspecified). Simulink® software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Maximum

Specify the maximum value that the block should output. The default value is [] (unspecified). Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

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.

Specify Multirate Filter Object

The Main pane of the FIR Rate Conversion block dialog appears as follows when Multirate filter object (MFILT) is specified in the Coefficient source group box.

Multirate filter variable

Specify the multirate filter object (mfilt) that you would like the block to implement. You can do this in one of three ways:

  • You can fully specify the mfilt object in the block mask.

  • You can enter the variable name of a mfilt object that is defined in any workspace.

  • You can enter a variable name for a mfilt object that is not yet defined, as shown in the default value.

For more information on creating mfilt objects, see the mfilt function reference page.

View filter response

This button opens the Filter Visualization Tool (fvtool) from the Signal Processing Toolbox product and displays the filter response of the mfilt object specified in the Multirate filter variable parameter. For more information on FVTool, see the Signal Processing Toolbox documentation.

    Note:   If you specify a filter in the Multirate filter variable parameter, you must apply the filter by clicking the Apply button before using the View filter response button.

The Data Types pane of the FIR Rate Conversion block dialog appears similar to the following dialog when Multirate filter object (MFILT) is specified in the Coefficient source group box. The fixed-point data types you see depend on the mfilt object you use.

The fixed-point settings of the filter object specified on the Main pane are displayed on the Data Types pane. You cannot change these settings directly on the block mask. To change the fixed-point settings you must edit the filter object directly.

For more information on multirate filter objects, see the mfilt function reference page.

References

[1] Orfanidis, S. J. Introduction to Signal Processing. Prentice Hall, 1996.

Supported Data Types

PortSupported Data Types

Input

  • Double-precision floating point

  • Single-precision floating point

  • Fixed point

  • 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

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

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

See Also

DownsampleDSP System Toolbox
FIR DecimationDSP System Toolbox
FIR InterpolationDSP System Toolbox
UpsampleDSP System Toolbox
fir1Signal Processing Toolbox
fir2Signal Processing Toolbox
firlsSignal Processing Toolbox
upfirdnSignal Processing Toolbox

See the following sections for related information:

Was this topic helpful?