ladspa.h 27 KB

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