Fix too low loudness normalization levels.

LUFS are defined as the power of the signal, not as the root mean square.
Accidential use of the RMS caused incorrect normalization to only half
of the LUFS value.
This commit is contained in:
Max Maisel 2018-07-27 16:50:27 +02:00
parent 487769d2b6
commit 9cbb67acba
1 changed files with 16 additions and 5 deletions

View File

@ -236,14 +236,19 @@ bool EffectNormalize::Process()
if(!track->GetLinked() || mStereoInd) {
// mono or 'stereo tracks independently'
if( (extent > 0) && mGain )
{
mMult = ratio / extent;
if(mUseLoudness)
{
// LUFS is defined as -0.691 dB + 10*log10(sum(channels))
mMult /= 0.8529037031;
// LUFS are related to square values so the multiplier must be the root.
mMult = sqrt(ratio / extent);
}
}
else
mMult = 1.0;
if(mUseLoudness)
// LUFS is defined as -0.691 dB + 10*log10(sum(channels))
extent *= 0.8529037031;
msg =
topMsg + wxString::Format( _("Processing: %s"), trackName );
if(track->GetLinked() || prevTrack->GetLinked()) // only get here if there is a linked track but we are processing independently
@ -284,7 +289,12 @@ bool EffectNormalize::Process()
extent = fmax(extent, extent2);
if( (extent > 0) && mGain )
{
mMult = ratio / extent; // we need to use this for both linked tracks
if(mUseLoudness)
// LUFS are related to square values so the multiplier must be the root.
mMult = sqrt(mMult);
}
else
mMult = 1.0;
track = (WaveTrack *) iter.Prev(); // go back to the first linked one
@ -422,7 +432,8 @@ bool EffectNormalize::AnalyseTrack(const WaveTrack * track, const wxString &msg,
offset = 0.0;
}
extent = sqrt(mSqSum / mCount.as_double());
// EBU R128: z_i = mean square without root
extent = mSqSum / mCount.as_double();
}
else
{