# A-weighted Digital Filter for 1/3rd Octave Band Analysis

I want to do a 1/3rd Octave band analysis on a noise signal. But the sound pressure levels should be in dB(A), i.e., and it should be A-weighted. For this, I am using the A-weight function from this module.

From this link, what I understood is that the function A-weight takes the input as a signal(in Pressure(Pa)), and sampling frequency and gives the output as another signal(in Pressure(Pa)). If This output signal converted into pressure level should provide the A-weighted pressure levels.

Now, I use the A filtered sound pressure signal as my starting point and use the Butterworth filter to convert it into 1/3rd Octave Bands. Reference for this - https://stackoverflow.com/questions/56791652/1-3-octave-from-audio-file-with-python

The 1/3rd filter is as -

The output plot I get for the original signal(not weighted) is - This is the correct output.

The output plot after applying the A-weights is: This plot is not correct. The weights for each band should be:

Reference of this table

The method I am using is not giving correct results in the lower bands, and I cannot figure why. I don't want to use the weights directly as I want a generally weighted signal for purposes other than just 1/3rd Octave Band Analysis too. I am a beginner in DSP so that any help will be much appreciated. Feel free to suggest even alternative approaches for the A-weighting filter that can be executed in Python. Thank you

• Did you plot your 1/3rd octave filter responses? – jojek Jul 1 at 13:47
• Yes. And that seems to be fine because the 1/3rd Octave Band bar graph is correct. I am updating the answer with that. – Rohan Yuttham Jul 1 at 14:03
• Have you tried by processing involved LP and HP filters separately in series. When A-Weighting filter is combined to one filter from those one LPF and 3 HPF and then to sos stages, it introduces distortion at low frequency area (how much, depends on implementation and sample rate)... I would try by processing each filter stage separately ... in 1st order filter implementation it would be ; LPF1...LPF1...HPF1...HPF1...HPF2...HPF3 . – Juha P Jul 1 at 18:15
• How many samples are you feeding in to it before you check the output? I would think the low frequency bands have a pretty long time constant, so the data might be a bit wonky if you don’t give it enough time to settle. – Dan Szabo Jul 2 at 1:56
• Hi @DanSzabo . I am feeding close to 1Lac data points. Sampling rate is 33kHz – Rohan Yuttham Jul 2 at 9:45

Based in my comment, here are quite accurate coefficients for A-Weighting filter to be used with 33kHz (33000Hz) sampling only:

b = [0.759941332414235 -1.931718891800229 0.5144488202077094 2.040523943539552 -1.283344336756084 -0.5073918947145036 0.3880093863750892 0.03272320276137633 -0.01319156202714533]
a = [1 -2.840785425332851 1.688214038430988 1.889562806030876 -2.289753885038417 0.2591762588766977 0.4062228100411928 -0.122514417900642 0.009877893153322726]


Second order sections:

[1 -1.999817001037482 0.999817017779804 1 -0.3278552435476524 0.02858846174272314]
[1 -2.000182998962519 1.000183015708817 1 -1.992171272584749 0.9921865948281223]
[1 1.403903298176578 0.4701139795164294 1 1.327684185781194 0.4091629729586278]
[1 0.05416509551979914 -0.03692436132666149 1 -1.848443094981644 0.8511063988059516]


(0dB @ 1kHz and g = 0.759941332414235)