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 
19 #include "audacity/EffectInterface.h"
20 #include "audacity/ModuleInterface.h"
21 #include "audacity/PluginInterface.h"
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 #define LADSPAEFFECTS_FAMILY wxT("LADSPA")
30 
32 //
33 // LadspaEffect
34 //
36 
37 class LadspaEffectMeter;
38 
39 class LadspaEffect final : public wxEvtHandler,
40  public EffectClientInterface,
41  public EffectUIClientInterface
42 {
43 public:
44  LadspaEffect(const wxString & path, int index);
45  virtual ~LadspaEffect();
46 
47  // IdentInterface implementation
48 
49  wxString GetPath() override;
50  wxString GetSymbol() override;
51  wxString GetName() override;
52  wxString GetVendor() override;
53  wxString GetVersion() override;
54  wxString GetDescription() override;
55 
56  // EffectIdentInterface implementation
57 
58  EffectType GetType() override;
59  wxString GetFamilyId() override;
60  wxString GetFamilyName() override;
61  bool IsInteractive() override;
62  bool IsDefault() override;
63  bool IsLegacy() override;
64  bool SupportsRealtime() override;
65  bool SupportsAutomation() override;
66 
67  // EffectClientInterface implementation
68 
69  bool SetHost(EffectHostInterface *host) override;
70 
71  unsigned GetAudioInCount() override;
72  unsigned GetAudioOutCount() override;
73 
74  int GetMidiInCount() override;
75  int GetMidiOutCount() override;
76 
77  void SetSampleRate(double rate) override;
78  size_t SetBlockSize(size_t maxBlockSize) override;
79 
80  sampleCount GetLatency() override;
81  size_t GetTailSize() override;
82 
83  bool IsReady() override;
84  bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
85  bool ProcessFinalize() override;
86  size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override;
87 
88  bool RealtimeInitialize() override;
89  bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override;
90  bool RealtimeFinalize() override;
91  bool RealtimeSuspend() override;
92  bool RealtimeResume() override;
93  bool RealtimeProcessStart() override;
94  size_t RealtimeProcess(int group,
95  float **inbuf,
96  float **outbuf,
97  size_t numSamples) override;
98  bool RealtimeProcessEnd() override;
99 
100  bool ShowInterface(wxWindow *parent, bool forceModal = false) override;
101 
102  bool GetAutomationParameters(EffectAutomationParameters & parms) override;
103  bool SetAutomationParameters(EffectAutomationParameters & parms) override;
104 
105  bool LoadUserPreset(const wxString & name) override;
106  bool SaveUserPreset(const wxString & name) override;
107 
108  wxArrayString GetFactoryPresets() override;
109  bool LoadFactoryPreset(int id) override;
110  bool LoadFactoryDefaults() override;
111 
112  // EffectUIClientInterface implementation
113 
114  void SetHostUI(EffectUIHostInterface *host) override;
115  bool PopulateUI(wxWindow *parent) override;
116  bool IsGraphicalUI() override;
117  bool ValidateUI() override;
118  bool HideUI() override;
119  bool CloseUI() override;
120 
121  bool CanExportPresets() override;
122  void ExportPresets() override;
123  void ImportPresets() override;
124 
125  bool HasOptions() override;
126  void ShowOptions() override;
127 
128  // LadspaEffect implementation
129 
130 private:
131  bool Load();
132  void Unload();
133 
134  bool LoadParameters(const wxString & group);
135  bool SaveParameters(const wxString & group);
136 
137  LADSPA_Handle InitInstance(float sampleRate);
138  void FreeInstance(LADSPA_Handle handle);
139 
140  void OnCheckBox(wxCommandEvent & evt);
141  void OnSlider(wxCommandEvent & evt);
142  void OnTextCtrl(wxCommandEvent & evt);
143  void RefreshControls(bool outputOnly = false);
144 
145 private:
146 
147  wxString mPath;
148  int mIndex;
149  EffectHostInterface *mHost;
150 
151  wxDynamicLibrary mLib;
153 
154  wxString pluginName;
155 
156  bool mReady;
157 
159 
160  double mSampleRate;
161  size_t mBlockSize;
162 
164 
165  unsigned mAudioIns;
167 
168  unsigned mAudioOuts;
170 
175 
179 
180  // Realtime processing
181  std::vector<LADSPA_Handle> mSlaves;
182 
183  EffectUIHostInterface *mUIHost;
184 
186  wxDialog *mDialog;
187  wxWindow *mParent;
193 
194  DECLARE_EVENT_TABLE()
195 
196  friend class LadspaEffectsModule;
197 };
198 
200 //
201 // LadspaEffectsModule
202 //
204 
205 class LadspaEffectsModule final : public ModuleInterface
206 {
207 public:
208  LadspaEffectsModule(ModuleManagerInterface *moduleManager, const wxString *path);
209  virtual ~LadspaEffectsModule();
210 
211  // IdentInterface implementation
212 
213  wxString GetPath() override;
214  wxString GetSymbol() override;
215  wxString GetName() override;
216  wxString 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:
245  ModuleManagerInterface *mModMan;
246  wxString mPath;
247 };
248 
bool RealtimeProcessEnd() override
bool LoadFactoryPreset(int id) override
void * LADSPA_Handle
Definition: ladspa.h:363
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:39
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
unsigned mAudioIns
Definition: LadspaEffect.h:165
EffectHostInterface * mHost
Definition: LadspaEffect.h:149
wxString GetFamilyName() override
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:192
size_t SetBlockSize(size_t maxBlockSize) override
bool ProcessFinalize() override
void OnTextCtrl(wxCommandEvent &evt)
wxString GetDescription() override
bool IsGraphicalUI() override
void ImportPresets() override
LadspaEffect(const wxString &path, int index)
wxString GetVersion() override
wxString GetSymbol() override
ArrayOf< unsigned long > mInputPorts
Definition: LadspaEffect.h:166
bool HideUI() override
ArrayOf< wxStaticText * > mLabels
Definition: LadspaEffect.h:190
wxArrayString GetFactoryPresets() override
wxString pluginName
Definition: LadspaEffect.h:154
int GetMidiInCount() override
wxString GetVendor() override
void SetSampleRate(double rate) override
ArrayOf< wxSlider * > mSliders
Definition: LadspaEffect.h:188
bool RealtimeSuspend() override
ArrayOf< wxTextCtrl * > mFields
Definition: LadspaEffect.h:189
EffectUIHostInterface * mUIHost
Definition: LadspaEffect.h:183
void SetHostUI(EffectUIHostInterface *host) override
wxString mPath
Definition: LadspaEffect.h:147
const LADSPA_Descriptor * mData
Definition: LadspaEffect.h:152
unsigned GetAudioInCount() override
LADSPA_Handle InitInstance(float sampleRate)
size_t GetTailSize() override
sampleCount GetLatency() override
bool RealtimeFinalize() override
wxString GetFamilyId() override
void FreeInstance(LADSPA_Handle handle)
void RefreshControls(bool outputOnly=false)
int GetMidiOutCount() override
ArrayOf< wxCheckBox * > mToggles
Definition: LadspaEffect.h:191
Floats mInputControls
Definition: LadspaEffect.h:172
size_t mBlockSize
Definition: LadspaEffect.h:161
bool RealtimeResume() override
virtual ~LadspaEffect()
wxString GetName() override
unsigned GetAudioOutCount() override
bool SupportsAutomation() override
bool RealtimeProcessStart() override
bool LoadUserPreset(const wxString &name) override
bool SetAutomationParameters(EffectAutomationParameters &parms) override
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
wxString GetPath() override
NumericTextCtrl * mDuration
Definition: LadspaEffect.h:185
_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
unsigned mAudioOuts
Definition: LadspaEffect.h:168
const wxChar * name
Definition: Distortion.cpp:94
wxWindow * mParent
Definition: LadspaEffect.h:187
wxDialog * mDialog
Definition: LadspaEffect.h:186
bool IsReady() override
friend class LadspaEffectsModule
Definition: LadspaEffect.h:196
double mSampleRate
Definition: LadspaEffect.h:160
bool RealtimeInitialize() override
bool SaveUserPreset(const wxString &name) override
void OnCheckBox(wxCommandEvent &evt)
void ExportPresets() override
LADSPA_Handle mMaster
Definition: LadspaEffect.h:158
bool SetHost(EffectHostInterface *host) override
bool GetAutomationParameters(EffectAutomationParameters &parms) override
bool IsInteractive() override
int mNumOutputControls
Definition: LadspaEffect.h:173
bool IsDefault() override
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
wxDynamicLibrary mLib
Definition: LadspaEffect.h:151
bool SupportsRealtime() override
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:181
Floats mOutputControls
Definition: LadspaEffect.h:174
bool LoadFactoryDefaults() override
int mNumInputControls
Definition: LadspaEffect.h:171
void OnSlider(wxCommandEvent &evt)
ArrayOf< unsigned long > mOutputPorts
Definition: LadspaEffect.h:169