Audacity  2.2.0
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 WX_DEFINE_ARRAY_PTR(LADSPA_Handle, LadspaSlaveArray);
38 
39 class LadspaEffectMeter;
40 
41 class LadspaEffect final : public wxEvtHandler,
42  public EffectClientInterface,
43  public EffectUIClientInterface
44 {
45 public:
46  LadspaEffect(const wxString & path, int index);
47  virtual ~LadspaEffect();
48 
49  // IdentInterface implementation
50 
51  wxString GetPath() override;
52  wxString GetSymbol() override;
53  wxString GetName() override;
54  wxString GetVendor() override;
55  wxString GetVersion() override;
56  wxString GetDescription() override;
57 
58  // EffectIdentInterface implementation
59 
60  EffectType GetType() override;
61  wxString GetFamily() 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(EffectAutomationParameters & parms) override;
104  bool SetAutomationParameters(EffectAutomationParameters & 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;
150  EffectHostInterface *mHost;
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  LadspaSlaveArray mSlaves;
183 
184  EffectUIHostInterface *mUIHost;
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  wxString GetSymbol() override;
216  wxString GetName() override;
217  wxString GetVendor() override;
218  wxString GetVersion() override;
219  wxString GetDescription() override;
220 
221  // ModuleInterface implementation
222 
223  bool Initialize() override;
224  void Terminate() override;
225 
226  bool AutoRegisterPlugins(PluginManagerInterface & pm) override;
227  wxArrayString FindPlugins(PluginManagerInterface & pm) override;
228  bool RegisterPlugin(PluginManagerInterface & pm, const wxString & path) override;
229 
230  bool IsPluginValid(const wxString & path, bool bFast) override;
231 
232  IdentInterface *CreateInstance(const wxString & path) override;
233  void DeleteInstance(IdentInterface *instance) override;
234 
235  // LadspaEffectModule implementation
236 
237  wxArrayString GetSearchPaths();
238 
239 private:
240  ModuleManagerInterface *mModMan;
241  wxString mPath;
242 };
243 
bool RealtimeProcessEnd() override
Definition: LadspaEffect.cpp:990
bool LoadFactoryPreset(int id) override
Definition: LadspaEffect.cpp:1092
void * LADSPA_Handle
Definition: ladspa.h:363
bool HasOptions() override
Definition: LadspaEffect.cpp:1487
void ShowOptions() override
Definition: LadspaEffect.cpp:1492
An Effect that calls up a LADSPA plug in, i.e. many possible effects from this one class...
Definition: LadspaEffect.h:41
bool RealtimeAddProcessor(unsigned numChannels, float sampleRate) override
Definition: LadspaEffect.cpp:931
unsigned mAudioIns
Definition: LadspaEffect.h:166
EffectHostInterface * mHost
Definition: LadspaEffect.h:150
LadspaSlaveArray mSlaves
Definition: LadspaEffect.h:182
EffectType GetType() override
Definition: LadspaEffect.cpp:607
size_t ProcessBlock(float **inBlock, float **outBlock, size_t blockLen) override
Definition: LadspaEffect.cpp:907
bool CanExportPresets() override
Definition: LadspaEffect.cpp:1474
bool SaveParameters(const wxString &group)
Definition: LadspaEffect.cpp:1570
ArrayOf< LadspaEffectMeter * > mMeters
Definition: LadspaEffect.h:193
size_t SetBlockSize(size_t maxBlockSize) override
Definition: LadspaEffect.cpp:848
bool ProcessFinalize() override
Definition: LadspaEffect.cpp:894
void OnTextCtrl(wxCommandEvent &evt)
Definition: LadspaEffect.cpp:1673
wxString GetDescription() override
Definition: LadspaEffect.cpp:598
bool IsGraphicalUI() override
Definition: LadspaEffect.cpp:1433
void ImportPresets() override
Definition: LadspaEffect.cpp:1483
bool mInteractive
Definition: LadspaEffect.h:164
LadspaEffect(const wxString &path, int index)
Definition: LadspaEffect.cpp:540
wxString GetVersion() override
Definition: LadspaEffect.cpp:593
int mIndex
Definition: LadspaEffect.h:149
wxString GetSymbol() override
Definition: LadspaEffect.cpp:578
ArrayOf< unsigned long > mInputPorts
Definition: LadspaEffect.h:167
bool HideUI() override
Definition: LadspaEffect.cpp:1453
ArrayOf< wxStaticText * > mLabels
Definition: LadspaEffect.h:191
wxArrayString GetFactoryPresets() override
Definition: LadspaEffect.cpp:1087
wxString pluginName
Definition: LadspaEffect.h:155
bool mReady
Definition: LadspaEffect.h:157
int GetMidiInCount() override
Definition: LadspaEffect.cpp:833
wxString GetVendor() override
Definition: LadspaEffect.cpp:588
bool mLatencyDone
Definition: LadspaEffect.h:179
void SetSampleRate(double rate) override
Definition: LadspaEffect.cpp:843
ArrayOf< wxSlider * > mSliders
Definition: LadspaEffect.h:189
bool RealtimeSuspend() override
Definition: LadspaEffect.cpp:955
ArrayOf< wxTextCtrl * > mFields
Definition: LadspaEffect.h:190
EffectUIHostInterface * mUIHost
Definition: LadspaEffect.h:184
void SetHostUI(EffectUIHostInterface *host) override
Definition: LadspaEffect.cpp:1113
wxString mPath
Definition: LadspaEffect.h:148
const LADSPA_Descriptor * mData
Definition: LadspaEffect.h:153
unsigned GetAudioInCount() override
Definition: LadspaEffect.cpp:823
LADSPA_Handle InitInstance(float sampleRate)
Definition: LadspaEffect.cpp:1587
size_t GetTailSize() override
Definition: LadspaEffect.cpp:866
void Unload()
Definition: LadspaEffect.cpp:1545
sampleCount GetLatency() override
Definition: LadspaEffect.cpp:855
bool RealtimeFinalize() override
Definition: LadspaEffect.cpp:944
void FreeInstance(LADSPA_Handle handle)
Definition: LadspaEffect.cpp:1620
void RefreshControls(bool outputOnly=false)
Definition: LadspaEffect.cpp:1706
int GetMidiOutCount() override
Definition: LadspaEffect.cpp:838
ArrayOf< wxCheckBox * > mToggles
Definition: LadspaEffect.h:192
Floats mInputControls
Definition: LadspaEffect.h:173
size_t mBlockSize
Definition: LadspaEffect.h:162
wxString mPath
Definition: LadspaEffect.h:241
bool RealtimeResume() override
Definition: LadspaEffect.cpp:960
virtual ~LadspaEffect()
Definition: LadspaEffect.cpp:565
wxString GetName() override
Definition: LadspaEffect.cpp:583
Definition: LadspaEffect.cpp:434
unsigned GetAudioOutCount() override
Definition: LadspaEffect.cpp:828
bool SupportsAutomation() override
Definition: LadspaEffect.cpp:652
bool RealtimeProcessStart() override
Definition: LadspaEffect.cpp:965
bool LoadUserPreset(const wxString &name) override
Definition: LadspaEffect.cpp:1070
bool SetAutomationParameters(EffectAutomationParameters &parms) override
Definition: LadspaEffect.cpp:1048
size_t RealtimeProcess(int group, float **inbuf, float **outbuf, size_t numSamples) override
Definition: LadspaEffect.cpp:970
Definition: NumericTextCtrl.h:141
bool Load()
Definition: LadspaEffect.cpp:1506
wxString GetPath() override
Definition: LadspaEffect.cpp:573
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)
Definition: LadspaEffect.cpp:1553
ModuleManagerInterface * mModMan
Definition: LadspaEffect.h:240
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
bool IsReady() override
Definition: LadspaEffect.cpp:871
friend class LadspaEffectsModule
Definition: LadspaEffect.h:197
double mSampleRate
Definition: LadspaEffect.h:161
bool RealtimeInitialize() override
Definition: LadspaEffect.cpp:926
wxString GetFamily() override
Definition: LadspaEffect.cpp:627
bool SaveUserPreset(const wxString &name) override
Definition: LadspaEffect.cpp:1082
void OnCheckBox(wxCommandEvent &evt)
Definition: LadspaEffect.cpp:1630
void ExportPresets() override
Definition: LadspaEffect.cpp:1479
LADSPA_Handle mMaster
Definition: LadspaEffect.h:159
bool SetHost(EffectHostInterface *host) override
Definition: LadspaEffect.cpp:661
int mLatencyPort
Definition: LadspaEffect.h:178
bool GetAutomationParameters(EffectAutomationParameters &parms) override
Definition: LadspaEffect.cpp:1030
bool IsInteractive() override
Definition: LadspaEffect.cpp:632
int mNumOutputControls
Definition: LadspaEffect.h:174
bool IsDefault() override
Definition: LadspaEffect.cpp:637
bool ShowInterface(wxWindow *parent, bool forceModal=false) override
Definition: LadspaEffect.cpp:995
wxDynamicLibrary mLib
Definition: LadspaEffect.h:152
bool SupportsRealtime() override
Definition: LadspaEffect.cpp:647
WX_DEFINE_ARRAY_PTR(LADSPA_Handle, LadspaSlaveArray)
bool mUseLatency
Definition: LadspaEffect.h:177
bool CloseUI() override
Definition: LadspaEffect.cpp:1458
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap=NULL) override
Definition: LadspaEffect.cpp:876
bool ValidateUI() override
Definition: LadspaEffect.cpp:1438
bool PopulateUI(wxWindow *parent) override
Definition: LadspaEffect.cpp:1118
bool IsLegacy() override
Definition: LadspaEffect.cpp:642
Definition: LadspaEffect.h:206
Floats mOutputControls
Definition: LadspaEffect.h:175
bool LoadFactoryDefaults() override
Definition: LadspaEffect.cpp:1097
int mNumInputControls
Definition: LadspaEffect.h:172
void OnSlider(wxCommandEvent &evt)
Definition: LadspaEffect.cpp:1637
ArrayOf< unsigned long > mOutputPorts
Definition: LadspaEffect.h:170