Async 1.8.0
|
Use a LADSPA plugin as an audio processor. More...
#include <AsyncAudioLADSPAPlugin.h>
Public Types | |
using | PortNumber = decltype(LADSPA_Descriptor::PortCount) |
using | PluginIndex = unsigned long |
using | UniqueID = unsigned long |
Public Member Functions | |
AudioLADSPAPlugin (const std::string &path, PluginIndex index) | |
Constructor. | |
AudioLADSPAPlugin (UniqueID id) | |
Constructor. | |
AudioLADSPAPlugin (const std::string &label) | |
Constructor. | |
AudioLADSPAPlugin (const AudioLADSPAPlugin &)=delete | |
Disallow copy construction. | |
AudioLADSPAPlugin & | operator= (const AudioLADSPAPlugin &)=delete |
Disallow copy assignment. | |
~AudioLADSPAPlugin (void) | |
Destructor. | |
bool | initialize (void) |
Initialize the plugin. | |
PortNumber | findControlInputByName (const std::string &name) |
Find an input control port by name. | |
bool | setControl (PortNumber portno, LADSPA_Data val) |
Set a control input to the given value. | |
void | activate (void) |
Activate the plugin. | |
void | deactivate (void) |
Deactivate the plugin. | |
std::string | path (void) const |
Get the path to the plugin. | |
UniqueID | uniqueId (void) const |
Get the unique ID for the plugin. | |
std::string | label (void) const |
Get the unique label for the plugin. | |
std::string | name (void) const |
Get the name of the plugin. | |
std::string | maker (void) const |
Get information on the maker of the plugin. | |
std::string | copyright (void) const |
Get the copyright information for the plugin. | |
PortNumber | portCount (void) const |
Get the number of ports for the plugin. | |
bool | portIsControl (PortNumber portno) const |
Check if a port is a control port. | |
bool | portIsAudio (PortNumber portno) const |
Check if a port is an audio port. | |
bool | portIsInput (PortNumber portno) const |
Check if a port is an input port. | |
bool | portIsOutput (PortNumber portno) const |
Check if a port is an output port. | |
void | print (const std::string &prefix="") |
Print some useful information for the plugin. | |
![]() | |
AudioProcessor (void) | |
Default constuctor. | |
virtual | ~AudioProcessor (void) |
Destructor. | |
int | writeSamples (const float *samples, int len) |
Write audio to the filter. | |
void | flushSamples (void) |
Order a flush of all samples. | |
void | resumeOutput (void) |
Resume output to the sink if previously stopped. | |
void | allSamplesFlushed (void) |
All samples have been flushed by the sink. | |
![]() | |
AudioSink (void) | |
Default constuctor. | |
virtual | ~AudioSink (void) |
Destructor. | |
bool | registerSource (AudioSource *source) |
Register an audio source to provide samples to this sink. | |
void | unregisterSource (void) |
Unregister the previously registered audio source. | |
bool | isRegistered (void) const |
Check if an audio source has been registered. | |
AudioSource * | source (void) const |
Get the registered audio source. | |
![]() | |
AudioSource (void) | |
Default constuctor. | |
virtual | ~AudioSource (void) |
Destructor. | |
bool | registerSink (AudioSink *sink, bool managed=false) |
Register an audio sink to provide samples to. | |
void | unregisterSink (void) |
Unregister the previously registered audio sink. | |
bool | isRegistered (void) const |
Check if an audio sink has been registered. | |
AudioSink * | sink (void) const |
Get the registered audio sink. | |
bool | sinkManaged (void) const |
Check if the sink is managed or not. | |
void | handleAllSamplesFlushed (void) |
The registered sink has flushed all samples. | |
Static Public Member Functions | |
static bool | findPluginsInDir (std::string dir) |
Find any LADSPA plugins in the given subdirectory. | |
static bool | findPlugins (void) |
Find LADSPA plugins in standard subdirectories. | |
Static Public Attributes | |
static constexpr PortNumber | npos = std::numeric_limits<PortNumber>::max() |
Protected Member Functions | |
virtual void | processSamples (float *dest, const float *src, int count) override |
Process incoming samples and put them into the output buffer. | |
![]() | |
void | setInputOutputSampleRate (int input_rate, int output_rate) |
Set the input and output sample rates. | |
![]() | |
void | sourceResumeOutput (void) |
Tell the source that we are ready to accept more samples. | |
void | sourceAllSamplesFlushed (void) |
Tell the source that all samples have been flushed. | |
bool | setHandler (AudioSink *handler) |
Setup another sink to handle the incoming audio. | |
void | clearHandler (void) |
Clear a handler that was previously setup with setHandler. | |
AudioSink * | handler (void) const |
![]() | |
int | sinkWriteSamples (const float *samples, int len) |
void | sinkFlushSamples (void) |
bool | setHandler (AudioSource *handler) |
Setup another source to handle the outgoing audio. | |
AudioSource * | handler (void) const |
void | clearHandler (void) |
Clear a handler that was previously setup with setHandler. | |
Use a LADSPA plugin as an audio processor.
This class is used to load a LADSPA plugin and use it as an audio processor.
Definition at line 125 of file AsyncAudioLADSPAPlugin.h.
using Async::AudioLADSPAPlugin::PluginIndex = unsigned long |
Definition at line 129 of file AsyncAudioLADSPAPlugin.h.
using Async::AudioLADSPAPlugin::PortNumber = decltype(LADSPA_Descriptor::PortCount) |
Definition at line 128 of file AsyncAudioLADSPAPlugin.h.
using Async::AudioLADSPAPlugin::UniqueID = unsigned long |
Definition at line 130 of file AsyncAudioLADSPAPlugin.h.
|
inline |
Constructor.
path | The full path of the plugin to load |
index | The index of the plugin to instantiate |
This constructor is normally not used directly unless there is a special requirement to load a specific LADSPA plugin file with a known plugin index.
Definition at line 172 of file AsyncAudioLADSPAPlugin.h.
Async::AudioLADSPAPlugin::AudioLADSPAPlugin | ( | UniqueID | id | ) |
Constructor.
id | The plugin unique id to look for |
Use this constructor for creating a LADSPA plugin instance if you know its unique ID. The easiest way normally is to use the label to find the plugin.
Async::AudioLADSPAPlugin::AudioLADSPAPlugin | ( | const std::string & | label | ) |
Constructor.
label | The plugin label to look for |
This is the main constructor for creating a LADSPA plugin instance.
|
delete |
Disallow copy construction.
Async::AudioLADSPAPlugin::~AudioLADSPAPlugin | ( | void | ) |
Destructor.
void Async::AudioLADSPAPlugin::activate | ( | void | ) |
Activate the plugin.
Use this function to activate this plugin. Activation is done in the initialize function so manual activation is normally not needed. Read more about plugin activation in the LADSPA documentation.
|
inline |
Get the copyright information for the plugin.
Definition at line 292 of file AsyncAudioLADSPAPlugin.h.
void Async::AudioLADSPAPlugin::deactivate | ( | void | ) |
Deactivate the plugin.
Use this function to deactivate this plugin. Read more about plugin activation in the LADSPA documentation.
PortNumber Async::AudioLADSPAPlugin::findControlInputByName | ( | const std::string & | name | ) |
Find an input control port by name.
name | The port namne to look for |
|
static |
Find LADSPA plugins in standard subdirectories.
LADSPA plugins are typically installed in /usr/lib64/ladspa (on a 64 bit x86 system). This default value is adapted automatically to match the target system during compilation of the software.
If the LADSPA_PATH environment variable is set it will override the default path.
This function is called by the "label variant" of the constructor if the plugin index is empty.
|
static |
Find any LADSPA plugins in the given subdirectory.
dir | The path to the directory to look in |
This function will go through all files in the given subdirectory, reading any *.so files it can find and load them as LADSPA plugins. The plugins are not fully initialized in this process but rather just the necessary calls are made to extract enough information to determine if this is a plugin that is compatible with this class. Any plugin found to be usable is put in an index so that we later can find plugins using their label.
bool Async::AudioLADSPAPlugin::initialize | ( | void | ) |
Initialize the plugin.
All loading, instantiation and initialization of the plugin is done in this function. The LADSPA activate call is called at the end of the function so it is directly ready to process audio when this function returns true. If the function returns false, it's not allowed to call any other functions so the object should be deleted as soon as possible.
|
inline |
Get the unique label for the plugin.
The label is what most often is used to find a specific plugin.
Definition at line 272 of file AsyncAudioLADSPAPlugin.h.
|
inline |
Get information on the maker of the plugin.
Definition at line 286 of file AsyncAudioLADSPAPlugin.h.
|
inline |
Get the name of the plugin.
This function return the free text name/display name for the plugin.
Definition at line 280 of file AsyncAudioLADSPAPlugin.h.
|
delete |
Disallow copy assignment.
|
inline |
Get the path to the plugin.
Definition at line 256 of file AsyncAudioLADSPAPlugin.h.
|
inline |
Get the number of ports for the plugin.
Definition at line 298 of file AsyncAudioLADSPAPlugin.h.
bool Async::AudioLADSPAPlugin::portIsAudio | ( | PortNumber | portno | ) | const |
Check if a port is an audio port.
bool Async::AudioLADSPAPlugin::portIsControl | ( | PortNumber | portno | ) | const |
Check if a port is a control port.
bool Async::AudioLADSPAPlugin::portIsInput | ( | PortNumber | portno | ) | const |
Check if a port is an input port.
bool Async::AudioLADSPAPlugin::portIsOutput | ( | PortNumber | portno | ) | const |
Check if a port is an output port.
void Async::AudioLADSPAPlugin::print | ( | const std::string & | prefix = "" | ) |
Print some useful information for the plugin.
|
overrideprotectedvirtual |
Process incoming samples and put them into the output buffer.
dest | Destination buffer |
src | Source buffer |
count | Number of samples in the source buffer |
This function should be reimplemented by the inheriting class to do the actual processing of the incoming samples. All samples must be processed, otherwise they are lost and the output buffer will contain garbage.
Implements Async::AudioProcessor.
bool Async::AudioLADSPAPlugin::setControl | ( | PortNumber | portno, |
LADSPA_Data | val ) |
Set a control input to the given value.
portno | The port number to set |
val | The value to set |
|
inline |
Get the unique ID for the plugin.
All plugins have a unique ID which can be used to find it.
Definition at line 264 of file AsyncAudioLADSPAPlugin.h.
|
staticconstexpr |
Definition at line 132 of file AsyncAudioLADSPAPlugin.h.