# dsp.AllpassFilter

Single section or cascaded allpass filter

## Description

The dsp.AllpassFilter object filters each channel of the input using allpass filter implementations. To import this object into Simulink®, use the MATLAB® System block.

To filter each channel of the input:

1. Create the dsp.AllpassFilter object and set its properties.

2. Call the object with arguments, as if it were a function.

## Creation

### Description

Allpass = dsp.AllpassFilter returns an allpass filter System object™, Allpass, that filters each channel of the input signal independently using an allpass filter, with the default structure and coefficients.

example

Allpass = dsp.AllpassFilter(Name,Value) returns an allpass filter System object, Allpass, with each property set to the specified value.

## Properties

expand all

Unless otherwise indicated, properties are nontunable, which means you cannot change their values after calling the object. Objects lock when you call them, and the release function unlocks them.

If a property is tunable, you can change its value at any time.

You can specify the internal allpass filter implementation structure as one of | Minimum multiplier | Lattice | Wave Digital Filter. Each structure uses a different set of coefficients, independently stored in the corresponding object property.

Specify the real allpass polynomial filter coefficients. Specify this property as either an N-by-1 or N-by-2 matrix of N first-order or second-order allpass sections. The default value defines a stable second-order allpass filter with poles and zeros located at ±π/3 in the Z plane.

Tunable: Yes

#### Dependencies

This property is applicable only when the Structure property is set to Minimum multiplier.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the real allpass coefficients in the Wave Digital Filter form. Specify this property as either a N-by-1 or N-by-2 matrix of N first-order or second-order allpass sections. All elements must have absolute values less than or equal to 1. This value is a transformed version of the default value of AllpassCoefficients, computed using allpass2wdf(AllpassCoefficients). These coefficients define the same stable second-order allpass filter as when Structure is set to 'Minimum multiplier'.

Tunable: Yes

#### Dependencies

This property is only applicable when the Structure property is set to Wave Digital Filter.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Specify the real or complex allpass coefficients as lattice reflection coefficients. Specify this property as either a row vector (single-section configuration) or a column vector. This value is a transformed and transposed version of the default value of AllpassCoefficients, computed using transpose(tf2latc([1 h.AllpassCoefficients])). These coefficients define the same stable second-order allpass filter as when Structure is set to 'Lattice'.

Tunable: Yes

#### Dependencies

This property is applicable only if the Structure property is set to Lattice.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Indicate if last section is first order or second order. When you set TrailingFirstOrderSection to true, the last section is considered to be first-order, and the second element of the last row of the N-by-2 matrix is ignored. When you set TrailingFirstOrderSection to false, the last section is considered to be second-order.

## Usage

### Description

example

y = Allpass(x) filters the input signal x using an allpass filter to produce the output y. Each column of x is filtered independently as a separate channel over time.

### Input Arguments

expand all

Data input, specified as a vector or a matrix. This object also accepts variable-size inputs. Once the object is locked, you can change the size of each input channel, but you cannot change the number of channels.

Data Types: single | double
Complex Number Support: Yes

### Output Arguments

expand all

Filtered output, returned as a vector or a matrix. The size, data type, and complexity of the output signal matches that of the input signal.

Data Types: double | single
Complex Number Support: Yes

## Object Functions

To use an object function, specify the System object as the first input argument. For example, to release system resources of a System object named obj, use this syntax:

release(obj)

expand all

 freqz Frequency response of discrete-time filter System object fvtool Visualize frequency response of DSP filters impz Impulse response of discrete-time filter System object info Information about filter System object coeffs Returns the filter System object coefficients in a structure cost Estimate cost of implementing filter System object grpdelay Group delay response of discrete-time filter System object
 step Run System object algorithm release Release resources and allow changes to System object property values and input characteristics reset Reset internal states of System object

## Examples

collapse all

Note: This example runs only in R2016b or later. If you are using an earlier release, replace each call to the function with the equivalent step syntax. For example, myObject(x) becomes step(myObject,x).

Construct the Allpass Filters

Fs  = 48000;    % in Hz
FL = 1024;
APF1 = dsp.AllpassFilter('AllpassCoefficients',...
[-0.710525516540603   0.208818210000029]);
APF2 =  dsp.AllpassFilter('AllpassCoefficients',...
[-0.940456403667957   0.6;...
-0.324919696232907   0],...
'TrailingFirstOrderSection',true);

Construct the Transfer Function Estimator to estimate the transfer function between the random input and the Allpass filtered output

TFE = dsp.TransferFunctionEstimator('FrequencyRange',...
'onesided','SpectralAverages',2);

Construct the ArrayPlot to plot the magnitude response

AP = dsp.ArrayPlot('PlotType','Line','YLimits', [-80 5],...
'YLabel','Magnitude (dB)','SampleIncrement', Fs/FL,...
'XLabel','Frequency (Hz)','Title','Magnitude Response',...
'ShowLegend', true,'ChannelNames',{'Magnitude Response'});

Filter the Input and show the magnitude response of the estimated transfer function between the input and the filtered output

tic;
while toc < 5
in  = randn(FL,1);
out = 0.5.*(APF1(in) + APF2(in));
A = TFE(in, out);
AP(db(A));
end

## Algorithms

expand all

The transfer function of an allpass filter is given by

$H\left(z\right)=\frac{c\left(n\right)+c\left(n-1\right){z}^{-1}+...+{z}^{-n}}{1+c\left(1\right){z}^{-1}+...+c\left(n\right){z}^{-n}}$.

c is allpass polynomial coefficients vector. The order, n, of the transfer function is the length of vector c.

In the minimum multiplier form and wave digital form, the allpass filter is implemented as a cascade of either second-order (biquad) sections or first-order sections. When the coefficients are specified as an N-by-2 matrix, each row of the matrix specifies the coefficients of a second-order filter. The last element of the last row can be ignored based on the trailing first-order setting. When the coefficients are specified as an N-by-1 matrix, each element in the matrix specifies the coefficient of a first-order filter. The cascade of all the filter sections forms the allpass filter.

In the lattice form, the coefficients are specified as a vector.

These structures are computationally more economical and structurally more stable compared to the generic IIR filters, such as df1, df1t, df2, df2t. For all structures, the allpass filter can be a single-section or a multiple-section (cascaded) filter. The different sections can have different orders, but they are all implemented according to the same structure.

## References

[1] Regalia, Philip A. and Mitra Sanjit K. and Vaidyanathan, P. P. (1988) “The Digital All-Pass Filter: AVersatile Signal Processing Building Block.” Proceedings of the IEEE, Vol. 76, No. 1, 1988, pp. 19–37

[2] M. Lutovac, D. Tosic, B. Evans, Filter Design for Signal Processing Using MATLAB and Mathematica. Upper Saddle River, NJ: Prentice Hall, 2001.

## Version History

Introduced in R2013a