Audacity  2.2.2
LadspaEffect.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3  Audacity: A Digital Audio Editor
4 
5  LadspaEffect.h
6 
7  Dominic Mazzoni
8 
9 **********************************************************************/
10 
11 class wxSlider;
12 class wxStaticText;
13 class wxTextCtrl;
14 class wxCheckBox;
15 
16 #include "../../MemoryX.h"
17 #include <wx/dialog.h>
18 
22 
23 #include "../../widgets/NumericTextCtrl.h"
24 
25 #include "ladspa.h"
26 #include "../../SampleFormat.h"
27 
28 #define LADSPAEFFECTS_VERSION wxT("1.0.0.0")
29 /* i8n-hint: abbreviates "Linux Audio Developer's Simple Plugin API"
30  (Application programming interface)
31  */
32 #define LADSPAEFFECTS_FAMILY XO("LADSPA")
33 
35 //
36 // LadspaEffect
37 //
39 
40 class LadspaEffectMeter;
41 
42 class LadspaEffect final : public wxEvtHandler,
43  public EffectClientInterface,
45 {
46 public:
47  LadspaEffect(const wxString & path, int index);
48  virtual ~LadspaEffect();
49 
50  // IdentInterface implementation
51 
52  wxString GetPath() override;
55  wxString GetVersion() override;
56  wxString GetDescription() override;
57 
58  // EffectDefinitionInterface implementation
59 
60  EffectType GetType() override;
62  bool IsInteractive() override;
63  bool IsDefault() override;
64  bool IsLegacy() override;
65  bool SupportsRealtime() override;
66  bool SupportsAutomation() override;
67 
68  // EffectClientInterface implementation
69 
70  bool SetHost(EffectHostInterface *host) override;
71 
72  unsigned GetAudioInCount() override;
73  unsigned GetAudioOutCount() override;
74 
75  int GetMidiInCount() override;
76  int GetMidiOutCount() override;
77 
78  void SetSampleRate(double rate) override;
79  size_t SetBlockSize(size_t maxBlockSize) override;
80 
81  sampleCount GetLatency() override;
82  size_t GetTailSize() override;
83 
84  bool IsReady() override;
85  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
86  bool ProcessFinalize() override;
87  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
88 
89  bool RealtimeInitialize() override;
90  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
91  bool RealtimeFinalize() override;
92  bool RealtimeSuspend() override;
93  bool RealtimeResume() override;
94  bool RealtimeProcessStart() override;
95  size_t RealtimeProcess(int group,
96  float **inbuf,
97  float **outbuf,
98  size_t numSamples) override;
99  bool RealtimeProcessEnd() override;
100 
101  bool ShowInterface(wxWindow *parent, bool forceModal = false) override;
102 
103  bool GetAutomationParameters(CommandParameters & parms) override;
104  bool SetAutomationParameters(CommandParameters & parms) override;
105 
106  bool LoadUserPreset(const wxString & name) override;
107  bool SaveUserPreset(const wxString & name) override;
108 
109  wxArrayString GetFactoryPresets() override;
110  bool LoadFactoryPreset(int id) override;
111  bool LoadFactoryDefaults() override;
112 
113  // EffectUIClientInterface implementation
114 
115  void SetHostUI(EffectUIHostInterface *host) override;
116  bool PopulateUI(wxWindow *parent) override;
117  bool IsGraphicalUI() override;
118  bool ValidateUI() override;
119  bool HideUI() override;
120  bool CloseUI() override;
121 
122  bool CanExportPresets() override;
123  void ExportPresets() override;
124  void ImportPresets() override;
125 
126  bool HasOptions() override;
127  void ShowOptions() override;
128 
129  // LadspaEffect implementation
130 
131 private:
132  bool Load();
133  void Unload();
134 
135  bool LoadParameters(const wxString & group);
136  bool SaveParameters(const wxString & group);
137 
138  LADSPA_Handle InitInstance(float sampleRate);
139  void FreeInstance(LADSPA_Handle handle);
140 
141  void OnCheckBox(wxCommandEvent & evt);
142  void OnSlider(wxCommandEvent & evt);
143  void OnTextCtrl(wxCommandEvent & evt);
144  void RefreshControls(bool outputOnly = false);
145 
146 private:
147 
148  wxString mPath;
149  int mIndex;
151 
152  wxDynamicLibrary mLib;
154 
155  wxString pluginName;
156 
157  bool mReady;
158 
160 
161  double mSampleRate;
162  size_t mBlockSize;
163 
165 
166  unsigned mAudioIns;
168 
169  unsigned mAudioOuts;
171 
176 
180 
181  // Realtime processing
182  std::vector<LADSPA_Handle> mSlaves;
183 
185 
187  wxDialog *mDialog;
188  wxWindow *mParent;
194 
195  DECLARE_EVENT_TABLE()
196 
197  friend class LadspaEffectsModule;
198 };
199 
201 //
202 // LadspaEffectsModule
203 //
205 
206 class LadspaEffectsModule final : public ModuleInterface
207 {
208 public:
209  LadspaEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
210  virtual ~LadspaEffectsModule();
211 
212  // IdentInterface implementation
213 
214  wxString GetPath() override;
215  IdentInterfaceSymbol GetSymbol() override;
216  IdentInterfaceSymbol GetVendor() override;
217  wxString GetVersion() override;
218  wxString GetDescription() override;
219 
220  // ModuleInterface implementation
221 
222  bool Initialize() override;
223  void Terminate() override;
224 
225  wxArrayString FileExtensions() override;
226  wxString InstallPath() override;
227 
228  bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
229  wxArrayString FindPluginPaths(PluginManagerInterface & pm) override;
230  unsigned DiscoverPluginsAtPath(
231  const wxString & path, wxString &errMsg,
232  const RegistrationCallback &callback)
233  override;
234 
235  bool IsPluginValid(const wxString & path, bool bFast) override;
236 
237  IdentInterface *CreateInstance(const wxString & path) override;
238  void DeleteInstance(IdentInterface *instance) override;
239 
240  // LadspaEffectModule implementation
241 
242  wxArrayString GetSearchPaths();
243 
244 private:
246  wxString mPath;
247 };
248 
bool RealtimeProcessEnd() override
IdentInterfaceSymbol GetVendor() override
bool LoadFactoryPreset(int id) override
void * LADSPA_Handle
Definition: ladspa.h:363
IdentInterfaceSymbol GetSymbol() override
EffectUIClientInterface is an abstract base class to populate a UI and validate UI values...
bool HasOptions() override
void ShowOptions() override
An Effect that calls up a LADSPA plug in, i.e. many possible effects from this one class...
Definition: LadspaEffect.h:42
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
unsigned mAudioIns
Definition: LadspaEffect.h:166
EffectHostInterface * mHost
Definition: LadspaEffect.h:150
EffectType GetType() override
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
bool CanExportPresets() override
bool SaveParameters(const wxString &group)
ArrayOf< LadspaEffectMeter * > mMeters
Definition: LadspaEffect.h:193
size_t SetBlockSize(size_t maxBlockSize) override
bool ProcessFinalize() override
void OnTextCtrl(wxCommandEvent &evt)
wxString GetDescription() override
bool IsGraphicalUI() override
bool GetAutomationParameters(CommandParameters &parms) override
void ImportPresets() override
LadspaEffect(const wxString &path, int index)
wxString GetVersion() override
ArrayOf< unsigned long > mInputPorts
Definition: LadspaEffect.h:167
bool HideUI() override
ArrayOf< wxStaticText * > mLabels
Definition: LadspaEffect.h:191
wxArrayString GetFactoryPresets() override
wxString pluginName
Definition: LadspaEffect.h:155
int GetMidiInCount() override
void SetSampleRate(double rate) override
ArrayOf< wxSlider * > mSliders
Definition: LadspaEffect.h:189
bool RealtimeSuspend() override
ArrayOf< wxTextCtrl * > mFields
Definition: LadspaEffect.h:190
IdentInterfaceSymbol GetFamilyId() override
EffectUIHostInterface * mUIHost
Definition: LadspaEffect.h:184
void SetHostUI(EffectUIHostInterface *host) override
wxString mPath
Definition: LadspaEffect.h:148
const LADSPA_Descriptor * mData
Definition: LadspaEffect.h:153
unsigned GetAudioInCount() override
LADSPA_Handle InitInstance(float sampleRate)
size_t GetTailSize() override
sampleCount GetLatency() override
bool RealtimeFinalize() override
void FreeInstance(LADSPA_Handle handle)
void RefreshControls(bool outputOnly=false)
int GetMidiOutCount() override
ArrayOf< wxCheckBox * > mToggles
Definition: LadspaEffect.h:192
CommandParameters, derived from wxFileConfig, is essentially doing the same things as the Shuttle cla...
Floats mInputControls
Definition: LadspaEffect.h:173
size_t mBlockSize
Definition: LadspaEffect.h:162
bool RealtimeResume() override
virtual ~LadspaEffect()
unsigned GetAudioOutCount() override
bool SupportsAutomation() override
bool RealtimeProcessStart() override
bool LoadUserPreset(const wxString &name) override
IdentInterfaceSymbol pairs a persistent string identifier used internally with an optional...
enum ChannelName * ChannelNames
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
wxString GetPath() override
NumericTextCtrl * mDuration
Definition: LadspaEffect.h:186
_LADSPA_Descriptor is a structure that provides the API to a LADSPA (Linux Audio Plugin Architecture)...
Definition: ladspa.h:373
bool LoadParameters(const wxString &group)
ModuleManagerInterface * mModMan
Definition: LadspaEffect.h:245
EffectHostInterface is a decorator of a EffectUIClientInterface. It adds virtual (abstract) functions...
EffectType
unsigned mAudioOuts
Definition: LadspaEffect.h:169
const wxChar * name
Definition: Distortion.cpp:94
wxWindow * mParent
Definition: LadspaEffect.h:188
wxDialog * mDialog
Definition: LadspaEffect.h:187
std::function< const PluginID &(ModuleInterface *, IdentInterface *) > RegistrationCallback
bool IsReady() override
friend class LadspaEffectsModule
Definition: LadspaEffect.h:197
double mSampleRate
Definition: LadspaEffect.h:161
bool RealtimeInitialize() override
EffectClientInterface provides the ident interface to Effect, and is what makes Effect into a plug-in...
bool SetAutomationParameters(CommandParameters &parms) override
bool SaveUserPreset(const wxString &name) override
void OnCheckBox(wxCommandEvent &evt)
void ExportPresets() override
LADSPA_Handle mMaster
Definition: LadspaEffect.h:159
bool SetHost(EffectHostInterface *host) override
bool IsInteractive() override
int mNumOutputControls
Definition: LadspaEffect.h:174
bool IsDefault() override
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
wxDynamicLibrary mLib
Definition: LadspaEffect.h:152
bool SupportsRealtime() override
IdentInterface provides name / vendor / version functions to identify plugins. It is what makes a cla...
bool CloseUI() override
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
bool ValidateUI() override
bool PopulateUI(wxWindow *parent) override
bool IsLegacy() override
std::vector< LADSPA_Handle > mSlaves
Definition: LadspaEffect.h:182
Floats mOutputControls
Definition: LadspaEffect.h:175
bool LoadFactoryDefaults() override
EffectUIHostInterface has nothing in it. It is provided so that an Effect can call SetHostUI passing ...
int mNumInputControls
Definition: LadspaEffect.h:172
void OnSlider(wxCommandEvent &evt)
ArrayOf< unsigned long > mOutputPorts
Definition: LadspaEffect.h:170