From a6d9f24804fd6c58ecc092c3b391c78525cc0fae Mon Sep 17 00:00:00 2001 From: mchinen Date: Wed, 23 May 2012 23:02:25 +0000 Subject: [PATCH] Fix Bug 489 (P2) - Read Directly uncompressed audio produces incorrect Normalize in Chains. Wait until OD is finished before starting analysis. --- src/effects/Normalize.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/src/effects/Normalize.cpp b/src/effects/Normalize.cpp index 2b2fd77a1..1c0da9cac 100644 --- a/src/effects/Normalize.cpp +++ b/src/effects/Normalize.cpp @@ -261,17 +261,27 @@ bool EffectNormalize::Process() void EffectNormalize::AnalyseTrack(WaveTrack * track, wxString msg) { - if(mGain) - track->GetMinMax(&mMin, &mMax, mCurT0, mCurT1); // set mMin, mMax. No progress bar here as it's fast. - else - mMin = -1.0, mMax = 1.0; // sensible defaults? - if(mDC) { - AnalyseDC(track, msg); // sets mOffset - mMin += mOffset; - mMax += mOffset; - } - else - mOffset = 0.0; + if(mGain) { + // Since we need complete summary data, we need to block until the OD tasks are done for this track + // TODO: should we restrict the flags to just the relevant block files (for selections) + while (track->GetODFlags()) { + // update the gui + mProgress->Update(0, wxT("Waiting for waveform to finish computing...")); + wxMilliSleep(100); + } + + track->GetMinMax(&mMin, &mMax, mCurT0, mCurT1); // set mMin, mMax. No progress bar here as it's fast. + } else { + mMin = -1.0, mMax = 1.0; // sensible defaults? + } + + if(mDC) { + AnalyseDC(track, msg); // sets mOffset + mMin += mOffset; + mMax += mOffset; + } else { + mOffset = 0.0; + } } //AnalyseDC() takes a track, transforms it to bunch of buffer-blocks,