From b93a2e53cc2d3d29bbe2b0b902d44cf4c87f4fce Mon Sep 17 00:00:00 2001 From: James Crook Date: Tue, 13 Feb 2018 12:59:04 +0000 Subject: [PATCH] Protect Nyquist against effect-within-effect The Effect code makes temporary copies of wavetracks. If Nyquist invokes another effect, its temporary copy is no longer valid. My solution is to NOT apply the Nyquist effect results IF some other effect was successfully invoked in creating them. I do this by counting the effect invocations. If it has changed, then Nyquist output Is not applied back to the track. The net result is that Nyquist prompt can invoke other effects, or process the audio itself, but it cannot do both. --- src/effects/Effect.cpp | 4 ++++ src/effects/Effect.h | 4 +++- src/effects/nyquist/Nyquist.cpp | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 30b3cbe11..adbee9037 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -71,6 +71,9 @@ greater use in future. #include #endif +// Effect application counter +int Effect::nEffectsDone=0; + static const int kDummyID = 20000; static const int kSaveAsID = 20001; static const int kImportID = 20002; @@ -2267,6 +2270,7 @@ void Effect::ReplaceProcessedTracks(const bool bGoodResult) // The output list is no longer needed mOutputTracks.reset(); mOutputTracksType = Track::None; + nEffectsDone++; } void Effect::CountWaveTracks() diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 31e0f405b..867828d99 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -340,7 +340,6 @@ protected: bool TrackGroupProgress(int whichGroup, double frac, const wxString & = wxEmptyString); int GetNumWaveTracks() { return mNumTracks; } - int GetNumWaveGroups() { return mNumGroups; } // Calculates the start time and selection length in samples @@ -369,6 +368,9 @@ protected: void CopyInputTracks(); // trackType = Track::Wave void CopyInputTracks(int trackType); + // A global counter of all the successful Effect invocations. + static int nEffectsDone; + // For the use of analyzers, which don't need to make output wave tracks, // but may need to add label tracks. class AddedAnalysisTrack { diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 4b56b5bee..58e1754a4 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -488,6 +488,8 @@ bool NyquistEffect::CheckWhetherSkipEffect() bool NyquistEffect::Process() { bool success = true; + + int nEffectsSoFar = nEffectsDone; mProjectChanged = false; EffectManager & em = EffectManager::Get(); em.SetSkipStateFlag(false); @@ -790,7 +792,11 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample dlog.ShowModal(); } - ReplaceProcessedTracks(success); + // Has rug been pulled from under us by some effect done within Nyquist?? + if( nEffectsSoFar == nEffectsDone ) + ReplaceProcessedTracks(success); + else + ReplaceProcessedTracks(false); // Do not use the results. if (!mProjectChanged) em.SetSkipStateFlag(true);