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.
This commit is contained in:
v.audacity 2013-12-17 03:07:26 +00:00
parent d862db8b16
commit 477ab4245e
2 changed files with 14 additions and 12 deletions

View File

@ -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; j<windowSize; j++)
datawindow[j] = 0;
bResult |= RemoveClicks(windowSize, datawindow);
mbDidSomething |= RemoveClicks(windowSize, datawindow);
for(j=0; j<wcopy; j++)
buffer[i+j] = datawindow[j];
}
if (bResult) // RemoveClicks() actually did something.
if (mbDidSomething) // RemoveClicks() actually did something.
track->Set((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;
}

View File

@ -73,6 +73,7 @@ private:
Envelope *mEnvelope;
bool mbDidSomething; // This effect usually does nothing on real-world data.
int windowSize;
int mThresholdLevel;
int mClickWidth;