12
$\begingroup$

I want to calculate the loudness of a given signal and I've come across this thread. I'm slightly confused about the A-Weighting aspect of it. I can't post images, but I think this site has the formula I need. (Wa = 10log...)

What I don't understand is how to actually use it in my program. If the f stands for frequency, then presumably I can hardcode the values since they will remain constant. If that is the case, how do I apply Wa to my sample values and what values do I use? Do I calculate the power spectrum to get WINDOW_SIZE/2 values and multiply each value in the frequency band with relevant precalculated Wa value or is that the wrong way of doing it? Thank you in advance.

$\endgroup$

1 Answer 1

8
$\begingroup$

Yes, you could hardcode the values, do an FFT of your signal, and multiply by the hardcoded values, then get the amplitude in the frequency domain from Parseval's theorem (example).

You could also implement a digital filter and do it in the time domain. Here's Matlab code and my translation to Python.

Note that the bilinear transform causes the digital filter to roll-off more quickly than the analog filter, introducing measurement errors at common sample rates. A simple fix is to upsample the data first, so the discrepancy is minimized. Other filter design approaches here: http://dsp.stackexchange.com/q/36077/29

$\endgroup$
2
  • $\begingroup$ Thanks, I'm understanding it a bit better. In your Parseval example, is rms_flat the RMS equation (SQRT(x1^2 + x2^2...xn^2/n)) and what's the difference between rms_flat of the signal and rms_flat of the FFT? $\endgroup$
    – TryNCode
    Commented Oct 13, 2011 at 14:45
  • $\begingroup$ @ExpAns: Yes, rms_flat() is just sqrt(mean(absolute(a)**2)). The /n is on the outside. The RMS value of the signal and FFT are the same except for a scaling factor. $\endgroup$
    – endolith
    Commented Oct 13, 2011 at 15:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.