Documentation

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

To specify the filter coefficients, select the mode you want the FIR Rate Conversion block to operate in. Select the mode in the Coefficient source group box.

  • Dialog parameters — Enter information about the filter, such as coefficients, in the block dialog box.

  • Filter object — Specify the filter using a dsp.FIRRateConverter System object™.

  • Auto (default) — Choose the filter coefficients automatically.

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 DSP System Toolbox™ filter design functions such as firnyquist, firhalfband, firgr or firceqrip.

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.

When you select Auto, the block designs an N-th order, L-th band FIR Nyquist filter using N+1 length Kaiser window vector. firnyquist function designs the filter using the parameters specified in the block dialog box. The block uses the coefficients returned by the firnyquist function. For more information on the filter design, see Orfanidis [1].

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_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 three different modes. Select the mode in the Coefficient source group box.

  • Dialog parameters — Enter information about the filter, such as coefficients, in the block mask.

  • Filter object — Specify the filter using a dsp.FIRRateConverter System object.

  • Auto (default) — Choose the filter coefficients automatically.

Different items appear on the FIR Rate Conversion block dialog box depending on whether you select Dialog parameters, Filter object, or Auto in the Coefficient source group box.

 Specify Filter Characteristics in Dialog

 Specify Multirate Filter Object

 Choose Filter Coefficients Automatically

References

[1] Orfanidis, Sophocles J. Introduction to Signal Processing. Upper Saddle River, NJ: 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
UpsampleDSP System Toolbox
FIR DecimationDSP System Toolbox
FIR InterpolationDSP System Toolbox
CIC DecimationDSP System Toolbox
CIC InterpolationDSP System Toolbox
FIR Halfband InterpolatorDSP System Toolbox
FIR Halfband DecimatorDSP System Toolbox
IIR Halfband InterpolatorDSP System Toolbox
IIR Halfband DecimatorDSP System Toolbox
CIC Compensation InterpolatorDSP System Toolbox
CIC Compensation DecimatorDSP System Toolbox
dsp.CICCompensationDecimatorDSP System Toolbox
dsp.CICCompensationInterpolatorDSP System Toolbox
dsp.FIRHalfbandDecimatorDSP System Toolbox
dsp.FIRHalfbandInterpolatorDSP System Toolbox
dsp.FIRDecimatorDSP System Toolbox
dsp.FIRInterpolatorDSP System Toolbox
firnyquistDSP System Toolbox
firhalfbandDSP System Toolbox
firgrDSP System Toolbox
firceqripDSP System Toolbox

See the following sections for related information:

Introduced before R2006a

Was this topic helpful?