Async 1.8.0
AsyncAudioLADSPAPlugin.h
Go to the documentation of this file.
1
31#ifndef ASYNC_AUDIO_LADSPA_PLUGIN_INCLUDED
32#define ASYNC_AUDIO_LADSPA_PLUGIN_INCLUDED
33
34
35/****************************************************************************
36 *
37 * System Includes
38 *
39 ****************************************************************************/
40
41extern "C" {
42 #include <ladspa.h>
43};
44
45#include <string>
46#include <map>
47#include <memory>
48#include <limits>
49
50
51/****************************************************************************
52 *
53 * Project Includes
54 *
55 ****************************************************************************/
56
57#include <AsyncAudioProcessor.h>
58
59
60/****************************************************************************
61 *
62 * Local Includes
63 *
64 ****************************************************************************/
65
66
67
68/****************************************************************************
69 *
70 * Forward declarations
71 *
72 ****************************************************************************/
73
74
75
76/****************************************************************************
77 *
78 * Namespace
79 *
80 ****************************************************************************/
81
82namespace Async
83{
84
85
86/****************************************************************************
87 *
88 * Forward declarations of classes inside of the declared namespace
89 *
90 ****************************************************************************/
91
92
93
94/****************************************************************************
95 *
96 * Defines & typedefs
97 *
98 ****************************************************************************/
99
100
101
102/****************************************************************************
103 *
104 * Exported Global Variables
105 *
106 ****************************************************************************/
107
108
109
110/****************************************************************************
111 *
112 * Class definitions
113 *
114 ****************************************************************************/
115
126{
127 public:
128 using PortNumber = decltype(LADSPA_Descriptor::PortCount);
129 using PluginIndex = unsigned long;
130 using UniqueID = unsigned long;
131
132 constexpr static PortNumber npos = std::numeric_limits<PortNumber>::max();
133
146 static bool findPluginsInDir(std::string dir);
147
161 static bool findPlugins(void);
162
172 AudioLADSPAPlugin(const std::string& path, PluginIndex index)
173 : m_path(path), m_index(index) {}
174
184
191 AudioLADSPAPlugin(const std::string& label);
192
197
202
207
219 bool initialize(void);
220
227
233 bool setControl(PortNumber portno, LADSPA_Data val);
234
242 void activate(void);
243
250 void deactivate(void);
251
256 std::string path(void) const { return m_path; }
257
264 UniqueID uniqueId(void) const { return m_desc->UniqueID; }
265
272 std::string label(void) const { return m_desc->Label; }
273
280 std::string name(void) const { return m_desc->Name; }
281
286 std::string maker(void) const { return m_desc->Maker; }
287
292 std::string copyright(void) const { return m_desc->Copyright; }
293
298 PortNumber portCount(void) const { return m_desc->PortCount; }
299
304 bool portIsControl(PortNumber portno) const;
305
310 bool portIsAudio(PortNumber portno) const;
311
316 bool portIsInput(PortNumber portno) const;
317
322 bool portIsOutput(PortNumber portno) const;
323
327 void print(const std::string& prefix="");
328
329 protected:
341 virtual void processSamples(float *dest, const float *src,
342 int count) override;
343
344 private:
345 struct InstanceInfo
346 {
347 std::string m_path;
348 PluginIndex m_index;
349 UniqueID m_unique_id;
350 std::string m_label;
351 };
352 using InstanceInfoP = std::shared_ptr<InstanceInfo>;
353 using LabelMap = std::map<std::string, InstanceInfoP>;
354 using IDMap = std::map<UniqueID, InstanceInfoP>;
355
356 static const PortNumber NOPORT = 9999UL;
357
358 static IDMap& idMap(void)
359 {
360 static IDMap id_map;
361 return id_map;
362 }
363
364 static LabelMap& labelMap(void)
365 {
366 static LabelMap label_map;
367 return label_map;
368 }
369
370 const LADSPA_Descriptor* ladspaDescriptor(void);
371 bool setDefault(PortNumber portno);
372
373 std::string m_path;
374 void* m_handle = nullptr;
375 PluginIndex m_index = 0;
376 const LADSPA_Descriptor* m_desc = nullptr;
377 LADSPA_Handle m_inst_handle = nullptr;
378 bool m_is_active = false;
379 LADSPA_Data* m_ctrl_buf = nullptr;
380 PortNumber m_sample_input_port = NOPORT;
381 PortNumber m_sample_output_port = NOPORT;
382
383}; /* class AudioLADSPAPlugin */
384
385
386} /* namespace Async */
387
388#endif /* ASYNC_AUDIO_LADSPA_PLUGIN_INCLUDED */
389
390/*
391 * This file has not been truncated
392 */
The base class for an audio processor class.
Use a LADSPA plugin as an audio processor.
AudioLADSPAPlugin & operator=(const AudioLADSPAPlugin &)=delete
Disallow copy assignment.
static bool findPluginsInDir(std::string dir)
Find any LADSPA plugins in the given subdirectory.
std::string name(void) const
Get the name of the plugin.
AudioLADSPAPlugin(const AudioLADSPAPlugin &)=delete
Disallow copy construction.
decltype(LADSPA_Descriptor::PortCount) PortNumber
virtual void processSamples(float *dest, const float *src, int count) override
Process incoming samples and put them into the output buffer.
std::string copyright(void) const
Get the copyright information for the plugin.
~AudioLADSPAPlugin(void)
Destructor.
bool portIsAudio(PortNumber portno) const
Check if a port is an audio port.
static constexpr PortNumber npos
PortNumber portCount(void) const
Get the number of ports for the plugin.
void activate(void)
Activate the plugin.
std::string label(void) const
Get the unique label for the plugin.
PortNumber findControlInputByName(const std::string &name)
Find an input control port by name.
bool portIsInput(PortNumber portno) const
Check if a port is an input port.
UniqueID uniqueId(void) const
Get the unique ID for the plugin.
std::string maker(void) const
Get information on the maker of the plugin.
static bool findPlugins(void)
Find LADSPA plugins in standard subdirectories.
void print(const std::string &prefix="")
Print some useful information for the plugin.
bool portIsControl(PortNumber portno) const
Check if a port is a control port.
AudioLADSPAPlugin(const std::string &path, PluginIndex index)
Constructor.
AudioLADSPAPlugin(UniqueID id)
Constructor.
bool portIsOutput(PortNumber portno) const
Check if a port is an output port.
bool setControl(PortNumber portno, LADSPA_Data val)
Set a control input to the given value.
void deactivate(void)
Deactivate the plugin.
bool initialize(void)
Initialize the plugin.
std::string path(void) const
Get the path to the plugin.
AudioLADSPAPlugin(const std::string &label)
Constructor.
The base class for an audio processor.
Namespace for the asynchronous programming classes.