mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-30 15:39:27 +02:00
Remove GetLink(ed) in Normalize effect...
... It's much simpler and should be easy to generalize, but what would be appropriate messages?
This commit is contained in:
parent
f276373f3c
commit
4c75175e41
@ -219,10 +219,6 @@ bool EffectNormalize::Process()
|
|||||||
//Iterate over each track
|
//Iterate over each track
|
||||||
this->CopyInputTracks(); // Set up mOutputTracks.
|
this->CopyInputTracks(); // Set up mOutputTracks.
|
||||||
bool bGoodResult = true;
|
bool bGoodResult = true;
|
||||||
SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks.get());
|
|
||||||
WaveTrack *track = (WaveTrack *) iter.First();
|
|
||||||
WaveTrack *prevTrack;
|
|
||||||
prevTrack = track;
|
|
||||||
double progress = 0;
|
double progress = 0;
|
||||||
wxString topMsg;
|
wxString topMsg;
|
||||||
if(mDC && mGain)
|
if(mDC && mGain)
|
||||||
@ -234,8 +230,10 @@ bool EffectNormalize::Process()
|
|||||||
else if(!mDC && !mGain)
|
else if(!mDC && !mGain)
|
||||||
topMsg = _("Not doing anything...\n"); // shouldn't get here
|
topMsg = _("Not doing anything...\n"); // shouldn't get here
|
||||||
|
|
||||||
while (track) {
|
for ( auto track : mOutputTracks->Selected< WaveTrack >()
|
||||||
|
+ ( mStereoInd ? &Track::Any : &Track::IsLeader ) ) {
|
||||||
//Get start and end times from track
|
//Get start and end times from track
|
||||||
|
// PRL: No accounting for multiple channels?
|
||||||
double trackStart = track->GetStartTime();
|
double trackStart = track->GetStartTime();
|
||||||
double trackEnd = track->GetEndTime();
|
double trackEnd = track->GetEndTime();
|
||||||
|
|
||||||
@ -244,121 +242,106 @@ bool EffectNormalize::Process()
|
|||||||
mCurT0 = mT0 < trackStart? trackStart: mT0;
|
mCurT0 = mT0 < trackStart? trackStart: mT0;
|
||||||
mCurT1 = mT1 > trackEnd? trackEnd: mT1;
|
mCurT1 = mT1 > trackEnd? trackEnd: mT1;
|
||||||
|
|
||||||
|
auto range = mStereoInd
|
||||||
|
? TrackList::SingletonRange(track)
|
||||||
|
: TrackList::Channels(track);
|
||||||
|
|
||||||
// Process only if the right marker is to the right of the left marker
|
// Process only if the right marker is to the right of the left marker
|
||||||
if (mCurT1 > mCurT0) {
|
if (mCurT1 > mCurT0) {
|
||||||
wxString msg;
|
wxString trackName = track->GetName();
|
||||||
auto trackName = track->GetName();
|
|
||||||
|
|
||||||
if(!track->GetLinked() || mStereoInd)
|
float extent;
|
||||||
msg =
|
#ifdef EXPERIMENTAL_R128_NORM
|
||||||
topMsg + wxString::Format( _("Analyzing: %s"), trackName );
|
if (mUseLoudness)
|
||||||
|
// Loudness: use sum of both tracks.
|
||||||
|
// As a result, stereo tracks appear about 3 LUFS louder,
|
||||||
|
// as specified.
|
||||||
|
extent = 0;
|
||||||
else
|
else
|
||||||
msg =
|
#endif
|
||||||
topMsg + wxString::Format( _("Analyzing first track of stereo pair: %s"), trackName );
|
// Will compute a maximum
|
||||||
float offset, extent;
|
extent = std::numeric_limits<float>::lowest();
|
||||||
bGoodResult = AnalyseTrack(track, msg, progress, offset, extent);
|
std::vector<float> offsets;
|
||||||
if (!bGoodResult )
|
|
||||||
break;
|
wxString msg;
|
||||||
if(!track->GetLinked() || mStereoInd) {
|
if (range.size() == 1)
|
||||||
// mono or 'stereo tracks independently'
|
// mono or 'stereo tracks independently'
|
||||||
if( (extent > 0) && mGain )
|
msg = topMsg +
|
||||||
{
|
wxString::Format( _("Analyzing: %s"), trackName );
|
||||||
mMult = ratio / extent;
|
else
|
||||||
|
msg = topMsg +
|
||||||
|
// TODO: more-than-two-channels-message
|
||||||
|
wxString::Format( _("Analyzing first track of stereo pair: %s"), trackName);
|
||||||
|
|
||||||
|
// Analysis loop over channels collects offsets and extent
|
||||||
|
for (auto channel : range) {
|
||||||
|
float offset, extent2;
|
||||||
|
bGoodResult =
|
||||||
|
AnalyseTrack( channel, msg, progress, offset, extent2 );
|
||||||
|
if ( ! bGoodResult )
|
||||||
|
goto break2;
|
||||||
#ifdef EXPERIMENTAL_R128_NORM
|
#ifdef EXPERIMENTAL_R128_NORM
|
||||||
if(mUseLoudness) {
|
if (mUseLoudness)
|
||||||
// LUFS is defined as -0.691 dB + 10*log10(sum(channels))
|
extent += extent2;
|
||||||
mMult /= 0.8529037031;
|
|
||||||
// LUFS are related to square values so the multiplier must be the root.
|
|
||||||
mMult = sqrt(ratio / extent);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
mMult = 1.0;
|
#endif
|
||||||
|
extent = std::max( extent, extent2 );
|
||||||
msg =
|
offsets.push_back(offset);
|
||||||
topMsg + wxString::Format( _("Processing: %s"), trackName );
|
// TODO: more-than-two-channels-message
|
||||||
|
msg = topMsg +
|
||||||
if(track->GetLinked() || prevTrack->GetLinked()) // only get here if there is a linked track but we are processing independently
|
wxString::Format( _("Analyzing second track of stereo pair: %s"), trackName );
|
||||||
msg =
|
|
||||||
topMsg + wxString::Format( _("Processing stereo channels independently: %s"), trackName );
|
|
||||||
|
|
||||||
if (!ProcessOne(track, msg, progress, offset))
|
|
||||||
{
|
|
||||||
bGoodResult = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// we have a linked stereo track
|
|
||||||
// so we need to find it's min, max and offset
|
|
||||||
// as they are needed to calc the multiplier for both tracks
|
|
||||||
|
|
||||||
track = (WaveTrack *) iter.Next(); // get the next one
|
|
||||||
msg =
|
|
||||||
topMsg + wxString::Format( _("Analyzing second track of stereo pair: %s"), trackName );
|
|
||||||
|
|
||||||
float offset2, extent2;
|
|
||||||
bGoodResult = AnalyseTrack(track, msg, progress, offset2, extent2);
|
|
||||||
if ( !bGoodResult )
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
// Compute the multiplier using extent
|
||||||
|
if( (extent > 0) && mGain ) {
|
||||||
|
mMult = ratio / extent;
|
||||||
#ifdef EXPERIMENTAL_R128_NORM
|
#ifdef EXPERIMENTAL_R128_NORM
|
||||||
if (mUseLoudness) {
|
if(mUseLoudness) {
|
||||||
// Loudness: use sum of both tracks.
|
// PRL: See commit 9cbb67a for the origin of the next line,
|
||||||
// As a result, stereo tracks appear about 3 LUFS louder, as specified.
|
// which has no effect because mMult is again overwritten. What
|
||||||
extent = extent + extent2;
|
// was the intent?
|
||||||
|
|
||||||
// LUFS is defined as -0.691 dB + 10*log10(sum(channels))
|
// LUFS is defined as -0.691 dB + 10*log10(sum(channels))
|
||||||
extent *= 0.8529037031;
|
mMult /= 0.8529037031;
|
||||||
|
// LUFS are related to square values so the multiplier must be the root.
|
||||||
|
mMult = sqrt(ratio / extent);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
// Peak: use maximum of both tracks.
|
|
||||||
extent = fmax(extent, extent2);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Peak: use maximum of both tracks.
|
|
||||||
extent = fmax(extent, extent2);
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
else
|
||||||
|
mMult = 1.0;
|
||||||
|
|
||||||
if( (extent > 0) && mGain )
|
if (range.size() == 1) {
|
||||||
{
|
if (TrackList::Channels(track).size() == 1)
|
||||||
mMult = ratio / extent; // we need to use this for both linked tracks
|
// really mono
|
||||||
#ifdef EXPERIMENTAL_R128_NORM
|
msg = topMsg +
|
||||||
if(mUseLoudness) {
|
wxString::Format( _("Processing: %s"), trackName );
|
||||||
// LUFS are related to square values so the multiplier must be the root.
|
|
||||||
mMult = sqrt(mMult);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
mMult = 1.0;
|
//'stereo tracks independently'
|
||||||
|
// TODO: more-than-two-channels-message
|
||||||
|
msg = topMsg +
|
||||||
|
wxString::Format( _("Processing stereo channels independently: %s"), trackName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
msg = topMsg +
|
||||||
|
// TODO: more-than-two-channels-message
|
||||||
|
wxString::Format( _("Processing first track of stereo pair: %s"), trackName);
|
||||||
|
|
||||||
track = (WaveTrack *) iter.Prev(); // go back to the first linked one
|
// Use multiplier in the second, processing loop over channels
|
||||||
msg =
|
auto pOffset = offsets.begin();
|
||||||
topMsg + wxString::Format( _("Processing first track of stereo pair: %s"), trackName );
|
for (auto channel : range) {
|
||||||
|
if (false ==
|
||||||
if (!ProcessOne(track, msg, progress, offset))
|
(bGoodResult = ProcessOne(channel, msg, progress, *pOffset++)) )
|
||||||
{
|
goto break2;
|
||||||
bGoodResult = false;
|
// TODO: more-than-two-channels-message
|
||||||
break;
|
msg = topMsg +
|
||||||
}
|
wxString::Format( _("Processing second track of stereo pair: %s"), trackName);
|
||||||
track = (WaveTrack *) iter.Next(); // go to the second linked one
|
|
||||||
msg =
|
|
||||||
topMsg + wxString::Format( _("Processing second track of stereo pair: %s"), trackName );
|
|
||||||
|
|
||||||
if (!ProcessOne(track, msg, progress, offset2))
|
|
||||||
{
|
|
||||||
bGoodResult = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Iterate to the next track
|
|
||||||
prevTrack = track;
|
|
||||||
track = (WaveTrack *) iter.Next();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
break2:
|
||||||
|
|
||||||
this->ReplaceProcessedTracks(bGoodResult);
|
this->ReplaceProcessedTracks(bGoodResult);
|
||||||
return bGoodResult;
|
return bGoodResult;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user