From 2abb46b83d37f3cb83bf16d8d87bab5a454fb2ba Mon Sep 17 00:00:00 2001 From: "stevethefiddle@gmail.com" Date: Sun, 26 Oct 2014 20:30:22 +0000 Subject: [PATCH] Allow generator effects to use preview without requiring a selection to be made. Documentation: This does not affect any currently shipped effects. This will need documenting on the wiki for writing Nyquist plug-ins. --- src/effects/Effect.cpp | 3 ++- src/effects/Effect.h | 6 ++++++ src/effects/nyquist/Nyquist.cpp | 6 ++++++ src/effects/nyquist/Nyquist.h | 3 ++- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/effects/Effect.cpp b/src/effects/Effect.cpp index 2502af84b..7f2dc9ca7 100644 --- a/src/effects/Effect.cpp +++ b/src/effects/Effect.cpp @@ -1409,7 +1409,8 @@ void Effect::Preview(bool dryOnly) if (t1 > mT1) t1 = mT1; - if (t1 <= t0) + // Generators can run without a selection. + if (!GeneratorPreview() && (t1 <= t0)) return; bool success = ::MixAndRender(mTracks, mFactory, rate, floatSample, t0, t1, diff --git a/src/effects/Effect.h b/src/effects/Effect.h index 67aa36fa0..f2f934623 100644 --- a/src/effects/Effect.h +++ b/src/effects/Effect.h @@ -181,6 +181,12 @@ class AUDACITY_DLL_API Effect : public EffectHostInterface return (mFlags & BUILTIN_EFFECT) != 0; } + // Preview normally requires a selection, but INSERT_EFFECTs do not. + // Return true to override the need for a selection. + virtual bool GeneratorPreview(){ + return false; + } + // Called to set or retrieve parameter values. Return true if successful. virtual bool TransferParameters( Shuttle & WXUNUSED(shuttle) ) { return true; diff --git a/src/effects/nyquist/Nyquist.cpp b/src/effects/nyquist/Nyquist.cpp index 2f7436040..652ce4bc9 100644 --- a/src/effects/nyquist/Nyquist.cpp +++ b/src/effects/nyquist/Nyquist.cpp @@ -508,6 +508,12 @@ bool EffectNyquist::TransferParameters( Shuttle & shuttle ) return true; } +bool EffectNyquist::GeneratorPreview() +{ + // Enable Nyquist generator plug-ins to create preview without a selection + return (mEnablePreview && (GetEffectFlags() & INSERT_EFFECT)); +} + bool EffectNyquist::PromptUser() { while (mInteractive) { diff --git a/src/effects/nyquist/Nyquist.h b/src/effects/nyquist/Nyquist.h index de2be7418..9d036e2f0 100644 --- a/src/effects/nyquist/Nyquist.h +++ b/src/effects/nyquist/Nyquist.h @@ -112,7 +112,8 @@ class AUDACITY_DLL_API EffectNyquist:public Effect return mAction; } - virtual bool PromptUser(); + virtual bool GeneratorPreview(); + virtual bool PromptUser(); virtual bool Process();