2
$\begingroup$

I like to listen to instrumental music while trying to sleep. So, I've selected 20 songs from my music archive to listen to when I go to bed. The problem is that the loudness levels of the songs differ. Therefore, I have difficulty listening to some songs while the others disturb me for a specific volume level. I want to normalize the loudness of them and set it to a common value programmatically (e.g. using MATLAB).

I thought the following:

n <- number of songs
a <- an array of values initially 0 (length n)
for i = 1 to n
    partition song i into overlapping windows (e.g. window length of 1024, shift of 512)
    let s_j's involve the values in j'th window where j = 1 to #windows
    a(i) <- max_j sum(abs(s_j))
end for
m <- mean(a)
for i = 1 to n
    rescale all the amplitude values of song i by m/a(i)
end for

What should I take into consideration to normalize the songs' loudness levels? What strategy do you recommend? I can write the MATLAB code easily from a pseudocode.

$\endgroup$
  • 3
    $\begingroup$ You'll probably need a psychoacoustic measure of loudness rather than amplitude, e.g. en.wikipedia.org/wiki/Sones $\endgroup$ – datageist May 25 '12 at 7:48
  • 2
    $\begingroup$ You don't need to roll your own program in MATLAB to do this in 2012; you can use off-the-shelf software $\endgroup$ – Emre May 25 '12 at 7:55
  • $\begingroup$ Thanks Emre, that works great. You saved me a lot of time. $\endgroup$ – petrichor May 25 '12 at 8:46
  • $\begingroup$ @datageist I wasn't aware of that. Thanks! $\endgroup$ – petrichor May 25 '12 at 8:47
  • $\begingroup$ I'll add an answer so we can close this question. $\endgroup$ – Emre May 25 '12 at 17:15
2
$\begingroup$

You can spare yourself time by using off-the-shelf software such as http://mp3gain.sourceforge.net/

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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