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;
repair_t0 = (repair_t0 < trackStart? trackStart: repair_t0);
repair_t1 = (repair_t1 > trackEnd? trackEnd: repair_t1);
double rate = track->GetRate();
double repair_deltat = repair_t1 - repair_t0;
if (repair_t0 < repair_t1) { // selection is within track audio
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)
spacing = 128. / rate;
if (spacing < 128. / rate)
spacing = 128. / rate;
double t0 = repair_t0 - spacing;
double t1 = repair_t1 + spacing;
t0 = t0 < trackStart? trackStart: t0;
t1 = t1 > trackEnd? trackEnd: t1;
double t0 = repair_t0 - spacing;
double t1 = repair_t1 + spacing;
t0 = t0 < trackStart? trackStart: t0;
t1 = t1 > trackEnd? trackEnd: t1;
repair_t0 = (repair_t0 < t0? t0: repair_t0);
repair_t1 = (repair_t1 > t1? t1: repair_t1);
repair_t0 = (repair_t0 < t0? t0: repair_t0);
repair_t1 = (repair_t1 > t1? t1: repair_t1);
sampleCount s0 = track->TimeToLongSamples(t0);
sampleCount repair0 = track->TimeToLongSamples(repair_t0);
sampleCount repair1 = track->TimeToLongSamples(repair_t1);
sampleCount s1 = track->TimeToLongSamples(t1);
sampleCount s0 = track->TimeToLongSamples(t0);
sampleCount repair0 = track->TimeToLongSamples(repair_t0);
sampleCount repair1 = track->TimeToLongSamples(repair_t1);
sampleCount s1 = track->TimeToLongSamples(t1);
sampleCount repairStart = (sampleCount)(repair0 - s0);
sampleCount repairLen = (sampleCount)(repair1 - repair0);
sampleCount len = (sampleCount)(s1 - s0);
if (len < 0)
break; // FIX-ME: This failsafes bug 604, but does not account for why it actually happens.
sampleCount repairStart = (sampleCount)(repair0 - s0);
sampleCount repairLen = (sampleCount)(repair1 - repair0);
sampleCount len = (sampleCount)(s1 - s0);
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."));
bGoodResult = false;
break;
}
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."));
/// 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;
break;
}
if (!ProcessOne(count, track,
s0, len, repairStart, repairLen)) {
bGoodResult = false;
break;
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."));
bGoodResult = false;
break;
}
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."));
/// 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;
break;
}
if (!ProcessOne(count, track,
s0, len, repairStart, repairLen)) {
bGoodResult = false;
break;
}
}
track = (WaveTrack *) iter.Next();