Audacity 3.2.0
EffectManager.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 EffectManager.h
6
7 Audacity(R) is copyright (c) 1999-2008 Audacity Team.
8 License: GPL v2 or later. See License.txt.
9
10**********************************************************************/
11
12#ifndef __AUDACITY_EFFECTMANAGER__
13#define __AUDACITY_EFFECTMANAGER__
14
15#include <memory>
16#include <vector>
17
18#include <unordered_map>
19#include "EffectInterface.h"
20#include "EffectUIServices.h" // for EffectDialogFactory
21#include "Identifier.h"
22
23class AudacityCommand;
24class AudacityProject;
25class CommandContext;
28class TrackList;
29class SelectedRegion;
30class wxString;
31typedef wxString PluginID;
32
33#include "EffectInterface.h"
34
38};
39
40using EffectMap = std::unordered_map<wxString, EffectAndDefaultSettings>;
41using AudacityCommandMap = std::unordered_map<wxString, AudacityCommand *>;
42using EffectOwnerMap = std::unordered_map< wxString, std::shared_ptr<EffectPlugin> >;
43
44class AudacityCommand;
45
46
47class AUDACITY_DLL_API EffectManager
48{
49public:
50
51 enum : unsigned {
52 // No flags specified
53 kNone = 0x00,
54 // Flag used to disable prompting for configuration parameteres.
55 kConfigured = 0x01,
56 // Flag used to disable saving the state after processing.
57 kSkipState = 0x02,
58 // Flag used to disable "Repeat Last Effect"
59 kDontRepeatLast = 0x04,
60 // Flag used to disable "Select All during Repeat Generator Effect"
61 kRepeatGen = 0x08,
62 // Flag used for repeating Nyquist Prompt
63 kRepeatNyquistPrompt = 0x10,
64 };
65
67 static
68 const EffectInstanceFactory *GetInstanceFactory(const PluginID &ID);
69
72 static EffectManager & Get();
73
74//
75// public methods
76//
77// Used by the outside program to register the list of effects and retrieve
78// them by index number, usually when the user selects one from a menu.
79//
80public:
82 virtual ~EffectManager();
83
85
87 const PluginID & RegisterEffect(std::unique_ptr<EffectPlugin> uEffect);
89 void UnregisterEffect(const PluginID & ID);
90
91 TranslatableString GetEffectFamilyName(const PluginID & ID);
92 TranslatableString GetVendorName(const PluginID & ID);
93
95 // Returns true on success.
96 bool DoAudacityCommand(const PluginID & ID,
97 const CommandContext &,
98 wxWindow *parent,
99 bool shouldPrompt = true );
100
101 // Renamed from 'Effect' to 'Command' prior to moving out of this class.
102 ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID);
103 TranslatableString GetCommandName(const PluginID & ID);
104 CommandID GetCommandIdentifier(const PluginID & ID);
105 TranslatableString GetCommandDescription(const PluginID & ID);
106 ManualPageID GetCommandUrl(const PluginID & ID);
107 TranslatableString GetCommandTip(const PluginID & ID);
108 // flags control which commands are included.
109 void GetCommandDefinition(const PluginID & ID, const CommandContext & context, int flags);
110 bool IsHidden(const PluginID & ID);
111
113 bool SupportsAutomation(const PluginID & ID);
114 wxString GetEffectParameters(const PluginID & ID);
115 bool SetEffectParameters(const PluginID & ID, const wxString & params);
116 bool PromptUser( const PluginID & ID, const EffectDialogFactory &factory,
117 wxWindow &parent );
118 bool HasPresets(const PluginID & ID);
119 wxString GetPreset(const PluginID & ID, const wxString & params, wxWindow * parent);
120 wxString GetDefaultPreset(const PluginID & ID);
121
122private:
123 void BatchProcessingOn(const PluginID & ID);
124 void BatchProcessingOff(const PluginID & ID);
128 void operator () (EffectManager *p) const
129 { if(p) p->BatchProcessingOff(mID); }
130 };
132 std::unique_ptr< EffectManager, UnsetBatchProcessing >;
133public:
135
141 {
142 BatchProcessingOn(ID); return BatchProcessingScope{ this, {ID} };
143 }
144
146 void SetSkipStateFlag(bool flag);
147 bool GetSkipStateFlag();
148
149 const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
150
152 EffectPlugin *GetEffect(const PluginID & ID);
153
155 EffectSettings *GetDefaultSettings(const PluginID & ID);
156
162 std::pair<EffectPlugin *, EffectSettings *>
163 GetEffectAndDefaultSettings(const PluginID & ID);
164
165private:
166 EffectAndDefaultSettings &DoGetEffect(const PluginID & ID);
167
168 AudacityCommand *GetAudacityCommand(const PluginID & ID);
169
173
175
176 // Set true if we want to skip pushing state
177 // after processing at effect run time.
179};
180
181#endif
static RegisteredToolbarFactory factory
wxString PluginID
EffectDistortionSettings params
Definition: Distortion.cpp:77
std::unordered_map< wxString, std::shared_ptr< EffectPlugin > > EffectOwnerMap
Definition: EffectManager.h:42
std::unordered_map< wxString, EffectAndDefaultSettings > EffectMap
Definition: EffectManager.h:40
wxString PluginID
Definition: EffectManager.h:30
std::unordered_map< wxString, AudacityCommand * > AudacityCommandMap
Definition: EffectManager.h:41
std::function< DialogFactoryResults(wxWindow &parent, EffectBase &, EffectUIServices &, EffectSettingsAccess &) > EffectDialogFactory
Type of function that creates a dialog for an effect.
static std::once_flag flag
Base class for command in Audacity.
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Interface for objects that can receive (string) messages from a command.
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:48
void BatchProcessingOff(const PluginID &ID)
EffectOwnerMap mHostEffects
EffectMap mEffects
BatchProcessingScope SetBatchProcessing(const PluginID &ID)
Begin a scope that ends when the returned object is destroyed.
AudacityCommandMap mCommands
std::unique_ptr< EffectManager, UnsetBatchProcessing > BatchProcessingScope
Factory of instances of an effect.
Definition: EffectPlugin.h:36
Defines a selected portion of a project.
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:850
Holds a msgid for the translation catalog; may also bind format arguments.
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
AUDACITY_DLL_API bool DoAudacityCommand(const PluginID &ID, const CommandContext &context, unsigned flags)
EffectSettings settings
Definition: EffectManager.h:37
A custom deleter for std::unique_ptr.
Externalized state of a plug-in.