Audacity  3.0.3
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. 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>
20 #include "Identifier.h"
21 
22 class AudacityCommand;
23 class AudacityProject;
24 class CommandContext;
27 class Effect;
28 class TrackList;
29 class SelectedRegion;
30 class wxString;
31 typedef wxString PluginID;
32 
33 using EffectMap = std::unordered_map<wxString, Effect *>;
34 using AudacityCommandMap = std::unordered_map<wxString, AudacityCommand *>;
35 using EffectOwnerMap = std::unordered_map< wxString, std::shared_ptr<Effect> >;
36 
37 #if defined(EXPERIMENTAL_EFFECTS_RACK)
38 class EffectRack;
39 #endif
40 class AudacityCommand;
41 
42 
44 
45 class AUDACITY_DLL_API EffectManager
46 {
47 public:
48 
49  enum : unsigned {
50  // No flags specified
51  kNone = 0x00,
52  // Flag used to disable prompting for configuration parameteres.
53  kConfigured = 0x01,
54  // Flag used to disable saving the state after processing.
55  kSkipState = 0x02,
56  // Flag used to disable "Repeat Last Effect"
57  kDontRepeatLast = 0x04,
58  // Flag used to disable "Select All during Repeat Generator Effect"
59  kRepeatGen = 0x08,
60  // Flag used for repeating Nyquist Prompt
61  kRepeatNyquistPrompt = 0x10,
62  };
63 
66  static EffectManager & Get();
67 
68 //
69 // public methods
70 //
71 // Used by the outside program to register the list of effects and retrieve
72 // them by index number, usually when the user selects one from a menu.
73 //
74 public:
75  EffectManager();
76  virtual ~EffectManager();
77 
79  // Here solely for the purpose of Nyquist Workbench until
80  // a better solution is devised.
81  const PluginID & RegisterEffect(Effect *f);
82  void UnregisterEffect(const PluginID & ID);
83 
84  TranslatableString GetEffectFamilyName(const PluginID & ID);
85  TranslatableString GetVendorName(const PluginID & ID);
86 
88  // Returns true on success.
89  bool DoAudacityCommand(const PluginID & ID,
90  const CommandContext &,
91  wxWindow *parent,
92  bool shouldPrompt = true );
93 
94  // Renamed from 'Effect' to 'Command' prior to moving out of this class.
95  ComponentInterfaceSymbol GetCommandSymbol(const PluginID & ID);
96  TranslatableString GetCommandName(const PluginID & ID);
97  CommandID GetCommandIdentifier(const PluginID & ID);
98  TranslatableString GetCommandDescription(const PluginID & ID);
99  wxString GetCommandUrl(const PluginID & ID);
100  TranslatableString GetCommandTip(const PluginID & ID);
101  // flags control which commands are included.
102  void GetCommandDefinition(const PluginID & ID, const CommandContext & context, int flags);
103  bool IsHidden(const PluginID & ID);
104 
106  bool SupportsAutomation(const PluginID & ID);
107  wxString GetEffectParameters(const PluginID & ID);
108  bool SetEffectParameters(const PluginID & ID, const wxString & params);
109  bool PromptUser( const PluginID & ID,
111  wxWindow &parent );
112  bool HasPresets(const PluginID & ID);
113  wxString GetPreset(const PluginID & ID, const wxString & params, wxWindow * parent);
114  wxString GetDefaultPreset(const PluginID & ID);
115 
116 private:
117  void SetBatchProcessing(const PluginID & ID, bool start);
120  void operator () (EffectManager *p) const
121  { if(p) p->SetBatchProcessing(mID, false); }
122  };
124  std::unique_ptr< EffectManager, UnsetBatchProcessing >;
125 public:
126  // RAII for the function above
128  {
129  SetBatchProcessing(ID, true); return BatchProcessingScope{ this, {ID} };
130  }
131 
133  void SetSkipStateFlag(bool flag);
134  bool GetSkipStateFlag();
135 
136  const PluginID & GetEffectByIdentifier(const CommandID & strTarget);
137 
139  Effect *GetEffect(const PluginID & ID);
140 
141 private:
142  AudacityCommand *GetAudacityCommand(const PluginID & ID);
143 
147 
149 
150  // Set true if we want to skip pushing state
151  // after processing at effect run time.
153 
154 #if defined(EXPERIMENTAL_EFFECTS_RACK)
155  friend class EffectRack;
156 #endif
157 
158 };
159 
160 #endif
EffectMap
std::unordered_map< wxString, Effect * > EffectMap
Definition: EffectManager.h:33
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
EffectManager::mHostEffects
EffectOwnerMap mHostEffects
Definition: EffectManager.h:146
EffectManager::mCommands
AudacityCommandMap mCommands
Definition: EffectManager.h:145
EffectManager::UnsetBatchProcessing::mID
PluginID mID
Definition: EffectManager.h:119
flag
static std::once_flag flag
Definition: WaveformView.cpp:1113
EffectManager::mSkipStateFlag
bool mSkipStateFlag
Definition: EffectManager.h:152
EffectManager::SetBatchProcessing
void SetBatchProcessing(const PluginID &ID, bool start)
Definition: EffectManager.cpp:688
EffectInterface.h
Effect
Base class for many of the effects in Audacity.
Definition: Effect.h:70
TrackList
A flat linked list of tracks supporting Add, Remove, Clear, and Contains, serialization of the list o...
Definition: Track.h:1263
AudacityCommandMap
std::unordered_map< wxString, AudacityCommand * > AudacityCommandMap
Definition: EffectManager.h:34
CommandMessageTarget
Interface for objects that can receive (string) messages from a command.
Definition: CommandTargets.h:75
EffectManager::mEffects
EffectMap mEffects
Definition: EffectManager.h:144
ComponentInterfaceSymbol
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
Definition: ComponentInterface.h:61
EffectManager
EffectManager is the class that handles effects and effect categories.
Definition: EffectManager.h:46
EffectManager::BatchProcessingScope
std::unique_ptr< EffectManager, UnsetBatchProcessing > BatchProcessingScope
Definition: EffectManager.h:124
factory
static RegisteredToolbarFactory factory
Definition: ControlToolBar.cpp:807
CommandContext
CommandContext provides additional information to an 'Apply()' command. It provides the project,...
Definition: CommandContext.h:22
EffectManager::UnsetBatchProcessing
Definition: EffectManager.h:118
EffectManager::mNumEffects
int mNumEffects
Definition: EffectManager.h:148
PluginID
wxString PluginID
Definition: EffectManager.h:30
AudacityCommand
Base class for command in Audacity.
Definition: AudacityCommand.h:41
Identifier.h
EffectClientInterface::EffectDialogFactory
std::function< wxDialog *(wxWindow &parent, EffectHostInterface *, EffectUIClientInterface *) > EffectDialogFactory
Definition: EffectInterface.h:149
TaggedIdentifier
Template generates different TaggedIdentifier classes that don't interconvert implicitly.
Definition: Identifier.h:113
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:112
params
EffectDistortion::Params params
Definition: Distortion.cpp:99
EffectManager::SetBatchProcessing
BatchProcessingScope SetBatchProcessing(const PluginID &ID)
Definition: EffectManager.h:127
EffectOwnerMap
std::unordered_map< wxString, std::shared_ptr< Effect > > EffectOwnerMap
Definition: EffectManager.h:35
NotifyingSelectedRegion
Definition: ViewInfo.h:42
SelectedRegion
Defines a selected portion of a project.
Definition: SelectedRegion.h:38