diff --git a/src/effects/ChangePitch.cpp b/src/effects/ChangePitch.cpp index e9d617ea6..fb06b0b5f 100644 --- a/src/effects/ChangePitch.cpp +++ b/src/effects/ChangePitch.cpp @@ -215,7 +215,7 @@ bool EffectChangePitch::Process() proxy.mProxyEffectName = XO("High Quality Pitch Change"); proxy.setParameters(1.0, pitchRatio); - return Delegate(proxy, *mUIParent, nullptr); + return Delegate( proxy ); } else #endif diff --git a/src/effects/ChangeTempo.cpp b/src/effects/ChangeTempo.cpp index fb9f008dd..520bbc344 100644 --- a/src/effects/ChangeTempo.cpp +++ b/src/effects/ChangeTempo.cpp @@ -200,7 +200,7 @@ bool EffectChangeTempo::Process() EffectSBSMS proxy; proxy.mProxyEffectName = XO("High Quality Tempo Change"); proxy.setParameters(tempoRatio, 1.0); - success = Delegate(proxy, *mUIParent, nullptr); + success = Delegate( proxy ); } else #endif diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index c177cf034..d0ae08071 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1218,14 +1218,13 @@ bool Effect::DoEffect(double projectRate, return returnVal; } -bool Effect::Delegate( - Effect &delegate, wxWindow &parent, const EffectDialogFactory &factory ) +bool Effect::Delegate( Effect &delegate ) { NotifyingSelectedRegion region; region.setTimes( mT0, mT1 ); - return delegate.DoEffect( mProjectRate, mTracks, mFactory, - region, &parent, factory ); + return delegate.DoEffect( + mProjectRate, mTracks, mFactory, region ); } // All legacy effects should have this overridden diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 2b7f10d28..14bf8a028 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -261,8 +261,7 @@ class AUDACITY_DLL_API Effect /* not final */ : public wxEvtHandler, wxWindow *pParent = nullptr, const EffectDialogFactory &dialogFactory = {} ); - bool Delegate( Effect &delegate, - wxWindow &parent, const EffectDialogFactory &factory ); + bool Delegate( Effect &delegate ); virtual bool IsHidden(); diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 7ac052607..2eb467dc2 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -523,6 +523,8 @@ bool NyquistEffect::SetAutomationParameters(CommandParameters & parms) bool NyquistEffect::Init() { + mDelegate.reset(); + // When Nyquist Prompt spawns an effect GUI, Init() is called for Nyquist Prompt, // and then again for the spawned (mExternal) effect. @@ -596,17 +598,21 @@ bool NyquistEffect::Init() return true; } -bool NyquistEffect::CheckWhetherSkipEffect() -{ - // If we're a prompt and we have controls, then we've already processed - // the audio, so skip further processing. - return (mIsPrompt && mControls.size() > 0); -} - static void RegisterFunctions(); bool NyquistEffect::Process() { + if (mDelegate) + { + mProgress->Hide(); + auto &effect = *mDelegate; + auto result = Delegate( effect ); + mT0 = effect.mT0; + mT1 = effect.mT1; + mDelegate.reset(); + return result; + } + // Check for reentrant Nyquist commands. // I'm choosing to mark skipped Nyquist commands as successful even though // they are skipped. The reason is that when Nyquist calls out to a chain, @@ -626,10 +632,6 @@ bool NyquistEffect::Process() EffectManager & em = EffectManager::Get(); em.SetSkipStateFlag(false); - if (mExternal) { - mProgress->Hide(); - } - mOutputTime = 0; mCount = 0; mProgressIn = 0; @@ -992,14 +994,14 @@ bool NyquistEffect::ShowInterface( return res; } - NyquistEffect effect(NYQUIST_WORKER_ID); - + // Come here only in case the user entered a script into the Nyquist + // prompt window that included the magic comments that specify controls. + // Interpret those comments and put up a second dialog. + mDelegate = std::make_unique< NyquistEffect >( NYQUIST_WORKER_ID ); + auto &effect = *mDelegate; effect.SetCommand(mInputCmd); effect.mDebug = (mUIResultID == eDebugID); - bool result = Delegate(effect, parent, factory); - mT0 = effect.mT0; - mT1 = effect.mT1; - return result; + return effect.ShowInterface( parent, factory, forceModal ); } void NyquistEffect::PopulateOrExchange(ShuttleGui & S) diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index b1ac01af4..5143a1b8e 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -97,7 +97,6 @@ public: // Effect implementation bool Init() override; - bool CheckWhetherSkipEffect() override; bool Process() override; bool ShowInterface( wxWindow &parent, const EffectDialogFactory &factory, bool forceModal = false) override; @@ -189,6 +188,8 @@ private: private: + std::unique_ptr mDelegate; + wxString mXlispPath; wxFileName mFileName; ///< Name of the Nyquist script file this effect is loaded from