Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

746 lines
22KB

  1. /*
  2. * Carla Native Plugin API
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_NATIVE_H_INCLUDED
  18. #define CARLA_NATIVE_H_INCLUDED
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. #include <stdbool.h>
  23. #include <stddef.h>
  24. #include <stdint.h>
  25. /*!
  26. * @defgroup CarlaNativeAPI Carla Native API
  27. *
  28. * The Carla Native API
  29. * @{
  30. */
  31. // -----------------------------------------------------------------------
  32. // Macros
  33. /*!
  34. * Current API version.
  35. */
  36. #define CARLA_NATIVE_API_VERSION 1
  37. /*!
  38. * @defgroup PluginCategories Plugin Categories
  39. *
  40. * A small list of pre-defined plugin categories.
  41. *
  42. * Plugins should provide at least one of these basic categories.
  43. * THey can use their own custom categories as well, as long as they are lowercase and contain ASCII characters only.
  44. * Many categories can be set by using ":" in between them.
  45. * @{
  46. */
  47. #define PLUGIN_CATEGORY_SYNTH "synth" //!< A synthesizer or generator.
  48. #define PLUGIN_CATEGORY_DELAY "delay" //!< A delay or reverberator.
  49. #define PLUGIN_CATEGORY_EQ "eq" //!< An equalizer.
  50. #define PLUGIN_CATEGORY_FILTER "filter" //!< A filter.
  51. #define PLUGIN_CATEGORY_DYNAMICS "dynamics" //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  52. #define PLUGIN_CATEGORY_MODULATOR "modulator" //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  53. #define PLUGIN_CATEGORY_UTILITY "utility" //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  54. #define PLUGIN_CATEGORY_OTHER "other" //!< Misc plugin (used to check if the plugin has a category).
  55. /** @} */
  56. /*!
  57. * @defgroup PluginFeatures Plugin Features
  58. *
  59. * A list of plugin features or hints.
  60. *
  61. * Custom features are allowed, as long as they are lowercase and contain ASCII characters only.
  62. * The host can decide if it can load the plugin or not based on this information.
  63. *
  64. * Multiple features can be set by using ":" in between them.
  65. * @{
  66. */
  67. /*!
  68. * Is hard-realtime safe.
  69. *
  70. * Plugins with non-rtsafe parameters can be considered rtsafe,
  71. * as long as they set parameters hints accordingly.
  72. *
  73. * If the plugin is hard-realtime safe and supports MIDI programs,
  74. * it MUST ensure MIDI Program events are hard-realtime safe as well.
  75. *
  76. * @see PARAMETER_IS_RTSAFE
  77. */
  78. #define PLUGIN_FEATURE_RTSAFE "rtsafe"
  79. /*!
  80. * Needs non-realtime idle() function regularly.
  81. *
  82. * This can be used by plugins that need a non-realtime thread to do work.
  83. * The host will call PluginDescriptor::idle() at regular intervals.
  84. * The plugin MUST NOT lock indefinitely.
  85. *
  86. * Alternatively, the plugin can ask the host for a one-shot idle(),
  87. * by using HOST_OPCODE_NEEDS_IDLE.
  88. */
  89. #define PLUGIN_FEATURE_IDLE "idle"
  90. /*!
  91. * Needs fixed-size audio buffers.
  92. *
  93. * When this feature is set, the host will always call the process() with frames equal to the current buffer size.
  94. * The plugin should probably listen for buffer size changes.
  95. *
  96. * @see PLUGIN_FEATURE_BUFFER_SIZE_CHANGES, PLUGIN_OPCODE_BUFFER_SIZE_CHANGED
  97. */
  98. #define PLUGIN_FEATURE_FIXED_BUFFERS "fixedbuffers"
  99. /*!
  100. * Supports buffer size changes on-the-fly.
  101. *
  102. * If unset, the host will re-initiate the plugin when the buffer size changes.
  103. */
  104. #define PLUGIN_FEATURE_BUFFER_SIZE_CHANGES "buffersizechanges"
  105. /*!
  106. * Supports sample rate changes on-the-fly.
  107. *
  108. * If unset, the host will re-initiate the plugin when the sample rate changes.
  109. */
  110. #define PLUGIN_FEATURE_SAMPLE_RATE_CHANGES "sampleratechanges"
  111. /*!
  112. * Prefers mono-style panning.
  113. */
  114. #define PLUGIN_FEATURE_MONO_PANNING "monopanning"
  115. /*!
  116. * Prefers stereo balance.
  117. */
  118. #define PLUGIN_FEATURE_STEREO_BALANCE "stereobalance"
  119. /*!
  120. * Supports get_state() and set_state() functions.
  121. */
  122. #define PLUGIN_FEATURE_STATE "state"
  123. /*!
  124. * Uses get_time_info() function.
  125. */
  126. #define PLUGIN_FEATURE_TIME "time"
  127. /*!
  128. * Uses write_event() function.
  129. */
  130. #define PLUGIN_FEATURE_WRITE_EVENT "writeevent"
  131. /*!
  132. * Uses send_ui_msg() function.
  133. */
  134. #define PLUGIN_FEATURE_SEND_MSG "sendmsg"
  135. /** @} */
  136. /*!
  137. * @defgroup UiFeatures UI Features
  138. *
  139. * A list of UI features or hints.
  140. *
  141. * Custom features are allowed, as long as they are lowercase and contain ASCII characters only.
  142. * The host can decide if it can load the UI or not based on this information.
  143. *
  144. * Multiple features can be set by using ":" in between them.
  145. * @{
  146. */
  147. /*!
  148. * Supports sample rate changes on-the-fly.
  149. *
  150. * If unset, the host will re-initiate the UI when the sample rate changes.
  151. */
  152. #define UI_FEATURE_SAMPLE_RATE_CHANGES "sampleratechanges"
  153. /*!
  154. * Uses ui_open_file() and/or ui_save_file() functions.
  155. */
  156. #define UI_FEATURE_OPEN_SAVE "opensave"
  157. /*!
  158. * Uses send_plugin_msg() function.
  159. */
  160. #define UI_FEATURE_SEND_MSG "sendmsg"
  161. /** @} */
  162. /*!
  163. * TODO - this needs a better name...
  164. *
  165. * @defgroup PluginSupports Plugin Supports
  166. *
  167. * A list of plugin supported MIDI events.
  168. *
  169. * Multiple (supports) can be set by using ":" in between them.
  170. * @{
  171. */
  172. /*!
  173. * Handles MIDI programs internally instead of host-exposed/exported.
  174. *
  175. * When this is set, the host will no try to map MIDI program changes into
  176. * plugin exported programs by sending MidiProgramEvent, but will send MidiEvent directly.
  177. *
  178. * @see MidiProgram, MidiProgramEvent
  179. */
  180. #define PLUGIN_SUPPORTS_PROGRAM_CHANGES "program"
  181. /*!
  182. * Supports control changes (0xB0).
  183. *
  184. * @note:
  185. * The plugin MUST NEVER change exposed parameters on its own.
  186. * If the plugin wants to map a MIDI control change message to a parameter
  187. * it can do so by reporting it in the meta-data, which the host will read.
  188. */
  189. #define PLUGIN_SUPPORTS_CONTROL_CHANGES "control"
  190. /*!
  191. * Supports channel pressure (0xD0).
  192. */
  193. #define PLUGIN_SUPPORTS_CHANNEL_PRESSURE "pressure"
  194. /*!
  195. * Supports note aftertouch (0xA0).
  196. */
  197. #define PLUGIN_SUPPORTS_NOTE_AFTERTOUCH "aftertouch"
  198. /*!
  199. * Supports pitchbend (0xE0).
  200. */
  201. #define PLUGIN_SUPPORTS_PITCHBEND "pitchbend"
  202. /*!
  203. * Supports all-sound-off and all-notes-off events.
  204. *
  205. * When this is not set, the host might want to send various note-off events to silence the plugin.
  206. */
  207. #define PLUGIN_SUPPORTS_ALL_SOUND_OFF "allsoundoff"
  208. /**@}*/
  209. /*!
  210. * @defgroup ParameterHints Parameter Hints
  211. *
  212. * List of parameter hints.
  213. *
  214. * Multiple hints can be set by using ":" in between them.
  215. * @{
  216. */
  217. /*!
  218. * Is output.
  219. *
  220. * If this is not set, the parameter should be considered input.
  221. *
  222. * Input parameters are managed by the host and changed by sending a ParameterEvent to the plugin.
  223. * The plugin MUST NEVER change input parameters on its own.
  224. *
  225. * Output parameters are managed by the plugin.
  226. * Every time their values change the plugin should .
  227. * Because of this, any plugin that has output parameters should always set PLUGIN_FEATURE_WRITE_EVENT.
  228. */
  229. #define PARAMETER_IS_OUTPUT "output"
  230. /*!
  231. * Is enabled.
  232. *
  233. * If set the host may show this parameter on its "built-in" dialog.
  234. */
  235. #define PARAMETER_IS_ENABLED "enabled"
  236. /*!
  237. * Is hard-realtime safe.
  238. *
  239. * For input parameters:
  240. * When set, the host MUST ONLY use in-process events to change this parameter.
  241. * When not set the host MUST ONLY use PluginDescriptor::non_rt_event().
  242. *
  243. * For output parameters:
  244. * When set, the plugin must send a ParameterEvent to the host every time the value changes.
  245. * When not set the host will call PluginDescriptor::get_parameter_value(), where the plugin is allowed to lock.
  246. *
  247. * @see PLUGIN_FEATURE_RTSAFE
  248. */
  249. #define PARAMETER_IS_RTSAFE "rtsafe"
  250. /*!
  251. * Values are boolean (always at minimum or maximum values).
  252. */
  253. #define PARAMETER_IS_BOOLEAN "boolean"
  254. /*!
  255. * Values are integer.
  256. */
  257. #define PARAMETER_IS_INTEGER "integer"
  258. /*!
  259. * Values are logarithmic.
  260. */
  261. #define PARAMETER_IS_LOGARITHMIC "logarithmic"
  262. /*!
  263. * Needs sample rate to work.
  264. *
  265. * The parameter value and ranges are multiplied by sample rate on usage
  266. * and divided by sample rate on save.
  267. */
  268. #define PARAMETER_USES_SAMPLE_RATE "samplerate"
  269. /*!
  270. * Uses scalepoints to define internal values in a meaningful way.
  271. */
  272. #define PARAMETER_USES_SCALEPOINTS "scalepoints"
  273. /*!
  274. * Uses custom text for displaying its value.
  275. *
  276. * @see get_parameter_text()
  277. */
  278. #define PARAMETER_USES_CUSTOM_TEXT "customtext"
  279. /**@}*/
  280. /*!
  281. * @defgroup DefaultParameterRanges Default Parameter Ranges
  282. *
  283. * Default values for parameter range steps.
  284. * @{
  285. */
  286. #define PARAMETER_RANGE_DEFAULT_STEP 0.01f
  287. #define PARAMETER_RANGE_DEFAULT_STEP_SMALL 0.0001f
  288. #define PARAMETER_RANGE_DEFAULT_STEP_LARGE 0.1f
  289. /**@}*/
  290. /*!
  291. * @defgroup EventTypes EventTypes
  292. *
  293. * List of supported event types.
  294. *
  295. * The types are mapped into mapped_value_t by the host.
  296. * @see Plugin/UiHostDescriptor::map_value()
  297. * @{
  298. */
  299. /*!
  300. * Generic MIDI event.
  301. *
  302. * Realtime MIDI events are always used in-process,
  303. * while non realtime ones should be used in PluginDescriptor::non_rt_event().
  304. *
  305. * @see MidiEvent
  306. */
  307. #define EVENT_TYPE_MIDI "midi"
  308. /*!
  309. * Midi program event.
  310. *
  311. * Used in-process only.
  312. *
  313. * @see MidiProgramEvent
  314. */
  315. #define EVENT_TYPE_MIDI_PROGRAM "midiprogram"
  316. /*!
  317. * Parameter event.
  318. *
  319. * There are some rules for parameter events,
  320. * please see PARAMETER_IS_RTSAFE.
  321. *
  322. * @see ParameterEvent
  323. */
  324. #define EVENT_TYPE_PARAMETER "parameter"
  325. /*!
  326. * Time information event.
  327. *
  328. * Used in-process only.
  329. *
  330. * @see TimeInfoEvent
  331. */
  332. #define EVENT_TYPE_PARAMETER "time"
  333. /**@}*/
  334. /*!
  335. * @defgroup PluginDispatcherOpcodes Plugin Dispatcher Opcodes
  336. *
  337. * Opcodes dispatched by the host to report changes to the plugin or UI.
  338. *
  339. * The opcodes are mapped into MappedValue by the host.
  340. * @see PluginDescriptor::dispatcher()
  341. * @{
  342. */
  343. #define PLUGIN_OPCODE_MSG_RECEIVED "msgReceived" //!< Message received, uses ptr as char*.
  344. #define PLUGIN_OPCODE_BUFFER_SIZE_CHANGED "bufferSizeChanged" //!< Audio buffer size changed, uses value, returns 1 if supported. @see PluginHostDescriptor::get_buffer_size()
  345. #define PLUGIN_OPCODE_SAMPLE_RATE_CHANGED "sampleRateChanged" //!< Audio sample rate changed, uses opt, returns 1 if supported. @see Plugin/UiHostDescriptor::get_sample_rate()
  346. #define PLUGIN_OPCODE_OFFLINE_CHANGED "offlineChanged" //!< Offline mode changed, uses value (0=off, 1=on). @see Plugin/UiHostDescriptor::is_offline()
  347. #define PLUGIN_OPCODE_UI_TITLE_CHANGED "uiTitleChanged" //!< UI title changed, uses ptr. @see UiHostDescriptor::is_offline()
  348. /**@}*/
  349. /*!
  350. * @defgroup HostDispatcherOpcodes Host Dispatcher Opcodes
  351. *
  352. * Opcodes dispatched by the plugin or UI to report and request information from the host.
  353. *
  354. * The opcodes are mapped into MappedValue by the host.
  355. * @see HostDescriptor::dispatcher()
  356. * @{
  357. */
  358. #define HOST_OPCODE_NEEDS_IDLE "needsIdle" //!< Tell the host to call idle() as soon as possible (once), uses nothing.
  359. #define HOST_OPCODE_SET_VOLUME "setVolume" //!< Set host's volume, uses opt. MUST ONLY be called within PluginDescriptor::set_midi_program().
  360. #define HOST_OPCODE_SET_DRYWET "setDryWet" //!< Set host's dry-wet, uses opt. MUST ONLY be called within PluginDescriptor::set_midi_program().
  361. #define HOST_OPCODE_SET_BALANCE_LEFT "setBalanceLeft" //!< Set host's balance-left, uses opt. MUST ONLY be called within PluginDescriptor::set_midi_program().
  362. #define HOST_OPCODE_SET_BALANCE_RIGHT "setBalanceRight" //!< Set host's balance-right, uses opt. MUST ONLY be called within PluginDescriptor::set_midi_program().
  363. #define HOST_OPCODE_SET_PANNING "setPanning" //!< Set host's panning, uses opt. MUST ONLY be called within PluginDescriptor::set_midi_program().
  364. #define HOST_OPCODE_GET_PARAMETER_MIDI_CC "getParameterMidiCC" //!< Get the parameter @a index currently mapped MIDI control, uses index, return answer.
  365. #define HOST_OPCODE_SET_PARAMETER_MIDI_CC "setParameterMidiCC" //!< Set the parameter @a index mapped MIDI control, uses index and value.
  366. #define HOST_OPCODE_UPDATE_PARAMETER "updateParameter" //!< Tell the host to update parameter @a index, uses index with -1 for all.
  367. #define HOST_OPCODE_UPDATE_MIDI_PROGRAM "updateMidiProgram" //!< Tell the host to update midi-program @index, uses index with -1 for all; may also use value for channel.
  368. #define HOST_OPCODE_RELOAD_PARAMETERS "reloadParameters" //!< Tell the host to reload all parameters data, uses nothing.
  369. #define HOST_OPCODE_RELOAD_MIDI_PROGRAMS "reloadMidiPrograms" //!< Tell the host to reload all midi-programs data, uses nothing.
  370. #define HOST_OPCODE_RELOAD_ALL "reloadAll" //!< Tell the host to reload everything all the plugin, uses nothing.
  371. #define HOST_OPCODE_UI_UNAVAILABLE "uiUnavailable" //!< Tell the host the UI can't be shown, uses nothing.
  372. /**@}*/
  373. // -----------------------------------------------------------------------
  374. // Base types
  375. /*!
  376. * Audio sample type.
  377. */
  378. typedef float audio_sample_t;
  379. /*!
  380. * Host mapped value of a string.
  381. * The value 0 is reserved as undefined.
  382. * @see Plugin/UiHostDescriptor::map_value()
  383. */
  384. typedef uint32_t mapped_value_t;
  385. /*!
  386. * Opaque plugin handle.
  387. */
  388. typedef void* PluginHandle;
  389. /*!
  390. * Opaque UI handle.
  391. */
  392. typedef void* UiHandle;
  393. /*!
  394. * Opaque plugin host handle.
  395. */
  396. typedef void* PluginHostHandle;
  397. /*!
  398. * Opaque UI host handle.
  399. */
  400. typedef void* UiHostHandle;
  401. // -----------------------------------------------------------------------
  402. // Base structs
  403. /*!
  404. * Parameter scale point.
  405. */
  406. typedef struct {
  407. const char* label;
  408. float value;
  409. } ParameterScalePoint;
  410. /*!
  411. * Parameter ranges.
  412. */
  413. typedef struct {
  414. float def;
  415. float min;
  416. float max;
  417. float step;
  418. float stepSmall;
  419. float stepLarge;
  420. } ParameterRanges;
  421. /*!
  422. * Parameter.
  423. */
  424. typedef struct {
  425. const char* hints; //!< @see ParameterHints
  426. const char* name;
  427. const char* symbol;
  428. const char* unit;
  429. ParameterRanges ranges;
  430. uint32_t scalePointCount;
  431. ParameterScalePoint* scalePoints;
  432. } Parameter;
  433. /*!
  434. * MIDI Program.
  435. */
  436. typedef struct {
  437. uint32_t bank;
  438. uint32_t program;
  439. const char* name;
  440. } MidiProgram;
  441. /*!
  442. * Bar-Beat-Tick information.
  443. *
  444. * @note this is the same data provided by JACK
  445. */
  446. typedef struct {
  447. bool valid;
  448. int32_t bar; //!< current bar
  449. int32_t beat; //!< current beat-within-bar
  450. int32_t tick; //!< current tick-within-beat
  451. double barStartTick;
  452. float beatsPerBar; //!< time signature "numerator"
  453. float beatType; //!< time signature "denominator"
  454. double ticksPerBeat;
  455. double beatsPerMinute;
  456. } TimeInfoBBT;
  457. /*!
  458. * Time information.
  459. */
  460. typedef struct {
  461. bool playing;
  462. uint64_t frame;
  463. uint64_t usecs;
  464. TimeInfoBBT bbt;
  465. } TimeInfo;
  466. /*!
  467. * Generic event.
  468. */
  469. typedef struct {
  470. mapped_value_t type; //!< Type of event. @see EventTypes
  471. uint32_t frame; //!< Frame offset since the beginning of process()
  472. } Event;
  473. /*!
  474. * MIDI event.
  475. */
  476. typedef struct {
  477. Event e;
  478. uint8_t port;
  479. uint8_t size;
  480. uint8_t data[4];
  481. } MidiEvent;
  482. /*!
  483. * MIDI Program event.
  484. *
  485. * This is a special type of event that tells to plugin to switch MIDI program.
  486. * The plugin is allowed to change its parameter values, the host should request them afterwards if needed.
  487. *
  488. * If the plugin has PLUGIN_SUPPORTS_PROGRAM_CHANGES set, the host must never use event type.
  489. *
  490. * @see MidiProgram
  491. */
  492. typedef struct {
  493. Event e;
  494. uint8_t channel; // used only in synths
  495. uint32_t bank;
  496. uint32_t program;
  497. } MidiProgramEvent;
  498. /*!
  499. * Parameter event.
  500. */
  501. typedef struct {
  502. Event e;
  503. uint32_t index;
  504. float value;
  505. } ParameterEvent;
  506. /*!
  507. * Time information event.
  508. */
  509. typedef struct {
  510. Event e;
  511. TimeInfoBBT bbt;
  512. } TimeInfoEvent;
  513. // -----------------------------------------------------------------------
  514. // PluginHostDescriptor
  515. typedef struct {
  516. PluginHostHandle handle;
  517. /*!
  518. * Previously used plugin version, may be NULL.
  519. */
  520. const char* pluginVersion;
  521. // NOTE: NOT allowed during process()
  522. mapped_value_t (*map_value)(PluginHostHandle handle, const char* valueStr);
  523. const char* (*unmap_value)(PluginHostHandle handle, mapped_value_t value);
  524. // NOTE: always allowed
  525. uint32_t (*get_buffer_size)(PluginHostHandle handle);
  526. double (*get_sample_rate)(PluginHostHandle handle);
  527. bool (*is_offline)(PluginHostHandle handle);
  528. // plugin must set "time" feature to use this
  529. // NOTE: only allowed during process()
  530. const TimeInfo* (*get_time_info)(PluginHostHandle handle);
  531. // plugin must set "sendmsg" feature to use this
  532. // NOTE: only allowed during idle()
  533. bool (*send_ui_msg)(PluginHostHandle handle, const char* msg);
  534. // plugin must set "writeevent" feature to use this
  535. // NOTE: only allowed during process()
  536. bool (*write_event)(PluginHostHandle handle, const Event* event);
  537. // uses HostDispatcherOpcodes
  538. intptr_t (*dispatcher)(PluginHostHandle handle, MappedValue opcode, int32_t index, intptr_t value, void* ptr, float opt);
  539. } PluginHostDescriptor;
  540. // -----------------------------------------------------------------------
  541. // UiHostDescriptor
  542. typedef struct {
  543. UiHostHandle handle;
  544. const char* resourceDir;
  545. const char* uiTitle;
  546. mapped_value_t (*map_value)(UiHostHandle handle, const char* valueStr);
  547. const char* (*unmap_value)(UiHostHandle handle, mapped_value_t value);
  548. double (*get_sample_rate)(UiHostHandle handle);
  549. bool (*is_offline)(UiHostHandle handle);
  550. void (*parameter_changed)(UiHostHandle handle, uint32_t index, float value);
  551. void (*midi_program_changed)(UiHostHandle handle, uint8_t channel, uint32_t bank, uint32_t program);
  552. void (*closed)(UiHostHandle handle);
  553. // TODO: add some msgbox call
  554. // ui must set "opensave" feature to use these
  555. const char* (*open_file)(UiHostHandle handle, bool isDir, const char* title, const char* filter);
  556. const char* (*save_file)(UiHostHandle handle, bool isDir, const char* title, const char* filter);
  557. // ui must set "sendmsg" feature to use this
  558. bool (*send_plugin_msg)(const char* msg);
  559. // uses HostDispatcherOpcodes
  560. intptr_t (*dispatcher)(PluginHostHandle handle, MappedValue opcode, int32_t index, intptr_t value, void* ptr, float opt);
  561. } UiHostDescriptor;
  562. // -----------------------------------------------------------------------
  563. // PluginDescriptor
  564. typedef struct _PluginDescriptor {
  565. const int api; //!< Must be set to CARLA_NATIVE_API_VERSION.
  566. const char* const categories; //!< Categories. @see PluginCategories
  567. const char* const features; //!< Features. @see PluginFeatures
  568. const char* const supports; //!< MIDI supported events. @see PluginSupports
  569. const char* const metadata; //!< Meta-data in JSON? format.
  570. const uint32_t audioIns; //!< Default number of audio inputs.
  571. const uint32_t audioOuts; //!< Default number of audio outputs.
  572. const uint32_t midiIns; //!< Default number of MIDI inputs.
  573. const uint32_t midiOuts; //!< Default number of MIDI inputs.
  574. const uint32_t paramIns; //!< Default number of input parameters, may be 0.
  575. const uint32_t paramOuts; //!< Default number of output parameters, may be 0.
  576. const char* const author; //!< Author.
  577. const char* const name; //!< Name.
  578. const char* const label; //!< Label, can only contain letters, numbers and "_".
  579. const char* const copyright; //!< Copyright.
  580. const int version; //!< Version in hexadecimal (0x1023 = 1.0.23).
  581. PluginHandle (*instantiate)(const PluginHostDescriptor* host);
  582. void (*cleanup)(PluginHandle handle);
  583. uint32_t (*get_parameter_count)(PluginHandle handle);
  584. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  585. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  586. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index, float value); // only used if parameter hint "customtext" is set
  587. uint32_t (*get_midi_program_count)(PluginHandle handle);
  588. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  589. // NOTE: host will never call this while process() is running
  590. void (*non_rt_event)(PluginHandle handle, const Event* event);
  591. // only used if "idle" feature is set, or HOST_OPCODE_NEEDS_IDLE was triggered (for one-shot).
  592. // NOTE: although it's a non-realtime function, it will probably still not be called from the host main thread
  593. void (*idle)(PluginHandle handle);
  594. // only used if "state" feature is set
  595. char* (*get_state)(PluginHandle handle);
  596. void (*set_state)(PluginHandle handle, const char* data);
  597. void (*activate)(PluginHandle handle);
  598. void (*deactivate)(PluginHandle handle);
  599. void (*process)(PluginHandle handle, audio_sample_t** inBuffer, audio_sample_t** outBuffer, uint32_t frames, const Event* events, uint32_t eventCount);
  600. // uses PluginDispatcherOpcodes
  601. intptr_t (*dispatcher)(PluginHandle handle, MappedValue opcode, int32_t index, intptr_t value, void* ptr, float opt);
  602. } PluginDescriptor;
  603. // -----------------------------------------------------------------------
  604. // UiDescriptor
  605. typedef struct {
  606. const int api; //!< Must be set to CARLA_NATIVE_API_VERSION.
  607. const char* const features; //!< Features. @see UiFeatures
  608. const char* const author; //!< Author this UI matches to.
  609. const char* const label; //!< Label this UI matches to, can only contain letters, numbers and "_". May be null, in which case represents all UIs for @a maker.
  610. UiHandle (*instantiate)(const UiHostDescriptor* host);
  611. void (*cleanup)(UiHandle handle);
  612. void (*show)(UiHandle handle, bool show);
  613. void (*idle)(UiHandle handle);
  614. void (*event)(UiHandle handle, const Event* event);
  615. intptr_t (*dispatcher)(UiHandle handle, MappedValue opcode, int32_t index, intptr_t value, void* ptr, float opt);
  616. } UiDescriptor;
  617. // -----------------------------------------------------------------------
  618. // Register plugin
  619. extern void carla_register_native_plugin(const PluginDescriptor* desc);
  620. // -----------------------------------------------------------------------
  621. /**@}*/
  622. #ifdef __cplusplus
  623. } // extern "C"
  624. #endif
  625. #endif // CARLA_NATIVE_H_INCLUDED