1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-12-15 09:01:12 +01:00

Move static EffectManager::DoEffect into new namespace

This commit is contained in:
Paul Licameli
2019-07-21 13:01:01 -04:00
parent 23a0206d2a
commit 91c45dd32a
9 changed files with 46 additions and 70 deletions

View File

@@ -91,14 +91,13 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
mEffects.erase(id);
}
/// DoEffect() takes a PluginID and has the EffectManager execute the associated
/// effect.
/// DoEffect() takes a PluginID and executes the associated effect.
///
/// At the moment flags are used only to indicate whether to prompt for
// parameters, whether to save the state to history and whether to allow
/// 'Repeat Last Effect'.
/* static */ bool EffectManager::DoEffect(
/* static */ bool EffectUI::DoEffect(
const PluginID & ID, const CommandContext &context, unsigned flags )
{
AudacityProject &project = context.project;
@@ -157,9 +156,26 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
EffectManager & em = EffectManager::Get();
success = em.DoEffect(ID, &window, context.project, rate,
&tracks, &trackFactory, selectedRegion,
(flags & EffectManager::kConfigured) == 0);
em.SetSkipStateFlag( false );
if (auto effect = em.GetEffect(ID)) {
#if defined(EXPERIMENTAL_EFFECTS_RACK)
if (effect->SupportsRealtime())
{
EffectRack::Get( context.project ).Add(effect);
}
#endif
success = effect->DoEffect(&window,
rate,
&tracks,
&trackFactory,
selectedRegion,
(flags & EffectManager::kConfigured) == 0
? DialogFactory
: nullptr
);
}
else
success = false;
if (!success)
return false;
@@ -227,43 +243,6 @@ void EffectManager::UnregisterEffect(const PluginID & ID)
return true;
}
bool EffectManager::DoEffect(const PluginID & ID,
wxWindow *parent,
AudacityProject &project,
double projectRate,
TrackList *list,
TrackFactory *trackFactory,
NotifyingSelectedRegion &selectedRegion,
bool shouldPrompt /* = true */)
{
this->SetSkipStateFlag(false);
Effect *effect = GetEffect(ID);
if (!effect)
{
return false;
}
#if defined(EXPERIMENTAL_EFFECTS_RACK)
if (effect->SupportsRealtime())
{
EffectRack::Get( project ).Add(effect);
}
#else
(void)project;
#endif
bool res = effect->DoEffect( parent,
projectRate,
list,
trackFactory,
selectedRegion,
shouldPrompt ? EffectUI::DialogFactory : nullptr );
return res;
}
bool EffectManager::DoAudacityCommand(const PluginID & ID,
const CommandContext &context,
wxWindow *parent,

View File

@@ -71,9 +71,6 @@ public:
// them by index number, usually when the user selects one from a menu.
//
public:
static bool DoEffect(
const PluginID & ID, const CommandContext &context, unsigned flags );
EffectManager();
virtual ~EffectManager();
@@ -83,19 +80,6 @@ public:
const PluginID & RegisterEffect(Effect *f);
void UnregisterEffect(const PluginID & ID);
/** Run an effect given the plugin ID */
// Returns true on success. Will only operate on tracks that
// have the "selected" flag set to true, which is consistent with
// Audacity's standard UI.
bool DoEffect(const PluginID & ID,
wxWindow *parent,
AudacityProject &project,
double projectRate,
TrackList *list,
TrackFactory *factory,
NotifyingSelectedRegion &selectedRegion,
bool shouldPrompt = true);
TranslatableString GetEffectFamilyName(const PluginID & ID);
TranslatableString GetVendorName(const PluginID & ID);
@@ -150,12 +134,12 @@ public:
const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
private:
/** Return an effect by its ID. */
Effect *GetEffect(const PluginID & ID);
AudacityCommand *GetAudacityCommand(const PluginID & ID);
private:
AudacityCommand *GetAudacityCommand(const PluginID & ID);
EffectMap mEffects;
AudacityCommandMap mCommands;
EffectOwnerMap mHostEffects;

View File

@@ -310,7 +310,7 @@ void EffectRack::OnApply(wxCommandEvent & WXUNUSED(evt))
{
if (mPowerState[i])
{
if (!EffectManager::DoEffect(mEffects[i]->GetID(),
if (!EffectUI::DoEffect(mEffects[i]->GetID(),
*project,
EffectManager::kConfigured))
// If any effect fails (or throws), then stop.
@@ -1195,7 +1195,7 @@ void EffectUIHost::OnApply(wxCommandEvent & evt)
// This is absolute hackage...but easy and I can't think of another way just now.
//
// It should callback to the EffectManager to kick off the processing
EffectManager::DoEffect(mEffect->GetID(), context,
EffectUI::DoEffect(mEffect->GetID(), context,
EffectManager::kConfigured);
}

View File

@@ -212,9 +212,20 @@ private:
DECLARE_EVENT_TABLE()
};
struct CommandContext;
namespace EffectUI {
wxDialog *DialogFactory( wxWindow *parent, EffectHostInterface *pHost,
EffectUIClientInterface *client);
/** Run an effect given the plugin ID */
// Returns true on success. Will only operate on tracks that
// have the "selected" flag set to true, which is consistent with
// Audacity's standard UI.
bool DoEffect(
const PluginID & ID, const CommandContext &context, unsigned flags );
}
#endif // __AUDACITY_EFFECTUI_H__

View File

@@ -34,7 +34,6 @@ Functions that find and load all LV2 plugins on the system.
#include <wx/log.h>
#include <wx/string.h>
#include "../EffectManager.h"
#include "../../Internat.h"
#include "LV2Effect.h"