# Making audio clips comparable in terms of RMS

I have a challenging question on how to normalize several audio clips so that they are comparable (similar) in RMS but without the clips clipping (having values over -1 and 1). Is there a systematic way to do this? One scaling factor must be found for all clips so that their L/R channels keep their ratio while at the same time making the different clips' RMS equal. Thanks in advance!

• yes, there's a way: normalize all to a maximum amplitude of < 1. Which means you look for the maximum amplitude $a_{max}$ in all audio clips and normalize all the clips with a factor of $\le\frac1{a_{max}}$,+ Done. Nov 26 '17 at 15:40
• This won't work because (1) I want to keep the relative differences betwen L/R channels, and (2) this won't make all clips have an equal RMS. Nov 26 '17 at 22:04

I wrote this simple Matlab function a while back, it operates on dBFS:

function y = change_rms(x, newRMS)

currentRMS = mean(20*log10(rms(x)));

d = newRMS - currentRMS;
y = x * 10^(d/20);
end


You would call a function like this with the signal whose RMS you want to change as the first argument (consecutive samples along the first dimension, channels along the second) and the new RMS value in dBFS as the second argument. After processing all signals so that they have an RMS equal to your reference RMS, you check which signal contains the highest absolute value. Then devide all signals by that value. They will then all have the same RMS (i.e. mean RMS) and their internal level ratio between channels will still be what it was before changing their RMS.

Note however that the final RMS that all signals will have after this procedure will not be equal to the reference RMS you used when calling the function. This is of course due to dividing all signals by the maximum absolute value of the entire data set after using the function. Consequently, the final RMS will be determined by the signal that contained the maximum absolute value across the entire data set.

Here is the step-by-step guide:

1. Process all your audio files with the script provided above. Use the same newRMS for all the audio files. newRMS can be an arbitrary value.

2. Find the highest absolute value in the entire set of audio files.

3. Divide all audio files by that value.

After that, all audio files will have the same RMS. All audio files will have values in the [-1 1] range.

• Thanks for this. The problem I see here is that the added RMS for both channels will surpass the desired RMS level (I may be wrong). Also, the issue at hand is to find a constant for all my audio clips so that the RMS for both L and R channels are identical across clips (because, as I said in my question, the aim to is make comparable audio clips in terms of RMS, without them exceeding amplitude (-1,1). Nov 26 '17 at 22:08
• This then becomes a question of how you want to determine the RMS of a 2-channel signal. My solution just takes the mean of the 2 channels. This might lead to one of the channels having a higher RMS, one having a lower RMS than the reference RMS. Their mean however will be equal to the reference RMS, and each 2-channel signal will keep its internal level ratio between channels. By deviding all signals by the maximum absolute value of the entire data set, no signal will have values exceeding the [-1 1] range. Nov 27 '17 at 17:59
• I thought of this but it wouldn't work. Each channel needs to be divided by sqrt(RMS(left)^2+RMS(right)^2) x factor, so that the root power of each channel is identical in all clips, with the factor making them in the range of -1,1. Dec 1 '17 at 8:13
• @EmmanuelGoldstein Hm, I'm starting to doubt that I've fully understood what it is you want to achieve. You stated multiple times that you want signals to have a) the same RMS, b) the same ratio between their left and right channels and c) values within the [-1 1] range. Now you say "it wouldn't work". Can you please explain in which way my proposed solution would be different from the one you seek? Dec 1 '17 at 13:03
• I want to make all clips among themselves comparable (have the same RMS, not just keeping their L/R ratio but also the RMS level is the same as the other clips). Dec 19 '17 at 11:50