diff --git a/src/effects/ChangeSpeed.cpp b/src/effects/ChangeSpeed.cpp index b0268397a..4d5bc62b9 100644 --- a/src/effects/ChangeSpeed.cpp +++ b/src/effects/ChangeSpeed.cpp @@ -224,9 +224,9 @@ bool EffectChangeSpeed::Process() // Similar to EffectSoundTouch::Process() // Iterate over each track. - // Track::All is needed because this effect needs to introduce + // All needed because this effect needs to introduce // silence in the sync-lock group tracks to keep sync - CopyInputTracks(Track::All); // Set up mOutputTracks. + CopyInputTracks(true); // Set up mOutputTracks. bool bGoodResult = true; mCurTrackNum = 0; diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index e3694f1a0..5a312d82c 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -104,7 +104,6 @@ Effect::Effect() mClient = NULL; mTracks = NULL; - mOutputTracksType = Track::None; mT0 = 0.0; mT1 = 0.0; mDuration = 0.0; @@ -1311,7 +1310,7 @@ bool Effect::InitPass2() bool Effect::Process() { - CopyInputTracks(Track::All); + CopyInputTracks(true); bool bGoodResult = true; // It's possible that the number of channels the effect expects changed based on @@ -2050,37 +2049,32 @@ void Effect::GetSamples( // // private methods // -// Use these two methods to copy the input tracks to mOutputTracks, if +// Use this method to copy the input tracks to mOutputTracks, if // doing the processing on them, and replacing the originals only on success (and not cancel). // Copy the group tracks that have tracks selected -void Effect::CopyInputTracks() -{ - CopyInputTracks(Track::Wave); -} - -void Effect::CopyInputTracks(TrackKind trackType) +// If not all sync-locked selected, then only selected wave tracks. +void Effect::CopyInputTracks(bool allSyncLockSelected) { // Reset map mIMap.clear(); mOMap.clear(); mOutputTracks = TrackList::Create(); - mOutputTracksType = trackType; - //iterate over tracks of type trackType (All types if Track::All) - TrackListOfKindIterator aIt(trackType, mTracks); + auto trackRange = mTracks->Any() + + [&] (const Track *pTrack) { + return allSyncLockSelected + ? pTrack->IsSelectedOrSyncLockSelected() + : track_cast( pTrack ) && pTrack->GetSelected(); + }; + t2bHash added; - for (Track *aTrack = aIt.First(); aTrack; aTrack = aIt.Next()) + for (auto aTrack : trackRange) { - // Include selected tracks, plus sync-lock selected tracks for Track::All. - if (aTrack->GetSelected() || - (trackType == Track::All && aTrack->IsSyncLockSelected())) - { - Track *o = mOutputTracks->Add(aTrack->Duplicate()); - mIMap.push_back(aTrack); - mOMap.push_back(o); - } + Track *o = mOutputTracks->Add(aTrack->Duplicate()); + mIMap.push_back(aTrack); + mOMap.push_back(o); } } @@ -2192,8 +2186,6 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult) mIMap.clear(); mOMap.clear(); - mOutputTracksType = Track::None; - //TODO:undo the non-gui ODTask transfer return; } @@ -2265,7 +2257,6 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult) // The output list is no longer needed mOutputTracks.reset(); - mOutputTracksType = Track::None; nEffectsDone++; } diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 9ce5aa98e..02828f8d4 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -366,10 +366,10 @@ protected: // preview copies of all wave tracks. void IncludeNotSelectedPreviewTracks(bool includeNotSelected); - // Use these two methods to copy the input tracks to mOutputTracks, if + // Use this method to copy the input tracks to mOutputTracks, if // doing the processing on them, and replacing the originals only on success (and not cancel). - void CopyInputTracks(); // trackType = TrackKind::Wave - void CopyInputTracks(TrackKind trackType); + // If not all sync-locked selected, then only selected wave tracks. + void CopyInputTracks(bool allSyncLockSelected = false); // A global counter of all the successful Effect invocations. static int nEffectsDone; @@ -478,9 +478,6 @@ protected: sampleCount mSampleCnt; - // type of the tracks on mOutputTracks - TrackKind mOutputTracksType; - // Used only by the base Effect class // private: diff --git a/src/effects/Equalization48x.cpp b/src/effects/Equalization48x.cpp index a96c2d92b..bdc8ceab4 100644 --- a/src/effects/Equalization48x.cpp +++ b/src/effects/Equalization48x.cpp @@ -347,7 +347,8 @@ bool EffectEqualization48x::TrackCompare() // Include selected tracks, plus sync-lock selected tracks for Track::All. if (aTrack->GetSelected() || - (mEffectEqualization->mOutputTracksType == Track::All && aTrack->IsSyncLockSelected())) + (// mEffectEqualization->mOutputTracksType == TrackKind::All && + aTrack->IsSyncLockSelected())) { auto o = aTrack->Duplicate(); SecondIMap.push_back(aTrack); diff --git a/src/effects/Generator.cpp b/src/effects/Generator.cpp index c84b0a8c2..2cce54401 100644 --- a/src/effects/Generator.cpp +++ b/src/effects/Generator.cpp @@ -32,8 +32,8 @@ bool Generator::Process() // Set up mOutputTracks. - // This effect needs Track::All for sync-lock grouping. - this->CopyInputTracks(Track::All); + // This effect needs all for sync-lock grouping. + this->CopyInputTracks(true); // Iterate over the tracks bool bGoodResult = true; diff --git a/src/effects/Repeat.cpp b/src/effects/Repeat.cpp index a1b2ab3cd..d88c2d9b7 100644 --- a/src/effects/Repeat.cpp +++ b/src/effects/Repeat.cpp @@ -106,8 +106,8 @@ bool EffectRepeat::SetAutomationParameters(CommandParameters & parms) bool EffectRepeat::Process() { // Set up mOutputTracks. - // This effect needs Track::All for sync-lock grouping. - CopyInputTracks(Track::All); + // This effect needs all for sync-lock grouping. + CopyInputTracks(true); int nTrack = 0; bool bGoodResult = true; diff --git a/src/effects/Reverse.cpp b/src/effects/Reverse.cpp index 794d9ed26..6674c0372 100644 --- a/src/effects/Reverse.cpp +++ b/src/effects/Reverse.cpp @@ -64,8 +64,8 @@ bool EffectReverse::IsInteractive() bool EffectReverse::Process() { - //Track::All is needed because Reverse should move the labels too - this->CopyInputTracks(Track::All); // Set up mOutputTracks. + //all needed because Reverse should move the labels too + this->CopyInputTracks(true); // Set up mOutputTracks. bool bGoodResult = true; int count = 0; diff --git a/src/effects/SBSMSEffect.cpp b/src/effects/SBSMSEffect.cpp index b2c237605..ec9023553 100644 --- a/src/effects/SBSMSEffect.cpp +++ b/src/effects/SBSMSEffect.cpp @@ -215,8 +215,8 @@ bool EffectSBSMS::Process() bool bGoodResult = true; //Iterate over each track - //Track::All is needed because this effect needs to introduce silence in the group tracks to keep sync - this->CopyInputTracks(Track::All); // Set up mOutputTracks. + //all needed because this effect needs to introduce silence in the group tracks to keep sync + this->CopyInputTracks(true); // Set up mOutputTracks. mCurTrackNum = 0; double maxDuration = 0.0; diff --git a/src/effects/SoundTouchEffect.cpp b/src/effects/SoundTouchEffect.cpp index 3e68abb30..dd77863c9 100644 --- a/src/effects/SoundTouchEffect.cpp +++ b/src/effects/SoundTouchEffect.cpp @@ -82,8 +82,8 @@ bool EffectSoundTouch::ProcessWithTimeWarper(const TimeWarper &warper) } //Iterate over each track - // Needs Track::All for sync-lock grouping. - this->CopyInputTracks(Track::All); + // Needs all for sync-lock grouping. + this->CopyInputTracks(true); bool bGoodResult = true; mCurTrackNum = 0; diff --git a/src/effects/TruncSilence.cpp b/src/effects/TruncSilence.cpp index 3a8f3adcc..72465f298 100644 --- a/src/effects/TruncSilence.cpp +++ b/src/effects/TruncSilence.cpp @@ -356,7 +356,7 @@ bool EffectTruncSilence::ProcessIndependently() // Now do the work // Copy tracks - CopyInputTracks(Track::All); + CopyInputTracks(true); double newT1 = 0.0; { @@ -396,7 +396,7 @@ bool EffectTruncSilence::ProcessIndependently() bool EffectTruncSilence::ProcessAll() { // Copy tracks - CopyInputTracks(Track::All); + CopyInputTracks(true); // Master list of silent regions. // This list should always be kept in order. diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 0a4315ca1..8b41c8f00 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -643,10 +643,9 @@ bool NyquistEffect::Process() // We must copy all the tracks, because Paste needs label tracks to ensure // correct sync-lock group behavior when the timeline is affected; then we just want - // to operate on the selected wave tracks. - // Also need to set up mOutputTracks for channel count. - if( !bOnePassTool ) - CopyInputTracks(Track::All); + // to operate on the selected wave tracks + if ( !bOnePassTool ) + CopyInputTracks(true); SelectedTrackListOfKindIterator sel(Track::Wave, mOutputTracks.get()); for (WaveTrack *t = (WaveTrack *) sel.First(); t; t = (WaveTrack *) sel.Next()) { @@ -791,7 +790,7 @@ bool NyquistEffect::Process() } SelectedTrackListOfKindIterator iter(Track::Wave, mOutputTracks.get()); - mCurTrack[0] = (WaveTrack *)iter.First(); + mCurTrack[0] = (WaveTrack *) iter.First(); // Keep track of whether the current track is first selected in its sync-lock group // (we have no idea what the length of the returned audio will be, so we have