From 33daaafc59685de16af7f72effc0dc75fa14f84f Mon Sep 17 00:00:00 2001 From: James Crook Date: Sat, 24 Feb 2018 10:24:10 +0000 Subject: [PATCH] Make Nyquist effects define their parameters. --- src/effects/nyquist/Nyquist.cpp | 67 ++++++++++++++++++++++++++++++++- src/effects/nyquist/Nyquist.h | 1 + 2 files changed, 67 insertions(+), 1 deletion(-) diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index f3e22d45d..4ae7ed02c 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -278,6 +278,70 @@ bool NyquistEffect::IsDefault() } // EffectClientInterface implementation +bool NyquistEffect::DefineParams( ShuttleParams & S ) +{ + // For now we assume Nyquist can do get and set better than DefineParams can, + // And so we ONLY use it for geting the signature. + auto pGa = dynamic_cast(&S); + if( pGa ){ + GetAutomationParameters( *(pGa->mpEap) ); + return true; + } + auto pSa = dynamic_cast(&S); + if( pSa ){ + SetAutomationParameters( *(pSa->mpEap) ); + return true; + } + auto pSd = dynamic_cast(&S); + if( pSd == nullptr ) + return true; + //wxASSERT( pSd ); + + if (mExternal) + return true; + + if (mIsPrompt) + { + S.Define( mInputCmd, KEY_Command, "" ); + S.Define( mVersion, KEY_Version, 3 ); + return true; + } + + for (size_t c = 0, cnt = mControls.size(); c < cnt; c++) + { + NyqControl & ctrl = mControls[c]; + double d = ctrl.val; + + if (d == UNINITIALIZED_CONTROL && ctrl.type != NYQ_CTRL_STRING) + { + d = GetCtrlValue(ctrl.valStr); + } + + if (ctrl.type == NYQ_CTRL_REAL || ctrl.type == NYQ_CTRL_FLOAT_TEXT) + { + S.Define( d, static_cast( ctrl.var.c_str() ), (double)0.0, ctrl.low, ctrl.high, 1.0); + } + else if (ctrl.type == NYQ_CTRL_INT || ctrl.type == NYQ_CTRL_INT_TEXT) + { + int x=d; + S.Define( x, static_cast( ctrl.var.c_str() ), 0, ctrl.low, ctrl.high, 1); + //parms.Write(ctrl.var, (int) d); + } + else if (ctrl.type == NYQ_CTRL_CHOICE) + { + wxArrayString choices = ParseChoice(ctrl); + int x=d; + //parms.WriteEnum(ctrl.var, (int) d, choices); + S.DefineEnum( x, static_cast( ctrl.var.c_str() ), 0, choices ); + } + else if (ctrl.type == NYQ_CTRL_STRING) + { + S.Define( ctrl.valStr, ctrl.var, "" , ctrl.lowStr, ctrl.highStr ); + //parms.Write(ctrl.var, ctrl.valStr); + } + } + return true; +} bool NyquistEffect::GetAutomationParameters(CommandParameters & parms) { @@ -493,6 +557,7 @@ bool NyquistEffect::CheckWhetherSkipEffect() bool NyquistEffect::Process() { bool success = true; + mProjectChanged = false; EffectManager & em = EffectManager::Get(); em.SetSkipStateFlag(false); @@ -781,7 +846,7 @@ _("Selection too long for Nyquist code.\nMaximum allowed selection is %ld sample mT1 = mT0 + mOutputTime; } - finish: +finish: // Show debug window if trace set in plug-in header and something to show. mDebug = (mTrace && !mDebugOutput.IsEmpty())? true : mDebug; diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index 09956cdb1..f86bbab2e 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -97,6 +97,7 @@ public: // EffectClientInterface implementation + bool DefineParams( ShuttleParams & S ) override; bool GetAutomationParameters(CommandParameters & parms) override; bool SetAutomationParameters(CommandParameters & parms) override;