Audio Weighting Filters
This example shows how to obtain A-weighting and C-weighting filters the
weightingFilter System object in the Audio Toolbox™.
In many applications involving acoustic measurements, the final sensor is the human ear. For this reason, acoustic measurements usually attempt to describe the subjective perception of a sound by this organ. Instrumentation devices are built to provide a linear response, but the ear is a nonlinear sensor. Special filters, known as weighting filters, are used to account for the nonlinearities.
A and C Weighting (ANSI® S1.42 Standard)
You can design A and C weighting filters that follow the ANSI S1.42  and IEC 61672-1  standards using
weightingFilter System object. An A-weighting filter is a bandpass filter designed to simulate the perceived loudness of low-level tones. An A-weighting filter progressively de-emphasizes frequencies below 500 Hz. A C-weighting filter removes sounds outside the audio range of 20 Hz to 20 kHz and simulates the loudness perception of high-level tones. The following code designs an IIR filter for A-weighting with a sampling rate of 48 kHz.
AWeighting = weightingFilter('A-weighting',48000)
AWeighting = weightingFilter with properties: Method: 'A-weighting' SampleRate: 48000
A and C-weighting filter designs are based on direct implementation of the filter's transfer function based on poles and zeros specified in the ANSI S1.42 standard.
The IEC 61672-1 standard requires that the filter magnitudes fall within a specified tolerance mask. The standard defines two masks, one with stricter tolerance values than the other. A filter that meets the tolerance specifications of the stricter mask is referred to as a Class 1 filter. A filter that meets the specifications of the less strict mask is referred to as a Class 2 filter. You can view the magnitude response of the filter along with a mask corresponding to Class 1 or Class 2 specifications by calling the
visualize method on the object. Note that the choice of the Class value will not affect the filter design itself but it will be used to render the correct tolerance mask in the visualization plot.
The A- and C-weighting standards specify tolerance magnitude values for up to 20 kHz. In the following example we use a sample rate of 28 kHz and design a C-weighting filter. Even though the Nyquist interval for this sample rate is below the maximum specified 20 kHz frequency, the design still meets the Class 2 tolerances as shown by the green mask around the magnitude response plot. The design, however, does not meet Class 1 tolerances due to the small sample rate value and you will see the mask around the magnitude response plot turn red.
CWeighting = weightingFilter('C-weighting',28000)
CWeighting = weightingFilter with properties: Method: 'C-weighting' SampleRate: 28000
visualize(CWeighting,'class 2') visualize(CWeighting,'class 1')
 "Design Response of Weighting Networks for Acoustical Measurements." American National Standard, ANSI S1.42–2001.
 "Electroacoustics Sound Level Meters Part 1: Specifications." IEC 61672-1, First Edition, 2002–05.