From 477ab4245e51de982f00ceb68d4ce3f5382bc26a Mon Sep 17 00:00:00 2001 From: "v.audacity" Date: Tue, 17 Dec 2013 03:07:26 +0000 Subject: [PATCH] Complete the alerts for the known misfires of this effect. Most cases, it does nothing. Previous commit had problem because TrackProgress() can report false for user cancellation, not actual failure, so I separated out mbDidSomething, to check whether it actually made any changes, for all tracks. --- src/effects/ClickRemoval.cpp | 25 +++++++++++++------------ src/effects/ClickRemoval.h | 1 + 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/effects/ClickRemoval.cpp b/src/effects/ClickRemoval.cpp index 4efea2a9b..4bbf2908c 100644 --- a/src/effects/ClickRemoval.cpp +++ b/src/effects/ClickRemoval.cpp @@ -124,6 +124,7 @@ bool EffectClickRemoval::Process() { this->CopyInputTracks(); // Set up mOutputTracks. bool bGoodResult = true; + mbDidSomething = false; SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks); WaveTrack *track = (WaveTrack *) iter.First(); @@ -149,8 +150,14 @@ bool EffectClickRemoval::Process() track = (WaveTrack *) iter.Next(); count++; } - this->ReplaceProcessedTracks(bGoodResult); - return bGoodResult; + if (bGoodResult && !mbDidSomething) // Processing successful, but ineffective. + wxMessageBox( + wxString::Format(_("Algorithm not effective on these data. Nothing changed.")), + this->GetEffectName(), + wxOK | wxICON_ERROR); + + this->ReplaceProcessedTracks(bGoodResult && mbDidSomething); + return bGoodResult && mbDidSomething; } bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount start, sampleCount len) @@ -170,7 +177,7 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st if (idealBlockLen % windowSize != 0) idealBlockLen += (windowSize - (idealBlockLen % windowSize)); - bool bResult = false; // This effect usually does nothing. + bool bResult = true; sampleCount s = 0; float *buffer = new float[idealBlockLen]; float *datawindow = new float[windowSize]; @@ -194,19 +201,19 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st for(j=wcopy; jSet((samplePtr) buffer, floatSample, start + s, block); s += block; if (TrackProgress(count, s / (double) len)) { - // Not necessarily a failure, as might be eProgressCancelled. // bResult = false; + bResult = false; break; } } @@ -214,12 +221,6 @@ bool EffectClickRemoval::ProcessOne(int count, WaveTrack * track, sampleCount st delete[] buffer; delete[] datawindow; - if (!bResult) - wxMessageBox( - wxString::Format(_("Algorithm not effective on these data. Nothing changed.")), - this->GetEffectName(), - wxOK | wxICON_ERROR); - return bResult; } diff --git a/src/effects/ClickRemoval.h b/src/effects/ClickRemoval.h index 20ea46f33..551d88223 100644 --- a/src/effects/ClickRemoval.h +++ b/src/effects/ClickRemoval.h @@ -73,6 +73,7 @@ private: Envelope *mEnvelope; + bool mbDidSomething; // This effect usually does nothing on real-world data. int windowSize; int mThresholdLevel; int mClickWidth;