Move enum into EffectManager...

... tying Effect into a cycle of 3 with EffectManager and EffectRack, which is
only revealing the true dependencies
This commit is contained in:
Paul Licameli 2019-06-12 22:44:24 -04:00
parent d2f386a329
commit 1c588fa014
8 changed files with 32 additions and 30 deletions

View File

@ -736,16 +736,16 @@ bool MacroCommands::ApplyEffectCommand(
// and apply the effect... // and apply the effect...
res = PluginActions::DoAudacityCommand(ID, res = PluginActions::DoAudacityCommand(ID,
Context, Context,
PluginActions::kConfigured | EffectManager::kConfigured |
PluginActions::kSkipState | EffectManager::kSkipState |
PluginActions::kDontRepeatLast); EffectManager::kDontRepeatLast);
else else
// and apply the effect... // and apply the effect...
res = PluginActions::DoEffect(ID, res = PluginActions::DoEffect(ID,
Context, Context,
PluginActions::kConfigured | EffectManager::kConfigured |
PluginActions::kSkipState | EffectManager::kSkipState |
PluginActions::kDontRepeatLast); EffectManager::kDontRepeatLast);
} }
return res; return res;
@ -778,7 +778,7 @@ bool MacroCommands::HandleTextualCommand( CommandManager &commandManager,
{ {
return PluginActions::DoEffect( return PluginActions::DoEffect(
plug->GetID(), context, plug->GetID(), context,
PluginActions::kConfigured); EffectManager::kConfigured);
} }
plug = pm.GetNextPlugin(PluginTypeEffect); plug = pm.GetNextPlugin(PluginTypeEffect);
} }

View File

