1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-06-18 09:00:07 +02:00

Better fix for bug 604, not losing the repaired track.

This commit is contained in:
martynshaw99 2013-01-12 22:17:41 +00:00
parent aac65490f9
commit 2dca704213

View File

@ -69,51 +69,51 @@ bool EffectRepair::Process()
double repair_t1 = mT1; double repair_t1 = mT1;
repair_t0 = (repair_t0 < trackStart? trackStart: repair_t0); repair_t0 = (repair_t0 < trackStart? trackStart: repair_t0);
repair_t1 = (repair_t1 > trackEnd? trackEnd: repair_t1); repair_t1 = (repair_t1 > trackEnd? trackEnd: repair_t1);
double rate = track->GetRate(); if (repair_t0 < repair_t1) { // selection is within track audio
double repair_deltat = repair_t1 - repair_t0; double rate = track->GetRate();
double repair_deltat = repair_t1 - repair_t0;
double spacing = repair_deltat * 2; double spacing = repair_deltat * 2;
if (spacing < 128. / rate) if (spacing < 128. / rate)
spacing = 128. / rate; spacing = 128. / rate;
double t0 = repair_t0 - spacing; double t0 = repair_t0 - spacing;
double t1 = repair_t1 + spacing; double t1 = repair_t1 + spacing;
t0 = t0 < trackStart? trackStart: t0; t0 = t0 < trackStart? trackStart: t0;
t1 = t1 > trackEnd? trackEnd: t1; t1 = t1 > trackEnd? trackEnd: t1;
repair_t0 = (repair_t0 < t0? t0: repair_t0); repair_t0 = (repair_t0 < t0? t0: repair_t0);
repair_t1 = (repair_t1 > t1? t1: repair_t1); repair_t1 = (repair_t1 > t1? t1: repair_t1);
sampleCount s0 = track->TimeToLongSamples(t0); sampleCount s0 = track->TimeToLongSamples(t0);
sampleCount repair0 = track->TimeToLongSamples(repair_t0); sampleCount repair0 = track->TimeToLongSamples(repair_t0);
sampleCount repair1 = track->TimeToLongSamples(repair_t1); sampleCount repair1 = track->TimeToLongSamples(repair_t1);
sampleCount s1 = track->TimeToLongSamples(t1); sampleCount s1 = track->TimeToLongSamples(t1);
sampleCount repairStart = (sampleCount)(repair0 - s0); sampleCount repairStart = (sampleCount)(repair0 - s0);
sampleCount repairLen = (sampleCount)(repair1 - repair0); sampleCount repairLen = (sampleCount)(repair1 - repair0);
sampleCount len = (sampleCount)(s1 - s0); sampleCount len = (sampleCount)(s1 - s0);
if (len < 0)
break; // FIX-ME: This failsafes bug 604, but does not account for why it actually happens.
if (repairLen > 128) { if (repairLen > 128) {
::wxMessageBox(_("The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair.")); ::wxMessageBox(_("The Repair effect is intended to be used on very short sections of damaged audio (up to 128 samples).\n\nZoom in and select a tiny fraction of a second to repair."));
bGoodResult = false; bGoodResult = false;
break; break;
} }
if (s0 == repair0 && s1 == repair1) { if (s0 == repair0 && s1 == repair1) {
::wxMessageBox(_("Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs.")); ::wxMessageBox(_("Repair works by using audio data outside the selection region.\n\nPlease select a region that has audio touching at least one side of it.\n\nThe more surrounding audio, the better it performs."));
/// The Repair effect needs some data to go on.\n\nPlease select an area to repair with some audio on at least one side (the more the better).")); /// The Repair effect needs some data to go on.\n\nPlease select an area to repair with some audio on at least one side (the more the better)."));
bGoodResult = false; bGoodResult = false;
break; break;
} }
if (!ProcessOne(count, track, if (!ProcessOne(count, track,
s0, len, repairStart, repairLen)) { s0, len, repairStart, repairLen)) {
bGoodResult = false; bGoodResult = false;
break; break;
}
} }
track = (WaveTrack *) iter.Next(); track = (WaveTrack *) iter.Next();