Audacity  2.2.2
EffectInterface.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  EffectInterface.h
6 
7  Leland Lucius
8 
9  Copyright (c) 2014, Audacity Team
10  All rights reserved.
11 
12  Redistribution and use in source and binary forms, with or without
13  modification, are permitted provided that the following conditions
14  are met:
15 
16  1. Redistributions of source code must retain the above copyright
17  notice, this list of conditions and the following disclaimer.
18 
19  2. Redistributions in binary form must reproduce the above copyright
20  notice, this list of conditions and the following disclaimer in the
21  documentation and/or other materials provided with the distribution.
22 
23  3. Neither the name of the copyright holder nor the names of its
24  contributors may be used to endorse or promote products derived from
25  this software without specific prior written permission.
26 
27  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31  COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
34  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
35  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
36  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
37  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38  POSSIBILITY OF SUCH DAMAGE.
39 
40 **********************************************************************/
41 
42 #ifndef __AUDACITY_EFFECTINTERFACE_H__
43 #define __AUDACITY_EFFECTINTERFACE_H__
44 
45 #include "audacity/Types.h"
48 #include "audacity/EffectAutomationParameters.h" // for command automation
49 
50 #include <wx/dialog.h>
51 
52 typedef enum EffectType
53 {
60 } EffectType;
61 
63 class ShuttleParams;
64 
65 /*************************************************************************************/
72 class AUDACITY_DLL_API ParamsInterface /* not final */
73 {
74 public:
75  virtual ~ParamsInterface() {};
76  // returns true if implemented.
77  virtual bool DefineParams( ShuttleParams & WXUNUSED(S) ){ return false;};
78 };
79 
80 /*************************************************************************************/
87 class AUDACITY_DLL_API CommandDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface
88 {
89 public:
91 };
92 
93 /*************************************************************************************/
101 class AUDACITY_DLL_API EffectDefinitionInterface /* not final */ : public IdentInterface, public ParamsInterface
102 {
103 public:
105 
106  // Type determines how it behaves.
107  virtual EffectType GetType() = 0;
108  // Classification determines which menu it appears in.
109  virtual EffectType GetClassification() { return GetType();};
110 
111  virtual IdentInterfaceSymbol GetFamilyId() = 0;
112 
113  // These should move to the "EffectClientInterface" class once all
114  // effects have been converted.
115  virtual bool IsInteractive() = 0;
116 
117  // I don't really like this, but couldn't think of a better way to force the
118  // effect to appear "above the line" in the menus.
119  virtual bool IsDefault() = 0;
120 
121  // This will go away when all Effects have been updated to the new
122  // interface.
123  virtual bool IsLegacy() = 0;
124 
125  // Whether the effect supports realtime previewing (while audio is playing).
126  virtual bool SupportsRealtime() = 0;
127 
128  // Can the effect be used without the UI.
129  virtual bool SupportsAutomation() = 0;
130 };
131 
134 
135 /*************************************************************************************/
144 class AUDACITY_DLL_API EffectHostInterface /* not final */ : public ConfigClientInterface
145 {
146 public:
147  virtual ~EffectHostInterface() {};
148 
149  virtual double GetDefaultDuration() = 0;
150  virtual double GetDuration() = 0;
151  virtual NumericFormatId GetDurationFormat() = 0;
152  virtual void SetDuration(double seconds) = 0;
153 
154  virtual bool Apply() = 0;
155  virtual void Preview() = 0;
156 
157  //
158  virtual wxDialog *CreateUI(wxWindow *parent, EffectUIClientInterface *client) = 0;
159 
160  // Preset handling
161  virtual wxString GetUserPresetsGroup(const wxString & name) = 0;
162  virtual wxString GetCurrentSettingsGroup() = 0;
163  virtual wxString GetFactoryDefaultsGroup() = 0;
164 };
165 
166 /*************************************************************************************/
175 class AUDACITY_DLL_API EffectClientInterface /* not final */ : public EffectDefinitionInterface
176 {
177 public:
179 
180  virtual bool SetHost(EffectHostInterface *host) = 0;
181 
182  virtual unsigned GetAudioInCount() = 0;
183  virtual unsigned GetAudioOutCount() = 0;
184 
185  virtual int GetMidiInCount() = 0;
186  virtual int GetMidiOutCount() = 0;
187 
188  virtual void SetSampleRate(double rate) = 0;
189  virtual size_t SetBlockSize(size_t maxBlockSize) = 0;
190 
191  virtual sampleCount GetLatency() = 0;
192  virtual size_t GetTailSize() = 0;
193 
194  virtual bool IsReady() = 0;
195  virtual bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) = 0;
196  // This may be called during stack unwinding:
197  virtual bool ProcessFinalize() /* noexcept */ = 0;
198  virtual size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) = 0;
199 
200  virtual bool RealtimeInitialize() = 0;
201  virtual bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) = 0;
202  virtual bool RealtimeFinalize() = 0;
203  virtual bool RealtimeSuspend() = 0;
204  virtual bool RealtimeResume() = 0;
205  virtual bool RealtimeProcessStart() = 0;
206  virtual size_t RealtimeProcess(int group, float **inBuf, float **outBuf, size_t numSamples) = 0;
207  virtual bool RealtimeProcessEnd() = 0;
208 
209  virtual bool ShowInterface(wxWindow *parent, bool forceModal = false) = 0;
210  // Some effects will use define params to define what parameters they take.
211  // If they do, they won't need to implement Get or SetAutomation parameters.
212  // since the Effect class can do it. Or at least that is how things happen
213  // in AudacityCommand. IF we do the same in class Effect, then Effect maybe
214  // should derive by some route from AudacityCommand to pick up that
215  // functionality.
216  //virtual bool DefineParams( ShuttleParams & S){ return false;};
217  virtual bool GetAutomationParameters(CommandParameters & parms) = 0;
218  virtual bool SetAutomationParameters(CommandParameters & parms) = 0;
219 
220  virtual bool LoadUserPreset(const wxString & name) = 0;
221  virtual bool SaveUserPreset(const wxString & name) = 0;
222 
223  virtual wxArrayString GetFactoryPresets() = 0;
224  virtual bool LoadFactoryPreset(int id) = 0;
225  virtual bool LoadFactoryDefaults() = 0;
226 };
227 
228 /*************************************************************************************/
237 class AUDACITY_DLL_API EffectUIHostInterface
238 {
239 public:
241 };
242 
243 /*************************************************************************************/
251 class AUDACITY_DLL_API EffectUIClientInterface /* not final */
252 {
253 public:
255 
256  virtual void SetHostUI(EffectUIHostInterface *host) = 0;
257  virtual bool IsGraphicalUI() = 0;
258  virtual bool PopulateUI(wxWindow *parent) = 0;
259  virtual bool ValidateUI() = 0;
260  virtual bool HideUI() = 0;
261  virtual bool CloseUI() = 0;
262 
263  virtual bool CanExportPresets() = 0;
264  virtual void ExportPresets() = 0;
265  virtual void ImportPresets() = 0;
266 
267  virtual bool HasOptions() = 0;
268  virtual void ShowOptions() = 0;
269 };
270 
271 
272 /*************************************************************************************/
280 class AUDACITY_DLL_API EffectManagerInterface
281 {
282 public:
284 
285  virtual void FindFilesInPathList(const wxString & pattern,
286  const wxArrayString & pathList,
287  wxArrayString & files,
288  int searchFlags) = 0;
289 };
290 
291 #endif // __AUDACITY_EFFECTINTERFACE_H__
UNUSED. EffectManagerInterface provides a single function to find files matching a pattern in a list...
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values...
virtual ~EffectHostInterface()
ConfigClientInterface is an unholy get/set configuration class, which differentiates between private ...
virtual ~EffectUIHostInterface()
Shuttle that deals with parameters. This is a base class with lots of virtual functions that do nothi...
Definition: Shuttle.h:60
virtual ~EffectClientInterface()
EffectDefinitionInterface is a CommandDefinitionInterface that additionally tracks flag-functions for...
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
virtual EffectType GetClassification()
virtual ~ParamsInterface()
CommandDefinitionInterface is an IdentInterface (to name the command) along with a DefineParameters v...
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
enum ChannelName * ChannelNames
ParamsInterface provides a DefineParameters virtual function, that defines the parameters of the comm...
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
EffectType
const wxChar * name
Definition: Distortion.cpp:94
virtual bool DefineParams(ShuttleParams &WXUNUSED(S))
EffectClientInterface provides the ident interface to Effect, and is what makes Effect into a plug-in...
IdentInterface provides name / vendor / version functions to identify plugins. It is what makes a cla...
EffectUIHostInterface has nothing in it. It is provided so that an Effect can call SetHostUI passing ...