@ -140,16 +140,6 @@ void DoRecord( AudacityProject & );
/// Namespace for helper functions to do with plug ins /// Namespace for helper functions to do with plug ins
namespace PluginActions { namespace PluginActions {
enum : unsigned {
// No flags specified
kNone = 0x00,
// Flag used to disable prompting for configuration parameteres.
kConfigured = 0x01,
// Flag used to disable saving the state after processing.
kSkipState = 0x02,
// Flag used to disable "Repeat Last Effect"
kDontRepeatLast = 0x04,
};
bool DoEffect( bool DoEffect(
const PluginID & ID, const CommandContext & context, unsigned flags ); const PluginID & ID, const CommandContext & context, unsigned flags );
bool DoAudacityCommand( bool DoAudacityCommand(

View File

@ -1715,7 +1715,7 @@ bool ProjectFileManager::Import(
PluginActions::DoEffect( PluginActions::DoEffect(
EffectManager::Get().GetEffectByIdentifier(wxT("Normalize")), EffectManager::Get().GetEffectByIdentifier(wxT("Normalize")),
context, context,
PluginActions::kConfigured); EffectManager::kConfigured);
} }
// This is a no-fail: // This is a no-fail:

View File

@ -47,6 +47,7 @@ greater use in future.
#include "audacity/ConfigInterface.h" #include "audacity/ConfigInterface.h"
#include "EffectManager.h"
#include "RealtimeEffectManager.h" #include "RealtimeEffectManager.h"
#include "../AudioIO.h" #include "../AudioIO.h"
#include "../CommonCommandFlags.h" #include "../CommonCommandFlags.h"
@ -777,7 +778,7 @@ bool Effect::Apply()
// //
// It should callback to the EffectManager to kick off the processing // It should callback to the EffectManager to kick off the processing
return PluginActions::DoEffect(GetID(), context, return PluginActions::DoEffect(GetID(), context,
PluginActions::kConfigured); EffectManager::kConfigured);
} }
void Effect::Preview() void Effect::Preview()

View File

@ -45,6 +45,17 @@ class AUDACITY_DLL_API EffectManager
{ {
public: public:
enum : unsigned {
// No flags specified
kNone = 0x00,
// Flag used to disable prompting for configuration parameteres.
kConfigured = 0x01,
// Flag used to disable saving the state after processing.
kSkipState = 0x02,
// Flag used to disable "Repeat Last Effect"
kDontRepeatLast = 0x04,
};
/** Get the singleton instance of the EffectManager. Probably not safe /** Get the singleton instance of the EffectManager. Probably not safe
for multi-thread use. */ for multi-thread use. */
static EffectManager & Get(); static EffectManager & Get();

View File

@ -311,7 +311,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
{ {
if (!PluginActions::DoEffect(mEffects[i]->GetID(), if (!PluginActions::DoEffect(mEffects[i]->GetID(),
*project, *project,
PluginActions::kConfigured)) EffectManager::kConfigured))
// If any effect fails (or throws), then stop. // If any effect fails (or throws), then stop.
return; return;
} }

View File

@ -447,7 +447,7 @@ bool DoEffect(
// Make sure there's no activity since the effect is about to be applied // Make sure there's no activity since the effect is about to be applied
// to the project's tracks. Mainly for Apply during RTP, but also used // to the project's tracks. Mainly for Apply during RTP, but also used
// for batch commands // for batch commands
if (flags & kConfigured) if (flags & EffectManager::kConfigured)
{ {
TransportActions::DoStop(project); TransportActions::DoStop(project);
SelectUtilities::SelectAllIfNone( project ); SelectUtilities::SelectAllIfNone( project );
@ -486,22 +486,22 @@ bool DoEffect(
success = em.DoEffect(ID, &window, rate, success = em.DoEffect(ID, &window, rate,
&tracks, &trackFactory, &selectedRegion, &tracks, &trackFactory, &selectedRegion,
(flags & kConfigured) == 0); (flags & EffectManager::kConfigured) == 0);
if (!success) if (!success)
return false; return false;
if (em.GetSkipStateFlag()) if (em.GetSkipStateFlag())
flags = flags | kSkipState; flags = flags | EffectManager::kSkipState;
if (!(flags & kSkipState)) if (!(flags & EffectManager::kSkipState))
{ {
wxString shortDesc = em.GetCommandName(ID); wxString shortDesc = em.GetCommandName(ID);
wxString longDesc = em.GetCommandDescription(ID); wxString longDesc = em.GetCommandDescription(ID);
ProjectHistory::Get( project ).PushState(longDesc, shortDesc); ProjectHistory::Get( project ).PushState(longDesc, shortDesc);
} }
if (!(flags & kDontRepeatLast)) if (!(flags & EffectManager::kDontRepeatLast))
{ {
// Only remember a successful effect, don't remember insert, // Only remember a successful effect, don't remember insert,
// or analyze effects. // or analyze effects.
@ -559,7 +559,7 @@ bool DoAudacityCommand(
if (!plug) if (!plug)
return false; return false;
if (flags & kConfigured) if (flags & EffectManager::kConfigured)
{ {
TransportActions::DoStop(project); TransportActions::DoStop(project);
// SelectAllIfNone(); // SelectAllIfNone();
@ -569,7 +569,7 @@ bool DoAudacityCommand(
bool success = em.DoAudacityCommand(ID, bool success = em.DoAudacityCommand(ID,
context, context,
&window, &window,
(flags & kConfigured) == 0); (flags & EffectManager::kConfigured) == 0);
if (!success) if (!success)
return false; return false;
@ -616,7 +616,7 @@ void OnRepeatLastEffect(const CommandContext &context)
auto lastEffect = MenuManager::Get(context.project).mLastEffect; auto lastEffect = MenuManager::Get(context.project).mLastEffect;
if (!lastEffect.empty()) if (!lastEffect.empty())
{ {
DoEffect( lastEffect, context, kConfigured ); DoEffect( lastEffect, context, EffectManager::kConfigured );
} }
} }
@ -743,7 +743,7 @@ void OnAudacityCommand(const CommandContext & ctx)
wxLogDebug( "Command was: %s", ctx.parameter.GET()); wxLogDebug( "Command was: %s", ctx.parameter.GET());
// Not configured, so prompt user. // Not configured, so prompt user.
DoAudacityCommand(EffectManager::Get().GetEffectByIdentifier(ctx.parameter), DoAudacityCommand(EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
ctx, kNone); ctx, EffectManager::kNone);
} }
}; // struct Handler }; // struct Handler

View File

@ -677,7 +677,7 @@ void OnStereoToMono(const CommandContext &context)
PluginActions::DoEffect( PluginActions::DoEffect(
EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")), EffectManager::Get().GetEffectByIdentifier(wxT("StereoToMono")),
context, context,
PluginActions::kConfigured); EffectManager::kConfigured);
} }
void OnMixAndRender(const CommandContext &context) void OnMixAndRender(const CommandContext &context)