mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-29 23:29:41 +02:00
Fix up label behavior, clean up reverse effect
This commit is contained in:
parent
7945e8723d
commit
10892c33e5
@ -36,25 +36,20 @@ bool EffectReverse::Process()
|
||||
//Track::All is needed because Reverse should move the labels too
|
||||
this->CopyInputTracks(Track::All); // Set up mOutputTracks.
|
||||
bool bGoodResult = true;
|
||||
Track *lastGroup = NULL; // First track of group of last acted-on WaveTrack
|
||||
TrackGroupIterator gIt(mOutputTracks);
|
||||
|
||||
TrackListIterator iter(mOutputTracks);
|
||||
Track *t = iter.First();
|
||||
int count = 0;
|
||||
double lt0 = -2.0; // -2.0 = not initialized yet; -1.0 = is not possible to reverse labels
|
||||
double lt1 = -2.0;
|
||||
while (t) {
|
||||
if (t->GetKind() == Track::Wave) {
|
||||
WaveTrack *track = (WaveTrack*)t;
|
||||
|
||||
// Since leading and trailing whitespaces should also be considered for reversal
|
||||
// t0 and t1 must always be equal to mT0 and mT1
|
||||
double t0 = mT0;
|
||||
double t1 = mT1;
|
||||
|
||||
if (track->GetSelected()) {
|
||||
if (t1 > t0) {
|
||||
sampleCount start = track->TimeToLongSamples(t0);
|
||||
sampleCount end = track->TimeToLongSamples(t1);
|
||||
if (mT1 > mT0) {
|
||||
sampleCount start = track->TimeToLongSamples(mT0);
|
||||
sampleCount end = track->TimeToLongSamples(mT1);
|
||||
sampleCount len = (sampleCount)(end - start);
|
||||
|
||||
if (!ProcessOneWave(count, track, start, len))
|
||||
@ -62,39 +57,19 @@ bool EffectReverse::Process()
|
||||
bGoodResult = false;
|
||||
break;
|
||||
}
|
||||
|
||||
//if this is the first selected track in the group we can define the label
|
||||
//region to be reversed without any more verifications
|
||||
if (lt0 == -2.0) {
|
||||
lt0 = t0;
|
||||
lt1 = t1;
|
||||
}
|
||||
//track has not the same selection result (after checking start and end of the track as the first track)
|
||||
//it's not possible to know how to reverse the label in this situation.
|
||||
else if ((lt0 != t0) || (lt1 != t1)) {
|
||||
lt0 = -1.0;
|
||||
lt1 = -1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
//if the track is not selected but has no content inside the selected region, there is no problem.
|
||||
//otherwise we should not change the labels.
|
||||
else if (t1 > t0) {
|
||||
lt0 = -1.0;
|
||||
lt1 = -1.0;
|
||||
}
|
||||
|
||||
// Update grouping variables
|
||||
lastGroup = gIt.First(t);
|
||||
}
|
||||
}
|
||||
else if (t->GetKind() == Track::Label) {
|
||||
AudacityProject *p = GetActiveProject();
|
||||
//if we can reverse the label
|
||||
if (lt0 != -1.0 && p && p->IsSticky()) {
|
||||
if ((p && p->IsSticky() && gIt.First(t) == lastGroup) ||
|
||||
t->GetSelected())
|
||||
{
|
||||
LabelTrack *track = (LabelTrack*)t;
|
||||
track->ChangeLabelsOnReverse(lt0, lt1);
|
||||
}
|
||||
//otherwise we set the region to the not initialized state -2.0 to begin the process in the next group
|
||||
else {
|
||||
lt0 = -2.0;
|
||||
lt1 = -2.0;
|
||||
track->ChangeLabelsOnReverse(mT0, mT1);
|
||||
}
|
||||
}
|
||||
t = iter.Next();
|
||||
|
Loading…
x
Reference in New Issue
Block a user