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!
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:
Process all your audio files with the script provided above. Use the same
newRMSfor all the audio files.
newRMScan be an arbitrary value.
Find the highest absolute value in the entire set of audio files.
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.