Main Content

mfilt.farrowsrc

(Removed) Sample rate converter with arbitrary conversion factor

Compatibility

mfilt.farrowsrc has been removed. Use dsp.FarrowRateConverter instead. For more details, see Version History.

Syntax

hm = mfilt.farrowsrc(L,M,C)
hm = mfilt.farrowsrc
hm = mfilt.farrowsrc(l,...)

Description

hm = mfilt.farrowsrc(L,M,C) returns a filter object that is a natural extension of dfilt.farrowfd with a time-varying fractional delay. It provides an economical implementation of a sample rate converter with an arbitrary conversion factor. This filter works well in the interpolation case, but may exhibit poor anti-aliasing properties in the decimation case.

Note

You can use the realizemdl method to create a Simulink® block of a filter created using mfilt.farrowsrc.

Input Arguments

The following table describes the input arguments for creating hm.

Input Argument

Description

l

Interpolation factor for the filter. l specifies the amount to increase the input sampling rate. The default value of l is 3.

m

Decimation factor for the filter. m specifies the amount to decrease the input sampling rate. The default value for m is 2.

c

Coefficients for the filter. When no input arguments are specified, the default coefficients are [-1 1; 1, 0]

hm = mfilt.farrowsrc constructs the filter using the default values for l, m, and c.

hm = mfilt.farrowsrc(l,...) constructs the filter using the input arguments you provide and defaults for the argument you omit.

mfilt.farrowsrc Object Properties

Every multirate filter object has properties that govern the way it behaves when you use it. Note that many of the properties are also input arguments for creating mfilt.farrowsrc objects. The next table describes each property for an mfilt.farrowsrc filter object.

Name

Values

Description

FilterStructure

Character vector

Reports the type of filter object. You cannot set this property — it is always read only and results from your choice of mfilt object.

Arithmetic

Character vector

Reports the arithmetic precision used by the filter.

Coefficients

Vector

Vector containing the coefficients of the FIR lowpass filter

InterpolationFactor

Integer

Interpolation factor for the filter. It specifies the amount to increase the input sampling rate.

DecimationFactor

Integer

Decimation factor for the filter. It specifies the amount to increase the input sampling rate.

PersistentMemory

false or true

Determines whether the filter states are restored to their starting values for each filtering operation. The starting values are the values in place when you create the filter if you have not changed the filter since you constructed it. PersistentMemory returns to zero any state that the filter changes during processing. States that the filter does not change are not affected.

Examples

Interpolation by a factor of 8. This object removes the spectral replicas in the signal after interpolation.

 [L,M] = rat(48/44.1);
 Hm = mfilt.farrowsrc(L,M);           % We use the default filter
 Fs = 44.1e3;                         % Original sampling frequency
 n = 0:9407;                          % 9408 samples, 0.213 seconds long
 x  = sin(2*pi*1e3/Fs*n);             % Original signal, sinusoid at 1kHz
 y = filter(Hm,x);                    % 10241 samples, still 0.213 seconds
 stem(n(1:45)/Fs,x(1:45))             % Plot original sampled at 44.1kHz
 hold on
 % Plot fractionally interpolated signal (48kHz) in red
 stem((n(2:50)-1)/(Fs*L/M),y(2:50),'r','filled')
 xlabel('Time (sec)');ylabel('Signal value')
 legend('44.1 kHz sample rate','48kHz sample rate')

The results of the example are shown in the following figure:

Version History

Introduced in R2011a

collapse all

R2023a: mfilt.farrowsrc has been removed

mfilt.farrowsrc has been removed. Use dsp.FarrowRateConverter instead.

Update Code

This table shows how to update the existing code to use the dsp.FarrowRateConverter object.

Discouraged UsageRecommended Replacement

Initialize the mfilt.farrowsrc object. Set the input and output sample rate to 44.1 kHz and 48.1 kHz, respectively.

[L,M] = rat(48/44.1);                    
hm = mfilt.farrowsrc(L,M)

Pass the data to the object.

% Input sample rate
fs = 44.1e3;   
% 5120 samples, 0.232 second long signal            
n = (0:5119)'; 
% Original signal, sinusoid at 1 kHz
x  = sin(2*pi*1e3/fs*n);    
y_mfilt = filter(hm,x);

Initialize the dsp.FarrowRateConverter object. Set the PolynomialOrder property to 1 to have the same configuration as the default mfilt.farrowsrc object.

farrowSRCObj = dsp.FarrowRateConverter(...
PolynomialOrder=1);

Pass the data through the object.

Note that System objects operate column-wise on data while mfilt objects are agnostic to the dimension. Therefore, pass the data as a column vector to the object.

% Input sample rate
fs = 44.1e3;   
% 5120 samples, 0.232 second long signal            
n = (0:5119)'; 
% Original signal, sinusoid at 1 kHz
x  = sin(2*pi*1e3/fs*n);    
yObj = farrowSRCObj(x);

Verify the results by comparing the first 50 samples.

plot(y_mfilt,'ro') 
hold on
plot(yObj,'kx')
xlim([1 50])