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

View File

@ -140,16 +140,6 @@ void DoRecord( AudacityProject & );
/// Namespace for helper functions to do with plug ins
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(
const PluginID & ID, const CommandContext & context, unsigned flags );
bool DoAudacityCommand(

View File

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

View File

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

View File

@ -45,6 +45,17 @@ class AUDACITY_DLL_API EffectManager
{
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
for multi-thread use. */
static EffectManager & Get();

View File

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

View File

@ -447,7 +447,7 @@ bool DoEffect(
// 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
// for batch commands
if (flags & kConfigured)
if (flags & EffectManager::kConfigured)
{
TransportActions::DoStop(project);
SelectUtilities::SelectAllIfNone( project );
@ -486,22 +486,22 @@ bool DoEffect(
success = em.DoEffect(ID, &window, rate,
&tracks, &trackFactory, &selectedRegion,
(flags & kConfigured) == 0);
(flags & EffectManager::kConfigured) == 0);
if (!success)
return false;
if (em.GetSkipStateFlag())
flags = flags | kSkipState;
flags = flags | EffectManager::kSkipState;
if (!(flags & kSkipState))
if (!(flags & EffectManager::kSkipState))
{
wxString shortDesc = em.GetCommandName(ID);
wxString longDesc = em.GetCommandDescription(ID);
ProjectHistory::Get( project ).PushState(longDesc, shortDesc);
}
if (!(flags & kDontRepeatLast))
if (!(flags & EffectManager::kDontRepeatLast))
{
// Only remember a successful effect, don't remember insert,
// or analyze effects.
@ -559,7 +559,7 @@ bool DoAudacityCommand(
if (!plug)
return false;
if (flags & kConfigured)
if (flags & EffectManager::kConfigured)
{
TransportActions::DoStop(project);
// SelectAllIfNone();
@ -569,7 +569,7 @@ bool DoAudacityCommand(
bool success = em.DoAudacityCommand(ID,
context,
&window,
(flags & kConfigured) == 0);
(flags & EffectManager::kConfigured) == 0);
if (!success)
return false;
@ -616,7 +616,7 @@ void OnRepeatLastEffect(const CommandContext &context)
auto lastEffect = MenuManager::Get(context.project).mLastEffect;
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());
// Not configured, so prompt user.
DoAudacityCommand(EffectManager::Get().GetEffectByIdentifier(ctx.parameter),
ctx, kNone);
ctx, EffectManager::kNone);
}
}; // struct Handler

View File

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