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 to a period K/L times the input sample period, where the integer K is specified by the Decimation factor parameter and the integer L is specified by the Interpolation factor parameter. The resampling process consists of the following steps:

  1. The block upsamples the input to a higher rate by inserting L-1 zeros between input samples.

  2. The upsampled data is passed through a direct-form II transpose FIR filter.

  3. The block downsamples the filtered data to a lower rate by discarding K-1 consecutive samples following each sample retained.

K and L must be relatively prime integers; that is, the ratio K/L cannot be reducible to a ratio of smaller integers. The FIR Rate Conversion block implements the above three steps together using a polyphase filter structure, which is more efficient than straightforward upsample-filter-decimate algorithms. See Orfanidis [1] for more information.

The FIR filter coefficients parameter specifies the numerator coefficients of the FIR filter transfer function H(z).

The coefficient vector, [b(1) b(2) ... b(m)], can be generated by one of the Signal Processing Toolbox™ filter design functions (such as fir1), and should have a length greater than the interpolation factor (m>L). The filter should be lowpass with normalized cutoff frequency no greater than min(1/L,1/K). All filter states are internally initialized to zero.

The FIR Rate Conversion block supports real and complex floating-point and fixed-point inputs except for complex unsigned fixed-point inputs.

Frame-Based Operation

This block accepts only frame-based inputs. An Mi-by-N frame-based matrix input is treated as N independent channels, and the block resamples each channel independently over time.

The Interpolation factor, L, and Decimation factor, K, must satisfy the relation

for an integer output frame size Mo. The simplest way to satisfy this requirement is to let the Decimation factor equal the input frame size, Mi. The output frame size, Mo, is then equal to the Interpolation factor. This change in the frame size, from Mi to Mo, produces the desired rate conversion while leaving the output frame period the same as the input (Tfo = Tfi).

Latency

The FIR Rate Conversion block has no tasking latency. The block propagates the first filtered input (received at t=0) as the first output sample.

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 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 is stored in the output buffer in the output data type and scaling that you set in the block dialog. Any initial conditions are also stored in the output buffer in the output data type and scaling you set in the block dialog.

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.

Examples

The doc_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.

Diagnostics

An error is generated when the relation between K and L shown above is not satisfied.

(Input port width)/(Output port width) must equal the
(Decimation factor)/(Interpolation factor).

A warning is generated when L and K are not relatively prime; that is, when the ratio L/K can be reduced to a ratio of smaller integers.

Warning: Integer conversion factors are not relatively prime
in block 'modelname/FIR Rate Conversion
(Frame)'. Converting ratio L/M to l/m.

The block scales the ratio to be relatively prime and continues the simulation.

Dialog Box

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

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.

The Fixed point 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.

Overflow mode

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

Coefficients

Choose how you specify the word length and fraction length of the filter 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.

Accumulator

As depicted above, inputs to the accumulator are cast to the accumulator data type. The output of the adder remains in the accumulator data type as each element of the input is added to it. Use this parameter to specify how you would like to designate this accumulator word and fraction lengths.

You also use this parameter to specify the accumulator word and fraction lengths resulting from a complex-complex multiplication in the block. See Multiplication Data Types for more information.

Output

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

Lock scaling against changes by the autoscaling tool

Select this parameter to prevent any fixed-point scaling you specify in this block mask from being overridden by the autoscaling tool in the Fixed-Point Tool.

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:

For more information on creating mfilt objects, see the mfilt function reference page in the Filter Design Toolbox documentation.

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.

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

The fixed-point settings of the filter object specified on the Main pane are displayed on the Fixed-point 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 in the Filter Design Toolbox documentation.

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

DownsampleSignal Processing Blockset
FIR DecimationSignal Processing Blockset
FIR InterpolationSignal Processing Blockset
UpsampleSignal Processing Blockset
fir1Signal Processing Toolbox
fir2Signal Processing Toolbox
firlsSignal Processing Toolbox
upfirdnSignal Processing Toolbox

See the following sections for related information:

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS