Alex Rivera | Logout

How can I determine how loud a WAV file will sound?

Asked 2009-06-12T02:24:47.453
18

I have a bunch of different audio recordings in WAV format (all different instruments and pitches), and I want to "normalize" them so that they all sound approximately the same volume when played.

I've tried measuring the average sample magnitude (the sum of all absolute values divided by the number of samples), but normalizing by this measurement doesn't work very well. I think this method isn't working because it doesn't take into account the frequency of the sounds, and I know that higher-frequency recordings sound louder than lower-frequency sounds of the same amplitude.

Does anyone know a good method for measuring the loudness of a sound?

Edit
Report

2 Answers

16

Root Mean Square is often used to estimate the loudness of sound files. This is because a sound that is very loud might not be perceived that way if it is very short. Also remember that power increases exponentially with the square of amplitude.

The audio geeks at Hydrogen Audio know a ton about this stuff...check out their free Replay Gain software. You may not need to do any programming at all.

EDIT: Included comment feedback on power vs. amplitude.

answered 2009-06-12T02:30:09.720
2

To reiterate what some other people have said, use RMS value to estimate the "loudness" of a passage of sound.

But, if you're dealing with impulsive sounds like plucking or drum hits, you'd want to do a sliding RMS value and pick out only the peak RMS value. Measure 100 ms of the sound, slide the window, measure again, etc. and then normalize according to the largest value you find.

Definitely remove any DC value before doing the RMS, and A-weighting will make it more like how we hear. Here's code for A-weighting in MATLAB/Octave and Python.

answered 2010-03-02T15:13:28.700

Your Answer