Chris@366: /* ladspa.h Chris@366: Chris@366: Linux Audio Developer's Simple Plugin API Version 1.1[LGPL]. Chris@366: Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis, Chris@366: Stefan Westerfeld. Chris@366: Chris@366: This library is free software; you can redistribute it and/or Chris@366: modify it under the terms of the GNU Lesser General Public License Chris@366: as published by the Free Software Foundation; either version 2.1 of Chris@366: the License, or (at your option) any later version. Chris@366: Chris@366: This library is distributed in the hope that it will be useful, but Chris@366: WITHOUT ANY WARRANTY; without even the implied warranty of Chris@366: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Chris@366: Lesser General Public License for more details. Chris@366: Chris@366: You should have received a copy of the GNU Lesser General Public Chris@366: License along with this library; if not, write to the Free Software Chris@366: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 Chris@366: USA. */ Chris@366: Chris@366: #ifndef LADSPA_INCLUDED Chris@366: #define LADSPA_INCLUDED Chris@366: Chris@366: #define LADSPA_VERSION "1.1" Chris@366: #define LADSPA_VERSION_MAJOR 1 Chris@366: #define LADSPA_VERSION_MINOR 1 Chris@366: Chris@366: #ifdef __cplusplus Chris@366: extern "C" { Chris@366: #endif Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Overview: Chris@366: Chris@366: There is a large number of synthesis packages in use or development Chris@366: on the Linux platform at this time. This API (`The Linux Audio Chris@366: Developer's Simple Plugin API') attempts to give programmers the Chris@366: ability to write simple `plugin' audio processors in C/C++ and link Chris@366: them dynamically (`plug') into a range of these packages (`hosts'). Chris@366: It should be possible for any host and any plugin to communicate Chris@366: completely through this interface. Chris@366: Chris@366: This API is deliberately short and simple. To achieve compatibility Chris@366: with a range of promising Linux sound synthesis packages it Chris@366: attempts to find the `greatest common divisor' in their logical Chris@366: behaviour. Having said this, certain limiting decisions are Chris@366: implicit, notably the use of a fixed type (LADSPA_Data) for all Chris@366: data transfer and absence of a parameterised `initialisation' Chris@366: phase. See below for the LADSPA_Data typedef. Chris@366: Chris@366: Plugins are expected to distinguish between control and audio Chris@366: data. Plugins have `ports' that are inputs or outputs for audio or Chris@366: control data and each plugin is `run' for a `block' corresponding Chris@366: to a short time interval measured in samples. Audio data is Chris@366: communicated using arrays of LADSPA_Data, allowing a block of audio Chris@366: to be processed by the plugin in a single pass. Control data is Chris@366: communicated using single LADSPA_Data values. Control data has a Chris@366: single value at the start of a call to the `run()' or `run_adding()' Chris@366: function, and may be considered to remain this value for its Chris@366: duration. The plugin may assume that all its input and output ports Chris@366: have been connected to the relevant data location (see the Chris@366: `connect_port()' function below) before it is asked to run. Chris@366: Chris@366: Plugins will reside in shared object files suitable for dynamic Chris@366: linking by dlopen() and family. The file will provide a number of Chris@366: `plugin types' that can be used to instantiate actual plugins Chris@366: (sometimes known as `plugin instances') that can be connected Chris@366: together to perform tasks. Chris@366: Chris@366: This API contains very limited error-handling. */ Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Fundamental data type passed in and out of plugin. This data type Chris@366: is used to communicate audio samples and control values. It is Chris@366: assumed that the plugin will work sensibly given any numeric input Chris@366: value although it may have a preferred range (see hints below). Chris@366: Chris@366: For audio it is generally assumed that 1.0f is the `0dB' reference Chris@366: amplitude and is a `normal' signal level. */ Chris@366: Chris@366: typedef float LADSPA_Data; Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Special Plugin Properties: Chris@366: Chris@366: Optional features of the plugin type are encapsulated in the Chris@366: LADSPA_Properties type. This is assembled by ORing individual Chris@366: properties together. */ Chris@366: Chris@366: typedef int LADSPA_Properties; Chris@366: Chris@366: /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a Chris@366: real-time dependency (e.g. listens to a MIDI device) and so its Chris@366: output must not be cached or subject to significant latency. */ Chris@366: #define LADSPA_PROPERTY_REALTIME 0x1 Chris@366: Chris@366: /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin Chris@366: may cease to work correctly if the host elects to use the same data Chris@366: location for both input and output (see connect_port()). This Chris@366: should be avoided as enabling this flag makes it impossible for Chris@366: hosts to use the plugin to process audio `in-place.' */ Chris@366: #define LADSPA_PROPERTY_INPLACE_BROKEN 0x2 Chris@366: Chris@366: /* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin Chris@366: is capable of running not only in a conventional host but also in a Chris@366: `hard real-time' environment. To qualify for this the plugin must Chris@366: satisfy all of the following: Chris@366: Chris@366: (1) The plugin must not use malloc(), free() or other heap memory Chris@366: management within its run() or run_adding() functions. All new Chris@366: memory used in run() must be managed via the stack. These Chris@366: restrictions only apply to the run() function. Chris@366: Chris@366: (2) The plugin will not attempt to make use of any library Chris@366: functions with the exceptions of functions in the ANSI standard C Chris@366: and C maths libraries, which the host is expected to provide. Chris@366: Chris@366: (3) The plugin will not access files, devices, pipes, sockets, IPC Chris@366: or any other mechanism that might result in process or thread Chris@366: blocking. Chris@366: Chris@366: (4) The plugin will take an amount of time to execute a run() or Chris@366: run_adding() call approximately of form (A+B*SampleCount) where A Chris@366: and B depend on the machine and host in use. This amount of time Chris@366: may not depend on input signals or plugin state. The host is left Chris@366: the responsibility to perform timings to estimate upper bounds for Chris@366: A and B. */ Chris@366: #define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4 Chris@366: Chris@366: #define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME) Chris@366: #define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN) Chris@366: #define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE) Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Plugin Ports: Chris@366: Chris@366: Plugins have `ports' that are inputs or outputs for audio or Chris@366: data. Ports can communicate arrays of LADSPA_Data (for audio Chris@366: inputs/outputs) or single LADSPA_Data values (for control Chris@366: input/outputs). This information is encapsulated in the Chris@366: LADSPA_PortDescriptor type which is assembled by ORing individual Chris@366: properties together. Chris@366: Chris@366: Note that a port must be an input or an output port but not both Chris@366: and that a port must be a control or audio port but not both. */ Chris@366: Chris@366: typedef int LADSPA_PortDescriptor; Chris@366: Chris@366: /* Property LADSPA_PORT_INPUT indicates that the port is an input. */ Chris@366: #define LADSPA_PORT_INPUT 0x1 Chris@366: Chris@366: /* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */ Chris@366: #define LADSPA_PORT_OUTPUT 0x2 Chris@366: Chris@366: /* Property LADSPA_PORT_CONTROL indicates that the port is a control Chris@366: port. */ Chris@366: #define LADSPA_PORT_CONTROL 0x4 Chris@366: Chris@366: /* Property LADSPA_PORT_AUDIO indicates that the port is a audio Chris@366: port. */ Chris@366: #define LADSPA_PORT_AUDIO 0x8 Chris@366: Chris@366: #define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT) Chris@366: #define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT) Chris@366: #define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL) Chris@366: #define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO) Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Plugin Port Range Hints: Chris@366: Chris@366: The host may wish to provide a representation of data entering or Chris@366: leaving a plugin (e.g. to generate a GUI automatically). To make Chris@366: this more meaningful, the plugin should provide `hints' to the host Chris@366: describing the usual values taken by the data. Chris@366: Chris@366: Note that these are only hints. The host may ignore them and the Chris@366: plugin must not assume that data supplied to it is meaningful. If Chris@366: the plugin receives invalid input data it is expected to continue Chris@366: to run without failure and, where possible, produce a sensible Chris@366: output (e.g. a high-pass filter given a negative cutoff frequency Chris@366: might switch to an all-pass mode). Chris@366: Chris@366: Hints are meaningful for all input and output ports but hints for Chris@366: input control ports are expected to be particularly useful. Chris@366: Chris@366: More hint information is encapsulated in the Chris@366: LADSPA_PortRangeHintDescriptor type which is assembled by ORing Chris@366: individual hint types together. Hints may require further Chris@366: LowerBound and UpperBound information. Chris@366: Chris@366: All the hint information for a particular port is aggregated in the Chris@366: LADSPA_PortRangeHint structure. */ Chris@366: Chris@366: typedef int LADSPA_PortRangeHintDescriptor; Chris@366: Chris@366: /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field Chris@366: of the LADSPA_PortRangeHint should be considered meaningful. The Chris@366: value in this field should be considered the (inclusive) lower Chris@366: bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also Chris@366: specified then the value of LowerBound should be multiplied by the Chris@366: sample rate. */ Chris@366: #define LADSPA_HINT_BOUNDED_BELOW 0x1 Chris@366: Chris@366: /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field Chris@366: of the LADSPA_PortRangeHint should be considered meaningful. The Chris@366: value in this field should be considered the (inclusive) upper Chris@366: bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also Chris@366: specified then the value of UpperBound should be multiplied by the Chris@366: sample rate. */ Chris@366: #define LADSPA_HINT_BOUNDED_ABOVE 0x2 Chris@366: Chris@366: /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be Chris@366: considered a Boolean toggle. Data less than or equal to zero should Chris@366: be considered `off' or `false,' and data above zero should be Chris@366: considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in Chris@366: conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or Chris@366: LADSPA_HINT_DEFAULT_1. */ Chris@366: #define LADSPA_HINT_TOGGLED 0x4 Chris@366: Chris@366: /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified Chris@366: should be interpreted as multiples of the sample rate. For Chris@366: instance, a frequency range from 0Hz to the Nyquist frequency (half Chris@366: the sample rate) could be requested by this hint in conjunction Chris@366: with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds Chris@366: at all must support this hint to retain meaning. */ Chris@366: #define LADSPA_HINT_SAMPLE_RATE 0x8 Chris@366: Chris@366: /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the Chris@366: user will find it more intuitive to view values using a logarithmic Chris@366: scale. This is particularly useful for frequencies and gains. */ Chris@366: #define LADSPA_HINT_LOGARITHMIC 0x10 Chris@366: Chris@366: /* Hint LADSPA_HINT_INTEGER indicates that a user interface would Chris@366: probably wish to provide a stepped control taking only integer Chris@366: values. Any bounds set should be slightly wider than the actual Chris@366: integer range required to avoid floating point rounding errors. For Chris@366: instance, the integer set {0,1,2,3} might be described as [-0.1, Chris@366: 3.1]. */ Chris@366: #define LADSPA_HINT_INTEGER 0x20 Chris@366: Chris@366: /* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal' Chris@366: value for the port that is sensible as a default. For instance, Chris@366: this value is suitable for use as an initial value in a user Chris@366: interface or as a value the host might assign to a control port Chris@366: when the user has not provided one. Defaults are encoded using a Chris@366: mask so only one default may be specified for a port. Some of the Chris@366: hints make use of lower and upper bounds, in which case the Chris@366: relevant bound or bounds must be available and Chris@366: LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting Chris@366: default must be rounded if LADSPA_HINT_INTEGER is present. Default Chris@366: values were introduced in LADSPA v1.1. */ Chris@366: #define LADSPA_HINT_DEFAULT_MASK 0x3C0 Chris@366: Chris@366: /* This default values indicates that no default is provided. */ Chris@366: #define LADSPA_HINT_DEFAULT_NONE 0x0 Chris@366: Chris@366: /* This default hint indicates that the suggested lower bound for the Chris@366: port should be used. */ Chris@366: #define LADSPA_HINT_DEFAULT_MINIMUM 0x40 Chris@366: Chris@366: /* This default hint indicates that a low value between the suggested Chris@366: lower and upper bounds should be chosen. For ports with Chris@366: LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 + Chris@366: log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper Chris@366: * 0.25). */ Chris@366: #define LADSPA_HINT_DEFAULT_LOW 0x80 Chris@366: Chris@366: /* This default hint indicates that a middle value between the Chris@366: suggested lower and upper bounds should be chosen. For ports with Chris@366: LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 + Chris@366: log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper * Chris@366: 0.5). */ Chris@366: #define LADSPA_HINT_DEFAULT_MIDDLE 0xC0 Chris@366: Chris@366: /* This default hint indicates that a high value between the suggested Chris@366: lower and upper bounds should be chosen. For ports with Chris@366: LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 + Chris@366: log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper Chris@366: * 0.75). */ Chris@366: #define LADSPA_HINT_DEFAULT_HIGH 0x100 Chris@366: Chris@366: /* This default hint indicates that the suggested upper bound for the Chris@366: port should be used. */ Chris@366: #define LADSPA_HINT_DEFAULT_MAXIMUM 0x140 Chris@366: Chris@366: /* This default hint indicates that the number 0 should be used. Note Chris@366: that this default may be used in conjunction with Chris@366: LADSPA_HINT_TOGGLED. */ Chris@366: #define LADSPA_HINT_DEFAULT_0 0x200 Chris@366: Chris@366: /* This default hint indicates that the number 1 should be used. Note Chris@366: that this default may be used in conjunction with Chris@366: LADSPA_HINT_TOGGLED. */ Chris@366: #define LADSPA_HINT_DEFAULT_1 0x240 Chris@366: Chris@366: /* This default hint indicates that the number 100 should be used. */ Chris@366: #define LADSPA_HINT_DEFAULT_100 0x280 Chris@366: Chris@366: /* This default hint indicates that the Hz frequency of `concert A' Chris@366: should be used. This will be 440 unless the host uses an unusual Chris@366: tuning convention, in which case it may be within a few Hz. */ Chris@366: #define LADSPA_HINT_DEFAULT_440 0x2C0 Chris@366: Chris@366: #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW) Chris@366: #define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE) Chris@366: #define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED) Chris@366: #define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE) Chris@366: #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC) Chris@366: #define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER) Chris@366: Chris@366: #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK) Chris@366: #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_MINIMUM) Chris@366: #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_LOW) Chris@366: #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_MIDDLE) Chris@366: #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_HIGH) Chris@366: #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_MAXIMUM) Chris@366: #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_0) Chris@366: #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_1) Chris@366: #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_100) Chris@366: #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \ Chris@366: == LADSPA_HINT_DEFAULT_440) Chris@366: Chris@366: typedef struct _LADSPA_PortRangeHint { Chris@366: Chris@366: /* Hints about the port. */ Chris@366: LADSPA_PortRangeHintDescriptor HintDescriptor; Chris@366: Chris@366: /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When Chris@366: LADSPA_HINT_SAMPLE_RATE is also active then this value should be Chris@366: multiplied by the relevant sample rate. */ Chris@366: LADSPA_Data LowerBound; Chris@366: Chris@366: /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When Chris@366: LADSPA_HINT_SAMPLE_RATE is also active then this value should be Chris@366: multiplied by the relevant sample rate. */ Chris@366: LADSPA_Data UpperBound; Chris@366: Chris@366: } LADSPA_PortRangeHint; Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Plugin Handles: Chris@366: Chris@366: This plugin handle indicates a particular instance of the plugin Chris@366: concerned. It is valid to compare this to NULL (0 for C++) but Chris@366: otherwise the host should not attempt to interpret it. The plugin Chris@366: may use it to reference internal instance data. */ Chris@366: Chris@366: typedef void * LADSPA_Handle; Chris@366: Chris@366: /*****************************************************************************/ Chris@366: Chris@366: /* Descriptor for a Type of Plugin: Chris@366: Chris@366: This structure is used to describe a plugin type. It provides a Chris@366: number of functions to examine the type, instantiate it, link it to Chris@366: buffers and workspaces and to run it. */ Chris@366: Chris@366: typedef struct _LADSPA_Descriptor { Chris@366: Chris@366: /* This numeric identifier indicates the plugin type Chris@366: uniquely. Plugin programmers may reserve ranges of IDs from a Chris@366: central body to avoid clashes. Hosts may assume that IDs are Chris@366: below 0x1000000. */ Chris@366: unsigned long UniqueID; Chris@366: Chris@366: /* This identifier can be used as a unique, case-sensitive Chris@366: identifier for the plugin type within the plugin file. Plugin Chris@366: types should be identified by file and label rather than by index Chris@366: or plugin name, which may be changed in new plugin Chris@366: versions. Labels must not contain white-space characters. */ Chris@366: const char * Label; Chris@366: Chris@366: /* This indicates a number of properties of the plugin. */ Chris@366: LADSPA_Properties Properties; Chris@366: Chris@366: /* This member points to the null-terminated name of the plugin Chris@366: (e.g. "Sine Oscillator"). */ Chris@366: const char * Name; Chris@366: Chris@366: /* This member points to the null-terminated string indicating the Chris@366: maker of the plugin. This can be an empty string but not NULL. */ Chris@366: const char * Maker; Chris@366: Chris@366: /* This member points to the null-terminated string indicating any Chris@366: copyright applying to the plugin. If no Copyright applies the Chris@366: string "None" should be used. */ Chris@366: const char * Copyright; Chris@366: Chris@366: /* This indicates the number of ports (input AND output) present on Chris@366: the plugin. */ Chris@366: unsigned long PortCount; Chris@366: Chris@366: /* This member indicates an array of port descriptors. Valid indices Chris@366: vary from 0 to PortCount-1. */ Chris@366: const LADSPA_PortDescriptor * PortDescriptors; Chris@366: Chris@366: /* This member indicates an array of null-terminated strings Chris@366: describing ports (e.g. "Frequency (Hz)"). Valid indices vary from Chris@366: 0 to PortCount-1. */ Chris@366: const char * const * PortNames; Chris@366: Chris@366: /* This member indicates an array of range hints for each port (see Chris@366: above). Valid indices vary from 0 to PortCount-1. */ Chris@366: const LADSPA_PortRangeHint * PortRangeHints; Chris@366: Chris@366: /* This may be used by the plugin developer to pass any custom Chris@366: implementation data into an instantiate call. It must not be used Chris@366: or interpreted by the host. It is expected that most plugin Chris@366: writers will not use this facility as LADSPA_Handle should be Chris@366: used to hold instance data. */ Chris@366: void * ImplementationData; Chris@366: Chris@366: /* This member is a function pointer that instantiates a plugin. A Chris@366: handle is returned indicating the new plugin instance. The Chris@366: instantiation function accepts a sample rate as a parameter. The Chris@366: plugin descriptor from which this instantiate function was found Chris@366: must also be passed. This function must return NULL if Chris@366: instantiation fails. Chris@366: Chris@366: Note that instance initialisation should generally occur in Chris@366: activate() rather than here. */ Chris@366: LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor, Chris@366: unsigned long SampleRate); Chris@366: Chris@366: /* This member is a function pointer that connects a port on an Chris@366: instantiated plugin to a memory location at which a block of data Chris@366: for the port will be read/written. The data location is expected Chris@366: to be an array of LADSPA_Data for audio ports or a single Chris@366: LADSPA_Data value for control ports. Memory issues will be Chris@366: managed by the host. The plugin must read/write the data at these Chris@366: locations every time run() or run_adding() is called and the data Chris@366: present at the time of this connection call should not be Chris@366: considered meaningful. Chris@366: Chris@366: connect_port() may be called more than once for a plugin instance Chris@366: to allow the host to change the buffers that the plugin is Chris@366: reading or writing. These calls may be made before or after Chris@366: activate() or deactivate() calls. Chris@366: Chris@366: connect_port() must be called at least once for each port before Chris@366: run() or run_adding() is called. When working with blocks of Chris@366: LADSPA_Data the plugin should pay careful attention to the block Chris@366: size passed to the run function as the block allocated may only Chris@366: just be large enough to contain the block of samples. Chris@366: Chris@366: Plugin writers should be aware that the host may elect to use the Chris@366: same buffer for more than one port and even use the same buffer Chris@366: for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN). Chris@366: However, overlapped buffers or use of a single buffer for both Chris@366: audio and control data may result in unexpected behaviour. */ Chris@366: void (*connect_port)(LADSPA_Handle Instance, Chris@366: unsigned long Port, Chris@366: LADSPA_Data * DataLocation); Chris@366: Chris@366: /* This member is a function pointer that initialises a plugin Chris@366: instance and activates it for use. This is separated from Chris@366: instantiate() to aid real-time support and so that hosts can Chris@366: reinitialise a plugin instance by calling deactivate() and then Chris@366: activate(). In this case the plugin instance must reset all state Chris@366: information dependent on the history of the plugin instance Chris@366: except for any data locations provided by connect_port() and any Chris@366: gain set by set_run_adding_gain(). If there is nothing for Chris@366: activate() to do then the plugin writer may provide a NULL rather Chris@366: than an empty function. Chris@366: Chris@366: When present, hosts must call this function once before run() (or Chris@366: run_adding()) is called for the first time. This call should be Chris@366: made as close to the run() call as possible and indicates to Chris@366: real-time plugins that they are now live. Plugins should not rely Chris@366: on a prompt call to run() after activate(). activate() may not be Chris@366: called again unless deactivate() is called first. Note that Chris@366: connect_port() may be called before or after a call to Chris@366: activate(). */ Chris@366: void (*activate)(LADSPA_Handle Instance); Chris@366: Chris@366: /* This method is a function pointer that runs an instance of a Chris@366: plugin for a block. Two parameters are required: the first is a Chris@366: handle to the particular instance to be run and the second Chris@366: indicates the block size (in samples) for which the plugin Chris@366: instance may run. Chris@366: Chris@366: Note that if an activate() function exists then it must be called Chris@366: before run() or run_adding(). If deactivate() is called for a Chris@366: plugin instance then the plugin instance may not be reused until Chris@366: activate() has been called again. Chris@366: Chris@366: If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE Chris@366: then there are various things that the plugin should not do Chris@366: within the run() or run_adding() functions (see above). */ Chris@366: void (*run)(LADSPA_Handle Instance, Chris@366: unsigned long SampleCount); Chris@366: Chris@366: /* This method is a function pointer that runs an instance of a Chris@366: plugin for a block. This has identical behaviour to run() except Chris@366: in the way data is output from the plugin. When run() is used, Chris@366: values are written directly to the memory areas associated with Chris@366: the output ports. However when run_adding() is called, values Chris@366: must be added to the values already present in the memory Chris@366: areas. Furthermore, output values written must be scaled by the Chris@366: current gain set by set_run_adding_gain() (see below) before Chris@366: addition. Chris@366: Chris@366: run_adding() is optional. When it is not provided by a plugin, Chris@366: this function pointer must be set to NULL. When it is provided, Chris@366: the function set_run_adding_gain() must be provided also. */ Chris@366: void (*run_adding)(LADSPA_Handle Instance, Chris@366: unsigned long SampleCount); Chris@366: Chris@366: /* This method is a function pointer that sets the output gain for Chris@366: use when run_adding() is called (see above). If this function is Chris@366: never called the gain is assumed to default to 1. Gain Chris@366: information should be retained when activate() or deactivate() Chris@366: are called. Chris@366: Chris@366: This function should be provided by the plugin if and only if the Chris@366: run_adding() function is provided. When it is absent this Chris@366: function pointer must be set to NULL. */ Chris@366: void (*set_run_adding_gain)(LADSPA_Handle Instance, Chris@366: LADSPA_Data Gain); Chris@366: Chris@366: /* This is the counterpart to activate() (see above). If there is Chris@366: nothing for deactivate() to do then the plugin writer may provide Chris@366: a NULL rather than an empty function. Chris@366: Chris@366: Hosts must deactivate all activated units after they have been Chris@366: run() (or run_adding()) for the last time. This call should be Chris@366: made as close to the last run() call as possible and indicates to Chris@366: real-time plugins that they are no longer live. Plugins should Chris@366: not rely on prompt deactivation. Note that connect_port() may be Chris@366: called before or after a call to deactivate(). Chris@366: Chris@366: Deactivation is not similar to pausing as the plugin instance Chris@366: will be reinitialised when activate() is called to reuse it. */ Chris@366: void (*deactivate)(LADSPA_Handle Instance); Chris@366: Chris@366: /* Once an instance of a plugin has been finished with it can be Chris@366: deleted using the following function. The instance handle passed Chris@366: ceases to be valid after this call. Chris@366: Chris@366: If activate() was called for a plugin instance then a Chris@366: corresponding call to deactivate() must be made before cleanup() Chris@366: is called. */ Chris@366: void (*cleanup)(LADSPA_Handle Instance); Chris@366: Chris@366: } LADSPA_Descriptor; Chris@366: Chris@366: /**********************************************************************/ Chris@366: Chris@366: /* Accessing a Plugin: */ Chris@366: Chris@366: /* The exact mechanism by which plugins are loaded is host-dependent, Chris@366: however all most hosts will need to know is the name of shared Chris@366: object file containing the plugin types. To allow multiple hosts to Chris@366: share plugin types, hosts may wish to check for environment Chris@366: variable LADSPA_PATH. If present, this should contain a Chris@366: colon-separated path indicating directories that should be searched Chris@366: (in order) when loading plugin types. Chris@366: Chris@366: A plugin programmer must include a function called Chris@366: "ladspa_descriptor" with the following function prototype within Chris@366: the shared object file. This function will have C-style linkage (if Chris@366: you are using C++ this is taken care of by the `extern "C"' clause Chris@366: at the top of the file). Chris@366: Chris@366: A host will find the plugin shared object file by one means or Chris@366: another, find the ladspa_descriptor() function, call it, and Chris@366: proceed from there. Chris@366: Chris@366: Plugin types are accessed by index (not ID) using values from 0 Chris@366: upwards. Out of range indexes must result in this function Chris@366: returning NULL, so the plugin count can be determined by checking Chris@366: for the least index that results in NULL being returned. */ Chris@366: Chris@366: const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index); Chris@366: Chris@366: /* Datatype corresponding to the ladspa_descriptor() function. */ Chris@366: typedef const LADSPA_Descriptor * Chris@366: (*LADSPA_Descriptor_Function)(unsigned long Index); Chris@366: Chris@366: /**********************************************************************/ Chris@366: Chris@366: #ifdef __cplusplus Chris@366: } Chris@366: #endif Chris@366: Chris@366: #endif /* LADSPA_INCLUDED */ Chris@366: Chris@366: /* EOF */