Weighted frequency response filter
Audio Toolbox / Filters
The Weighting Filter block performs frequency-weighted filtering independently across each input channel.
Port_1 — Input signal
matrix | 1-D vector
Matrix input –– Each column of the input is treated as an independent channel.
1-D vector input –– The input is treated as a single channel.
Port_1 — Output signal
The Weighting Filter block outputs a signal with the same data type as the input signal. The size of the output depends on the size of the input:
Matrix input –– The block outputs a matrix the same size and data type as the input signal.
1-D vector input –– The block outputs an N-by-1 matrix (column vector), where N is the number of elements in the 1-D vector.
If a parameter is listed as tunable, then you can change its value during simulation.
Inherit sample rate from input — Specify source of input sample rate
off (default) |
When you select this parameter, the block inherits its sample rate from the input signal. When you clear this parameter, you specify the sample rate in Input sample rate (Hz).
Input sample rate (Hz) — Sample rate of input
44100 (default) |
To enable this parameter, clear the Inherit sample rate from input parameter.
Simulate using — Specify type of simulation to run
Code generation (default) |
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 faster than
Interpreted execution–– Simulate model using the MATLAB® interpreter. This option shortens startup time but has a slower simulation speed compared to
Code generation. In this mode, you can debug the source code of the block.
Mask for attenuation limits — Creates a mask for filter response visualization
No mask (default) |
Class 1 |
The mask attenuation limits are defined in the IEC 61672-1:2002 standard.
If the mask is green, the design is compliant.
If the mask is red, the design breaks compliance.
To enable this parameter, set Weighting method to
Visualize filter response — Open plot to visualize magnitude response and compliance mask
A 2048-point FFT is used to calculate the magnitude response.
Variable name — Variable name of exported filter
myFilt (default) | valid variable name
Name of the variable in the base workspace to contain the filter when it is exported. The name must be a valid MATLAB variable name.
Overwrite variable if it already exists — Overwrite variable if it already exists
on (default) |
When you select this parameter, exporting the filter overwrites the
variable specified by the Variable name parameter if it
already exists in the base workspace. If you do not select this parameter
and the specified variable already exists in the workspace, exporting the
filter creates a new variable with an underscore and a number appended to
the variable name. For example, if the variable name is
var and it already exists, the exported variable will
Export filter to workspace — Export filter to workspace
Export the filter to the base workspace in the variable specified by the Variable name parameter.
You cannot export the filter if you have enabled the Inherit sample rate from input parameter and the model is not running.
The A-curve is a wide bandpass filter centered at 2.5 kHz, with approximately 20 dB attenuation at 100 Hz and 10 dB attenuation at 20 kHz. A-weighted SPL measurements of noise level are increasingly found in sales literature for domestic appliances. In most countries, the use of A-weighting is mandated for the protection of workers against noise-induced deafness. The ISO and ICOA standards mandate A-weighting for all civil aircraft noise measurements.
ANSI S1.42.2001 defines the weighting curve by specifying analog poles and zeros. Audio Toolbox™ converts the specified poles and zeros to the digital domain using a bilinear transform:
The C-curve is "flat," but with limited bandwidth: It has –3 dB corners at 31.5 Hz and 8 kHz. C-curves are used in sound level meters for sounds that are louder than sounds intended for A-weighting filters.
ANSI S1.42.2001 defines the weighting curve by specifying analog poles and zeros. Audio Toolbox converts the specified poles and zeros to the digital domain using a bilinear transform:
The K-weighting filter is used for loudness normalization in broadcast. It is composed of two stages of filtering: a first stage shelving filter and a second stage highpass filter.
The ITU-R BS.1770-4  standard defines this curve.
Assume a second-order filter.
The table shows the coefficients for the filters.
|First Stage Shelving Coefficients
|Second Stage Highpass Coefficients
The coefficients presented by ITU-R BS.1770-4 are defined for 48 kHz. These coefficients are recomputed for nonstandard sample rates using the algorithm described in .
 Acoustical Society of America. Design Response of Weighting Networks for Acoustical Measurements. ANSI S1.42-2001. New York, NY: American National Standards Institute, 2001.
 International Electrotechnical Commission. Electroacoustics Sound Level Meters Part 1: Specifications. First Edition. IEC 61672-1. 2002-2005.
 International Telecommunication Union. Algorithms to measure audio programme loudness and true-peak audio level. ITU-R BS.1770-4. 2015.
 Mansbridge, Stuart, Saoirse Finn, and Joshua D. Reiss. "Implementation and Evaluation of Autonomous Multi-track Fader Control." Paper presented at the 132nd Audio Engineering Society Convention, Budapest, Hungary, 2012.
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Introduced in R2016b