annotate ladspa.h @ 19:0cdedb2fab81 tip

* OS/X build fixes
author Chris Cannam
date Fri, 18 Jun 2010 11:18:49 +0100
parents 192333077923
children
rev   line source
Chris@18 1 /* ladspa.h
Chris@18 2
Chris@18 3 Linux Audio Developer's Simple Plugin API Version 1.1[LGPL].
Chris@18 4 Copyright (C) 2000-2002 Richard W.E. Furse, Paul Barton-Davis,
Chris@18 5 Stefan Westerfeld.
Chris@18 6
Chris@18 7 This library is free software; you can redistribute it and/or
Chris@18 8 modify it under the terms of the GNU Lesser General Public License
Chris@18 9 as published by the Free Software Foundation; either version 2.1 of
Chris@18 10 the License, or (at your option) any later version.
Chris@18 11
Chris@18 12 This library is distributed in the hope that it will be useful, but
Chris@18 13 WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@18 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@18 15 Lesser General Public License for more details.
Chris@18 16
Chris@18 17 You should have received a copy of the GNU Lesser General Public
Chris@18 18 License along with this library; if not, write to the Free Software
Chris@18 19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
Chris@18 20 USA. */
Chris@18 21
Chris@18 22 #ifndef LADSPA_INCLUDED
Chris@18 23 #define LADSPA_INCLUDED
Chris@18 24
Chris@18 25 #define LADSPA_VERSION "1.1"
Chris@18 26 #define LADSPA_VERSION_MAJOR 1
Chris@18 27 #define LADSPA_VERSION_MINOR 1
Chris@18 28
Chris@18 29 #ifdef __cplusplus
Chris@18 30 extern "C" {
Chris@18 31 #endif
Chris@18 32
Chris@18 33 /*****************************************************************************/
Chris@18 34
Chris@18 35 /* Overview:
Chris@18 36
Chris@18 37 There is a large number of synthesis packages in use or development
Chris@18 38 on the Linux platform at this time. This API (`The Linux Audio
Chris@18 39 Developer's Simple Plugin API') attempts to give programmers the
Chris@18 40 ability to write simple `plugin' audio processors in C/C++ and link
Chris@18 41 them dynamically (`plug') into a range of these packages (`hosts').
Chris@18 42 It should be possible for any host and any plugin to communicate
Chris@18 43 completely through this interface.
Chris@18 44
Chris@18 45 This API is deliberately short and simple. To achieve compatibility
Chris@18 46 with a range of promising Linux sound synthesis packages it
Chris@18 47 attempts to find the `greatest common divisor' in their logical
Chris@18 48 behaviour. Having said this, certain limiting decisions are
Chris@18 49 implicit, notably the use of a fixed type (LADSPA_Data) for all
Chris@18 50 data transfer and absence of a parameterised `initialisation'
Chris@18 51 phase. See below for the LADSPA_Data typedef.
Chris@18 52
Chris@18 53 Plugins are expected to distinguish between control and audio
Chris@18 54 data. Plugins have `ports' that are inputs or outputs for audio or
Chris@18 55 control data and each plugin is `run' for a `block' corresponding
Chris@18 56 to a short time interval measured in samples. Audio data is
Chris@18 57 communicated using arrays of LADSPA_Data, allowing a block of audio
Chris@18 58 to be processed by the plugin in a single pass. Control data is
Chris@18 59 communicated using single LADSPA_Data values. Control data has a
Chris@18 60 single value at the start of a call to the `run()' or `run_adding()'
Chris@18 61 function, and may be considered to remain this value for its
Chris@18 62 duration. The plugin may assume that all its input and output ports
Chris@18 63 have been connected to the relevant data location (see the
Chris@18 64 `connect_port()' function below) before it is asked to run.
Chris@18 65
Chris@18 66 Plugins will reside in shared object files suitable for dynamic
Chris@18 67 linking by dlopen() and family. The file will provide a number of
Chris@18 68 `plugin types' that can be used to instantiate actual plugins
Chris@18 69 (sometimes known as `plugin instances') that can be connected
Chris@18 70 together to perform tasks.
Chris@18 71
Chris@18 72 This API contains very limited error-handling. */
Chris@18 73
Chris@18 74 /*****************************************************************************/
Chris@18 75
Chris@18 76 /* Fundamental data type passed in and out of plugin. This data type
Chris@18 77 is used to communicate audio samples and control values. It is
Chris@18 78 assumed that the plugin will work sensibly given any numeric input
Chris@18 79 value although it may have a preferred range (see hints below).
Chris@18 80
Chris@18 81 For audio it is generally assumed that 1.0f is the `0dB' reference
Chris@18 82 amplitude and is a `normal' signal level. */
Chris@18 83
Chris@18 84 typedef float LADSPA_Data;
Chris@18 85
Chris@18 86 /*****************************************************************************/
Chris@18 87
Chris@18 88 /* Special Plugin Properties:
Chris@18 89
Chris@18 90 Optional features of the plugin type are encapsulated in the
Chris@18 91 LADSPA_Properties type. This is assembled by ORing individual
Chris@18 92 properties together. */
Chris@18 93
Chris@18 94 typedef int LADSPA_Properties;
Chris@18 95
Chris@18 96 /* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a
Chris@18 97 real-time dependency (e.g. listens to a MIDI device) and so its
Chris@18 98 output must not be cached or subject to significant latency. */
Chris@18 99 #define LADSPA_PROPERTY_REALTIME 0x1
Chris@18 100
Chris@18 101 /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin
Chris@18 102 may cease to work correctly if the host elects to use the same data
Chris@18 103 location for both input and output (see connect_port()). This
Chris@18 104 should be avoided as enabling this flag makes it impossible for
Chris@18 105 hosts to use the plugin to process audio `in-place.' */
Chris@18 106 #define LADSPA_PROPERTY_INPLACE_BROKEN 0x2
Chris@18 107
Chris@18 108 /* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin
Chris@18 109 is capable of running not only in a conventional host but also in a
Chris@18 110 `hard real-time' environment. To qualify for this the plugin must
Chris@18 111 satisfy all of the following:
Chris@18 112
Chris@18 113 (1) The plugin must not use malloc(), free() or other heap memory
Chris@18 114 management within its run() or run_adding() functions. All new
Chris@18 115 memory used in run() must be managed via the stack. These
Chris@18 116 restrictions only apply to the run() function.
Chris@18 117
Chris@18 118 (2) The plugin will not attempt to make use of any library
Chris@18 119 functions with the exceptions of functions in the ANSI standard C
Chris@18 120 and C maths libraries, which the host is expected to provide.
Chris@18 121
Chris@18 122 (3) The plugin will not access files, devices, pipes, sockets, IPC
Chris@18 123 or any other mechanism that might result in process or thread
Chris@18 124 blocking.
Chris@18 125
Chris@18 126 (4) The plugin will take an amount of time to execute a run() or
Chris@18 127 run_adding() call approximately of form (A+B*SampleCount) where A
Chris@18 128 and B depend on the machine and host in use. This amount of time
Chris@18 129 may not depend on input signals or plugin state. The host is left
Chris@18 130 the responsibility to perform timings to estimate upper bounds for
Chris@18 131 A and B. */
Chris@18 132 #define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4
Chris@18 133
Chris@18 134 #define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME)
Chris@18 135 #define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN)
Chris@18 136 #define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE)
Chris@18 137
Chris@18 138 /*****************************************************************************/
Chris@18 139
Chris@18 140 /* Plugin Ports:
Chris@18 141
Chris@18 142 Plugins have `ports' that are inputs or outputs for audio or
Chris@18 143 data. Ports can communicate arrays of LADSPA_Data (for audio
Chris@18 144 inputs/outputs) or single LADSPA_Data values (for control
Chris@18 145 input/outputs). This information is encapsulated in the
Chris@18 146 LADSPA_PortDescriptor type which is assembled by ORing individual
Chris@18 147 properties together.
Chris@18 148
Chris@18 149 Note that a port must be an input or an output port but not both
Chris@18 150 and that a port must be a control or audio port but not both. */
Chris@18 151
Chris@18 152 typedef int LADSPA_PortDescriptor;
Chris@18 153
Chris@18 154 /* Property LADSPA_PORT_INPUT indicates that the port is an input. */
Chris@18 155 #define LADSPA_PORT_INPUT 0x1
Chris@18 156
Chris@18 157 /* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */
Chris@18 158 #define LADSPA_PORT_OUTPUT 0x2
Chris@18 159
Chris@18 160 /* Property LADSPA_PORT_CONTROL indicates that the port is a control
Chris@18 161 port. */
Chris@18 162 #define LADSPA_PORT_CONTROL 0x4
Chris@18 163
Chris@18 164 /* Property LADSPA_PORT_AUDIO indicates that the port is a audio
Chris@18 165 port. */
Chris@18 166 #define LADSPA_PORT_AUDIO 0x8
Chris@18 167
Chris@18 168 #define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT)
Chris@18 169 #define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT)
Chris@18 170 #define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL)
Chris@18 171 #define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO)
Chris@18 172
Chris@18 173 /*****************************************************************************/
Chris@18 174
Chris@18 175 /* Plugin Port Range Hints:
Chris@18 176
Chris@18 177 The host may wish to provide a representation of data entering or
Chris@18 178 leaving a plugin (e.g. to generate a GUI automatically). To make
Chris@18 179 this more meaningful, the plugin should provide `hints' to the host
Chris@18 180 describing the usual values taken by the data.
Chris@18 181
Chris@18 182 Note that these are only hints. The host may ignore them and the
Chris@18 183 plugin must not assume that data supplied to it is meaningful. If
Chris@18 184 the plugin receives invalid input data it is expected to continue
Chris@18 185 to run without failure and, where possible, produce a sensible
Chris@18 186 output (e.g. a high-pass filter given a negative cutoff frequency
Chris@18 187 might switch to an all-pass mode).
Chris@18 188
Chris@18 189 Hints are meaningful for all input and output ports but hints for
Chris@18 190 input control ports are expected to be particularly useful.
Chris@18 191
Chris@18 192 More hint information is encapsulated in the
Chris@18 193 LADSPA_PortRangeHintDescriptor type which is assembled by ORing
Chris@18 194 individual hint types together. Hints may require further
Chris@18 195 LowerBound and UpperBound information.
Chris@18 196
Chris@18 197 All the hint information for a particular port is aggregated in the
Chris@18 198 LADSPA_PortRangeHint structure. */
Chris@18 199
Chris@18 200 typedef int LADSPA_PortRangeHintDescriptor;
Chris@18 201
Chris@18 202 /* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field
Chris@18 203 of the LADSPA_PortRangeHint should be considered meaningful. The
Chris@18 204 value in this field should be considered the (inclusive) lower
Chris@18 205 bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
Chris@18 206 specified then the value of LowerBound should be multiplied by the
Chris@18 207 sample rate. */
Chris@18 208 #define LADSPA_HINT_BOUNDED_BELOW 0x1
Chris@18 209
Chris@18 210 /* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field
Chris@18 211 of the LADSPA_PortRangeHint should be considered meaningful. The
Chris@18 212 value in this field should be considered the (inclusive) upper
Chris@18 213 bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
Chris@18 214 specified then the value of UpperBound should be multiplied by the
Chris@18 215 sample rate. */
Chris@18 216 #define LADSPA_HINT_BOUNDED_ABOVE 0x2
Chris@18 217
Chris@18 218 /* Hint LADSPA_HINT_TOGGLED indicates that the data item should be
Chris@18 219 considered a Boolean toggle. Data less than or equal to zero should
Chris@18 220 be considered `off' or `false,' and data above zero should be
Chris@18 221 considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in
Chris@18 222 conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or
Chris@18 223 LADSPA_HINT_DEFAULT_1. */
Chris@18 224 #define LADSPA_HINT_TOGGLED 0x4
Chris@18 225
Chris@18 226 /* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified
Chris@18 227 should be interpreted as multiples of the sample rate. For
Chris@18 228 instance, a frequency range from 0Hz to the Nyquist frequency (half
Chris@18 229 the sample rate) could be requested by this hint in conjunction
Chris@18 230 with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds
Chris@18 231 at all must support this hint to retain meaning. */
Chris@18 232 #define LADSPA_HINT_SAMPLE_RATE 0x8
Chris@18 233
Chris@18 234 /* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the
Chris@18 235 user will find it more intuitive to view values using a logarithmic
Chris@18 236 scale. This is particularly useful for frequencies and gains. */
Chris@18 237 #define LADSPA_HINT_LOGARITHMIC 0x10
Chris@18 238
Chris@18 239 /* Hint LADSPA_HINT_INTEGER indicates that a user interface would
Chris@18 240 probably wish to provide a stepped control taking only integer
Chris@18 241 values. Any bounds set should be slightly wider than the actual
Chris@18 242 integer range required to avoid floating point rounding errors. For
Chris@18 243 instance, the integer set {0,1,2,3} might be described as [-0.1,
Chris@18 244 3.1]. */
Chris@18 245 #define LADSPA_HINT_INTEGER 0x20
Chris@18 246
Chris@18 247 /* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal'
Chris@18 248 value for the port that is sensible as a default. For instance,
Chris@18 249 this value is suitable for use as an initial value in a user
Chris@18 250 interface or as a value the host might assign to a control port
Chris@18 251 when the user has not provided one. Defaults are encoded using a
Chris@18 252 mask so only one default may be specified for a port. Some of the
Chris@18 253 hints make use of lower and upper bounds, in which case the
Chris@18 254 relevant bound or bounds must be available and
Chris@18 255 LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting
Chris@18 256 default must be rounded if LADSPA_HINT_INTEGER is present. Default
Chris@18 257 values were introduced in LADSPA v1.1. */
Chris@18 258 #define LADSPA_HINT_DEFAULT_MASK 0x3C0
Chris@18 259
Chris@18 260 /* This default values indicates that no default is provided. */
Chris@18 261 #define LADSPA_HINT_DEFAULT_NONE 0x0
Chris@18 262
Chris@18 263 /* This default hint indicates that the suggested lower bound for the
Chris@18 264 port should be used. */
Chris@18 265 #define LADSPA_HINT_DEFAULT_MINIMUM 0x40
Chris@18 266
Chris@18 267 /* This default hint indicates that a low value between the suggested
Chris@18 268 lower and upper bounds should be chosen. For ports with
Chris@18 269 LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 +
Chris@18 270 log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper
Chris@18 271 * 0.25). */
Chris@18 272 #define LADSPA_HINT_DEFAULT_LOW 0x80
Chris@18 273
Chris@18 274 /* This default hint indicates that a middle value between the
Chris@18 275 suggested lower and upper bounds should be chosen. For ports with
Chris@18 276 LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 +
Chris@18 277 log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper *
Chris@18 278 0.5). */
Chris@18 279 #define LADSPA_HINT_DEFAULT_MIDDLE 0xC0
Chris@18 280
Chris@18 281 /* This default hint indicates that a high value between the suggested
Chris@18 282 lower and upper bounds should be chosen. For ports with
Chris@18 283 LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 +
Chris@18 284 log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper
Chris@18 285 * 0.75). */
Chris@18 286 #define LADSPA_HINT_DEFAULT_HIGH 0x100
Chris@18 287
Chris@18 288 /* This default hint indicates that the suggested upper bound for the
Chris@18 289 port should be used. */
Chris@18 290 #define LADSPA_HINT_DEFAULT_MAXIMUM 0x140
Chris@18 291
Chris@18 292 /* This default hint indicates that the number 0 should be used. Note
Chris@18 293 that this default may be used in conjunction with
Chris@18 294 LADSPA_HINT_TOGGLED. */
Chris@18 295 #define LADSPA_HINT_DEFAULT_0 0x200
Chris@18 296
Chris@18 297 /* This default hint indicates that the number 1 should be used. Note
Chris@18 298 that this default may be used in conjunction with
Chris@18 299 LADSPA_HINT_TOGGLED. */
Chris@18 300 #define LADSPA_HINT_DEFAULT_1 0x240
Chris@18 301
Chris@18 302 /* This default hint indicates that the number 100 should be used. */
Chris@18 303 #define LADSPA_HINT_DEFAULT_100 0x280
Chris@18 304
Chris@18 305 /* This default hint indicates that the Hz frequency of `concert A'
Chris@18 306 should be used. This will be 440 unless the host uses an unusual
Chris@18 307 tuning convention, in which case it may be within a few Hz. */
Chris@18 308 #define LADSPA_HINT_DEFAULT_440 0x2C0
Chris@18 309
Chris@18 310 #define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW)
Chris@18 311 #define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE)
Chris@18 312 #define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED)
Chris@18 313 #define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE)
Chris@18 314 #define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC)
Chris@18 315 #define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER)
Chris@18 316
Chris@18 317 #define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK)
Chris@18 318 #define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 319 == LADSPA_HINT_DEFAULT_MINIMUM)
Chris@18 320 #define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 321 == LADSPA_HINT_DEFAULT_LOW)
Chris@18 322 #define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 323 == LADSPA_HINT_DEFAULT_MIDDLE)
Chris@18 324 #define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 325 == LADSPA_HINT_DEFAULT_HIGH)
Chris@18 326 #define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 327 == LADSPA_HINT_DEFAULT_MAXIMUM)
Chris@18 328 #define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 329 == LADSPA_HINT_DEFAULT_0)
Chris@18 330 #define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 331 == LADSPA_HINT_DEFAULT_1)
Chris@18 332 #define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 333 == LADSPA_HINT_DEFAULT_100)
Chris@18 334 #define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
Chris@18 335 == LADSPA_HINT_DEFAULT_440)
Chris@18 336
Chris@18 337 typedef struct _LADSPA_PortRangeHint {
Chris@18 338
Chris@18 339 /* Hints about the port. */
Chris@18 340 LADSPA_PortRangeHintDescriptor HintDescriptor;
Chris@18 341
Chris@18 342 /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When
Chris@18 343 LADSPA_HINT_SAMPLE_RATE is also active then this value should be
Chris@18 344 multiplied by the relevant sample rate. */
Chris@18 345 LADSPA_Data LowerBound;
Chris@18 346
Chris@18 347 /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When
Chris@18 348 LADSPA_HINT_SAMPLE_RATE is also active then this value should be
Chris@18 349 multiplied by the relevant sample rate. */
Chris@18 350 LADSPA_Data UpperBound;
Chris@18 351
Chris@18 352 } LADSPA_PortRangeHint;
Chris@18 353
Chris@18 354 /*****************************************************************************/
Chris@18 355
Chris@18 356 /* Plugin Handles:
Chris@18 357
Chris@18 358 This plugin handle indicates a particular instance of the plugin
Chris@18 359 concerned. It is valid to compare this to NULL (0 for C++) but
Chris@18 360 otherwise the host should not attempt to interpret it. The plugin
Chris@18 361 may use it to reference internal instance data. */
Chris@18 362
Chris@18 363 typedef void * LADSPA_Handle;
Chris@18 364
Chris@18 365 /*****************************************************************************/
Chris@18 366
Chris@18 367 /* Descriptor for a Type of Plugin:
Chris@18 368
Chris@18 369 This structure is used to describe a plugin type. It provides a
Chris@18 370 number of functions to examine the type, instantiate it, link it to
Chris@18 371 buffers and workspaces and to run it. */
Chris@18 372
Chris@18 373 typedef struct _LADSPA_Descriptor {
Chris@18 374
Chris@18 375 /* This numeric identifier indicates the plugin type
Chris@18 376 uniquely. Plugin programmers may reserve ranges of IDs from a
Chris@18 377 central body to avoid clashes. Hosts may assume that IDs are
Chris@18 378 below 0x1000000. */
Chris@18 379 unsigned long UniqueID;
Chris@18 380
Chris@18 381 /* This identifier can be used as a unique, case-sensitive
Chris@18 382 identifier for the plugin type within the plugin file. Plugin
Chris@18 383 types should be identified by file and label rather than by index
Chris@18 384 or plugin name, which may be changed in new plugin
Chris@18 385 versions. Labels must not contain white-space characters. */
Chris@18 386 const char * Label;
Chris@18 387
Chris@18 388 /* This indicates a number of properties of the plugin. */
Chris@18 389 LADSPA_Properties Properties;
Chris@18 390
Chris@18 391 /* This member points to the null-terminated name of the plugin
Chris@18 392 (e.g. "Sine Oscillator"). */
Chris@18 393 const char * Name;
Chris@18 394
Chris@18 395 /* This member points to the null-terminated string indicating the
Chris@18 396 maker of the plugin. This can be an empty string but not NULL. */
Chris@18 397 const char * Maker;
Chris@18 398
Chris@18 399 /* This member points to the null-terminated string indicating any
Chris@18 400 copyright applying to the plugin. If no Copyright applies the
Chris@18 401 string "None" should be used. */
Chris@18 402 const char * Copyright;
Chris@18 403
Chris@18 404 /* This indicates the number of ports (input AND output) present on
Chris@18 405 the plugin. */
Chris@18 406 unsigned long PortCount;
Chris@18 407
Chris@18 408 /* This member indicates an array of port descriptors. Valid indices
Chris@18 409 vary from 0 to PortCount-1. */
Chris@18 410 const LADSPA_PortDescriptor * PortDescriptors;
Chris@18 411
Chris@18 412 /* This member indicates an array of null-terminated strings
Chris@18 413 describing ports (e.g. "Frequency (Hz)"). Valid indices vary from
Chris@18 414 0 to PortCount-1. */
Chris@18 415 const char * const * PortNames;
Chris@18 416
Chris@18 417 /* This member indicates an array of range hints for each port (see
Chris@18 418 above). Valid indices vary from 0 to PortCount-1. */
Chris@18 419 const LADSPA_PortRangeHint * PortRangeHints;
Chris@18 420
Chris@18 421 /* This may be used by the plugin developer to pass any custom
Chris@18 422 implementation data into an instantiate call. It must not be used
Chris@18 423 or interpreted by the host. It is expected that most plugin
Chris@18 424 writers will not use this facility as LADSPA_Handle should be
Chris@18 425 used to hold instance data. */
Chris@18 426 void * ImplementationData;
Chris@18 427
Chris@18 428 /* This member is a function pointer that instantiates a plugin. A
Chris@18 429 handle is returned indicating the new plugin instance. The
Chris@18 430 instantiation function accepts a sample rate as a parameter. The
Chris@18 431 plugin descriptor from which this instantiate function was found
Chris@18 432 must also be passed. This function must return NULL if
Chris@18 433 instantiation fails.
Chris@18 434
Chris@18 435 Note that instance initialisation should generally occur in
Chris@18 436 activate() rather than here. */
Chris@18 437 LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor,
Chris@18 438 unsigned long SampleRate);
Chris@18 439
Chris@18 440 /* This member is a function pointer that connects a port on an
Chris@18 441 instantiated plugin to a memory location at which a block of data
Chris@18 442 for the port will be read/written. The data location is expected
Chris@18 443 to be an array of LADSPA_Data for audio ports or a single
Chris@18 444 LADSPA_Data value for control ports. Memory issues will be
Chris@18 445 managed by the host. The plugin must read/write the data at these
Chris@18 446 locations every time run() or run_adding() is called and the data
Chris@18 447 present at the time of this connection call should not be
Chris@18 448 considered meaningful.
Chris@18 449
Chris@18 450 connect_port() may be called more than once for a plugin instance
Chris@18 451 to allow the host to change the buffers that the plugin is
Chris@18 452 reading or writing. These calls may be made before or after
Chris@18 453 activate() or deactivate() calls.
Chris@18 454
Chris@18 455 connect_port() must be called at least once for each port before
Chris@18 456 run() or run_adding() is called. When working with blocks of
Chris@18 457 LADSPA_Data the plugin should pay careful attention to the block
Chris@18 458 size passed to the run function as the block allocated may only
Chris@18 459 just be large enough to contain the block of samples.
Chris@18 460
Chris@18 461 Plugin writers should be aware that the host may elect to use the
Chris@18 462 same buffer for more than one port and even use the same buffer
Chris@18 463 for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN).
Chris@18 464 However, overlapped buffers or use of a single buffer for both
Chris@18 465 audio and control data may result in unexpected behaviour. */
Chris@18 466 void (*connect_port)(LADSPA_Handle Instance,
Chris@18 467 unsigned long Port,
Chris@18 468 LADSPA_Data * DataLocation);
Chris@18 469
Chris@18 470 /* This member is a function pointer that initialises a plugin
Chris@18 471 instance and activates it for use. This is separated from
Chris@18 472 instantiate() to aid real-time support and so that hosts can
Chris@18 473 reinitialise a plugin instance by calling deactivate() and then
Chris@18 474 activate(). In this case the plugin instance must reset all state
Chris@18 475 information dependent on the history of the plugin instance
Chris@18 476 except for any data locations provided by connect_port() and any
Chris@18 477 gain set by set_run_adding_gain(). If there is nothing for
Chris@18 478 activate() to do then the plugin writer may provide a NULL rather
Chris@18 479 than an empty function.
Chris@18 480
Chris@18 481 When present, hosts must call this function once before run() (or
Chris@18 482 run_adding()) is called for the first time. This call should be
Chris@18 483 made as close to the run() call as possible and indicates to
Chris@18 484 real-time plugins that they are now live. Plugins should not rely
Chris@18 485 on a prompt call to run() after activate(). activate() may not be
Chris@18 486 called again unless deactivate() is called first. Note that
Chris@18 487 connect_port() may be called before or after a call to
Chris@18 488 activate(). */
Chris@18 489 void (*activate)(LADSPA_Handle Instance);
Chris@18 490
Chris@18 491 /* This method is a function pointer that runs an instance of a
Chris@18 492 plugin for a block. Two parameters are required: the first is a
Chris@18 493 handle to the particular instance to be run and the second
Chris@18 494 indicates the block size (in samples) for which the plugin
Chris@18 495 instance may run.
Chris@18 496
Chris@18 497 Note that if an activate() function exists then it must be called
Chris@18 498 before run() or run_adding(). If deactivate() is called for a
Chris@18 499 plugin instance then the plugin instance may not be reused until
Chris@18 500 activate() has been called again.
Chris@18 501
Chris@18 502 If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE
Chris@18 503 then there are various things that the plugin should not do
Chris@18 504 within the run() or run_adding() functions (see above). */
Chris@18 505 void (*run)(LADSPA_Handle Instance,
Chris@18 506 unsigned long SampleCount);
Chris@18 507
Chris@18 508 /* This method is a function pointer that runs an instance of a
Chris@18 509 plugin for a block. This has identical behaviour to run() except
Chris@18 510 in the way data is output from the plugin. When run() is used,
Chris@18 511 values are written directly to the memory areas associated with
Chris@18 512 the output ports. However when run_adding() is called, values
Chris@18 513 must be added to the values already present in the memory
Chris@18 514 areas. Furthermore, output values written must be scaled by the
Chris@18 515 current gain set by set_run_adding_gain() (see below) before
Chris@18 516 addition.
Chris@18 517
Chris@18 518 run_adding() is optional. When it is not provided by a plugin,
Chris@18 519 this function pointer must be set to NULL. When it is provided,
Chris@18 520 the function set_run_adding_gain() must be provided also. */
Chris@18 521 void (*run_adding)(LADSPA_Handle Instance,
Chris@18 522 unsigned long SampleCount);
Chris@18 523
Chris@18 524 /* This method is a function pointer that sets the output gain for
Chris@18 525 use when run_adding() is called (see above). If this function is
Chris@18 526 never called the gain is assumed to default to 1. Gain
Chris@18 527 information should be retained when activate() or deactivate()
Chris@18 528 are called.
Chris@18 529
Chris@18 530 This function should be provided by the plugin if and only if the
Chris@18 531 run_adding() function is provided. When it is absent this
Chris@18 532 function pointer must be set to NULL. */
Chris@18 533 void (*set_run_adding_gain)(LADSPA_Handle Instance,
Chris@18 534 LADSPA_Data Gain);
Chris@18 535
Chris@18 536 /* This is the counterpart to activate() (see above). If there is
Chris@18 537 nothing for deactivate() to do then the plugin writer may provide
Chris@18 538 a NULL rather than an empty function.
Chris@18 539
Chris@18 540 Hosts must deactivate all activated units after they have been
Chris@18 541 run() (or run_adding()) for the last time. This call should be
Chris@18 542 made as close to the last run() call as possible and indicates to
Chris@18 543 real-time plugins that they are no longer live. Plugins should
Chris@18 544 not rely on prompt deactivation. Note that connect_port() may be
Chris@18 545 called before or after a call to deactivate().
Chris@18 546
Chris@18 547 Deactivation is not similar to pausing as the plugin instance
Chris@18 548 will be reinitialised when activate() is called to reuse it. */
Chris@18 549 void (*deactivate)(LADSPA_Handle Instance);
Chris@18 550
Chris@18 551 /* Once an instance of a plugin has been finished with it can be
Chris@18 552 deleted using the following function. The instance handle passed
Chris@18 553 ceases to be valid after this call.
Chris@18 554
Chris@18 555 If activate() was called for a plugin instance then a
Chris@18 556 corresponding call to deactivate() must be made before cleanup()
Chris@18 557 is called. */
Chris@18 558 void (*cleanup)(LADSPA_Handle Instance);
Chris@18 559
Chris@18 560 } LADSPA_Descriptor;
Chris@18 561
Chris@18 562 /**********************************************************************/
Chris@18 563
Chris@18 564 /* Accessing a Plugin: */
Chris@18 565
Chris@18 566 /* The exact mechanism by which plugins are loaded is host-dependent,
Chris@18 567 however all most hosts will need to know is the name of shared
Chris@18 568 object file containing the plugin types. To allow multiple hosts to
Chris@18 569 share plugin types, hosts may wish to check for environment
Chris@18 570 variable LADSPA_PATH. If present, this should contain a
Chris@18 571 colon-separated path indicating directories that should be searched
Chris@18 572 (in order) when loading plugin types.
Chris@18 573
Chris@18 574 A plugin programmer must include a function called
Chris@18 575 "ladspa_descriptor" with the following function prototype within
Chris@18 576 the shared object file. This function will have C-style linkage (if
Chris@18 577 you are using C++ this is taken care of by the `extern "C"' clause
Chris@18 578 at the top of the file).
Chris@18 579
Chris@18 580 A host will find the plugin shared object file by one means or
Chris@18 581 another, find the ladspa_descriptor() function, call it, and
Chris@18 582 proceed from there.
Chris@18 583
Chris@18 584 Plugin types are accessed by index (not ID) using values from 0
Chris@18 585 upwards. Out of range indexes must result in this function
Chris@18 586 returning NULL, so the plugin count can be determined by checking
Chris@18 587 for the least index that results in NULL being returned. */
Chris@18 588
Chris@18 589 const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);
Chris@18 590
Chris@18 591 /* Datatype corresponding to the ladspa_descriptor() function. */
Chris@18 592 typedef const LADSPA_Descriptor *
Chris@18 593 (*LADSPA_Descriptor_Function)(unsigned long Index);
Chris@18 594
Chris@18 595 /**********************************************************************/
Chris@18 596
Chris@18 597 #ifdef __cplusplus
Chris@18 598 }
Chris@18 599 #endif
Chris@18 600
Chris@18 601 #endif /* LADSPA_INCLUDED */
Chris@18 602
Chris@18 603 /* EOF */