Main Content

Variable Slope Filter Design

Design tunable lowpass or highpass filter coefficients

Since R2024a

Libraries:
Audio Toolbox / Filters

Description

The Variable Slope Filter Design block designs a lowpass or highpass filter with the specified slope and cutoff frequency. The block outputs filter coefficients of cascaded second-order section (SOS) filters, which you can use with the Second-Order Section Filter block to filter audio signals. You can tune the filter parameters during simulation.

Examples

expand all

Use the Variable Slope Filter Design block to design a lowpass filter and pass the coefficients to a Second-Order Section Filter block to filter a signal of random noise. Tune the filter parameters using the dashboard controls and see how the spectrum of the filtered signal changes.

Ports

Input

expand all

Use this port to specify the value of the Filter slope parameter.

Dependencies

To enable this port, select the Specify slope from input port parameter.

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

Use this port to specify the value of the Normalized cutoff frequency parameter.

Dependencies

To enable this port, select the Specify normalized cutoff frequency from input port parameter.

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

Use this port to specify the value of the Filter type parameter; 0 corresponds to a lowpass filter and 1 corresponds to a highpass filter.

Dependencies

To enable this port, select the Specify filter type from input port parameter.

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

Output

expand all

Numerator filter coefficients, returned as an N-by-3 matrix. N is the number of filter sections and depends on the Maximum filter slope parameter. If Filter slope is less than Maximum filter slope, then the block sets the unused sections to pass-through sections.

Dependencies

Data Types: single | double

Denominator filter coefficients, returned as an N-by-3 matrix. N is the number of filter sections and depends on the Maximum filter slope parameter. A steeper slope requires more filter sections. If Filter slope is less than Maximum filter slope, then the block sets the unused sections to pass-through sections.

Dependencies

Data Types: single | double

Parameters

expand all

To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.

Select this parameter to gradually change a filter parameter to the new value when tuning it. If you clear this parameter, the tuned parameter immediately switches to the new value. Specify the level of smoothing with the Smoothing factor parameter.

Smoothing factor for tuned parameters, specified as a scalar in the range [0,1). As the smoothing factor approaches 1, a tuned parameter changes more gradually to the new value. A smoothing factor of 0 is equivalent to no smoothing.

For more information about smoothing, see Smoothing.

Tunable: Yes

Dependencies

To enable this parameter, select the Smooth tuned filter parameters parameter.

Maximum filter slope in dB/octave, specified as a scalar in the range [0,48]. The Filter slope parameter cannot exceed this value.

When you select this parameter, an additional input port, S, is added to the block.

Filter slope in dB/octave, specified as a scalar in the range [0,48]. The block rounds the slope value to the nearest multiple of 6.

Tunable: Yes

Dependencies

  • To enable this parameter, clear the Specify slope from input port parameter.

  • The value of this parameter cannot exceed the value of the Maximum filter slope parameter.

When you select this parameter, an additional input port, Fc, is added to the block.

Normalized cutoff frequency of the filter, specified as a scalar in the range [0,1] where 1 corresponds to the Nyquist frequency.

Tunable: Yes

Dependencies

To enable this parameter, clear the Specify normalized cutoff frequency from input port parameter.

When you select this parameter, an additional input port, T, is added to the block.

Type of filter, specified as lowpass for a lowpass filter or highpass for a highpass filter.

Data type of output coefficients, specified as double or single.

Sample time of the block, in seconds, specified as -1 or a positive scalar. Setting this parameter to -1 means Simulink determines the sample time automatically for you. You can set this parameter to enable the design block to run at a slower rate than the filtering block.

  • Interpreted execution –– Simulate model using the MATLAB® interpreter. This option shortens startup time but has a slower simulation speed than Code generation. In this mode, you can debug the source code of the block.

  • Code generation –– Simulate model using generated C code. The first time you run a simulation, Simulink generates C code for the block. The C code is reused for subsequent simulations, as long as the model does not change. This option requires additional startup time, but the speed of the subsequent simulations is comparable to Interpreted execution.

Block Characteristics

Data Types

double | single

Direct Feedthrough

no

Multidimensional Signals

no

Variable-Size Signals

no

Zero-Crossing Detection

no

Algorithms

expand all

References

[1] Orfanidis, Sophocles J. "High-Order Digital Parametric Equalizer Design." Journal of the Audio Engineering Society. Vol. 53, November 2005, pp. 1026–1046.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.

Version History

Introduced in R2024a