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.

carla_plugin.hpp 23KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805
  1. /*
  2. * Carla Plugin API
  3. * Copyright (C) 2011-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 GPL.txt file
  16. */
  17. #ifndef __CARLA_PLUGIN_HPP__
  18. #define __CARLA_PLUGIN_HPP__
  19. #include "carla_backend.hpp"
  20. #include "carla_native.h"
  21. #include "carla_utils.hpp"
  22. // Avoid including extra libs here
  23. struct LADSPA_RDF_Descriptor;
  24. typedef void* lo_address;
  25. CARLA_BACKEND_START_NAMESPACE
  26. #if 0
  27. } // Fix editor indentation
  28. #endif
  29. #if 0 //ndef BUILD_BRIDGE
  30. enum PluginBridgeInfoType {
  31. kPluginBridgeAudioCount,
  32. kPluginBridgeMidiCount,
  33. kPluginBridgeParameterCount,
  34. kPluginBridgeProgramCount,
  35. kPluginBridgeMidiProgramCount,
  36. kPluginBridgePluginInfo,
  37. kPluginBridgeParameterInfo,
  38. kPluginBridgeParameterData,
  39. kPluginBridgeParameterRanges,
  40. kPluginBridgeProgramInfo,
  41. kPluginBridgeMidiProgramInfo,
  42. kPluginBridgeConfigure,
  43. kPluginBridgeSetParameterValue,
  44. kPluginBridgeSetDefaultValue,
  45. kPluginBridgeSetProgram,
  46. kPluginBridgeSetMidiProgram,
  47. kPluginBridgeSetCustomData,
  48. kPluginBridgeSetChunkData,
  49. kPluginBridgeUpdateNow,
  50. kPluginBridgeError
  51. };
  52. #endif
  53. enum PluginPostRtEventType {
  54. kPluginPostRtEventNull,
  55. kPluginPostRtEventDebug,
  56. kPluginPostRtEventParameterChange, // param, N, value
  57. kPluginPostRtEventProgramChange, // index
  58. kPluginPostRtEventMidiProgramChange, // index
  59. kPluginPostRtEventNoteOn, // channel, note, velo
  60. kPluginPostRtEventNoteOff // channel, note
  61. };
  62. // -----------------------------------------------------------------------
  63. /*!
  64. * Protected data used in CarlaPlugin and subclasses.\n
  65. * Non-plugin code MUST NEVER have direct access to this.
  66. */
  67. struct CarlaPluginProtectedData;
  68. /*!
  69. * \class CarlaPlugin
  70. *
  71. * \brief Carla Backend base plugin class
  72. *
  73. * This is the base class for all available plugin types available in Carla Backend.\n
  74. * All virtual calls are implemented in this class as fallback, so it's safe to only override needed calls.
  75. *
  76. * \see PluginType
  77. */
  78. class CarlaPlugin
  79. {
  80. public:
  81. /*!
  82. * This is the constructor of the base plugin class.
  83. *
  84. * \param engine The engine which this plugin belongs to, must not be null
  85. * \param id The 'id' of this plugin, must be between 0 and CarlaEngine::maxPluginNumber()
  86. */
  87. CarlaPlugin(CarlaEngine* const engine, const unsigned int id);
  88. /*!
  89. * This is the destructor of the base plugin class.
  90. */
  91. virtual ~CarlaPlugin();
  92. // -------------------------------------------------------------------
  93. // Information (base)
  94. /*!
  95. * Get the plugin's type (ie, a subclass of CarlaPlugin).
  96. *
  97. * \note Plugin bridges will return their respective plugin type, there is no plugin type such as "bridge".\n
  98. * To check if a plugin is a bridge use:
  99. * \code
  100. * if (hints() & PLUGIN_IS_BRIDGE)
  101. * ...
  102. * \endcode
  103. */
  104. virtual PluginType type() const
  105. {
  106. return PLUGIN_NONE;
  107. }
  108. /*!
  109. * Get the plugin's id (as passed in the constructor).
  110. *
  111. * \see setId()
  112. */
  113. unsigned int id() const;
  114. /*!
  115. * Get the plugin's hints.
  116. *
  117. * \see PluginHints
  118. */
  119. unsigned int hints() const;
  120. /*!
  121. * Get the plugin's options.
  122. *
  123. * \see PluginOptions
  124. */
  125. unsigned int options() const;
  126. /*!
  127. * Check if the plugin is enabled.
  128. *
  129. * \see setEnabled()
  130. */
  131. bool enabled() const;
  132. /*!
  133. * Get the plugin's internal name.\n
  134. * This name is unique within all plugins in an engine.
  135. *
  136. * \see getRealName()
  137. */
  138. const char* name() const;
  139. /*!
  140. * Get the currently loaded DLL filename for this plugin.\n
  141. * (Sound kits return their exact filename).
  142. */
  143. const char* filename() const;
  144. /*!
  145. * Get the plugin's category (delay, filter, synth, etc).
  146. */
  147. virtual PluginCategory category() const
  148. {
  149. return PLUGIN_CATEGORY_NONE;
  150. }
  151. /*!
  152. * Get the plugin's native unique Id.\n
  153. * May return 0 on plugin types that don't support Ids.
  154. */
  155. virtual long uniqueId() const
  156. {
  157. return 0;
  158. }
  159. /*!
  160. * Get the plugin's latency, in samples.
  161. */
  162. uint32_t latency() const;
  163. // -------------------------------------------------------------------
  164. // Information (count)
  165. /*!
  166. * Get the number of audio inputs.
  167. */
  168. virtual uint32_t audioInCount() const;
  169. /*!
  170. * Get the number of audio outputs.
  171. */
  172. virtual uint32_t audioOutCount() const;
  173. /*!
  174. * Get the number of MIDI inputs.
  175. */
  176. virtual uint32_t midiInCount() const;
  177. /*!
  178. * Get the number of MIDI outputs.
  179. */
  180. virtual uint32_t midiOutCount() const;
  181. /*!
  182. * Get the number of parameters.\n
  183. * To know the number of parameter inputs and outputs separately use getParameterCountInfo() instead.
  184. */
  185. uint32_t parameterCount() const;
  186. /*!
  187. * Get the number of scalepoints for parameter \a parameterId.
  188. */
  189. virtual uint32_t parameterScalePointCount(const uint32_t parameterId) const;
  190. /*!
  191. * Get the number of programs.
  192. */
  193. uint32_t programCount() const;
  194. /*!
  195. * Get the number of MIDI programs.
  196. */
  197. uint32_t midiProgramCount() const;
  198. /*!
  199. * Get the number of custom data sets.
  200. */
  201. size_t customDataCount() const;
  202. // -------------------------------------------------------------------
  203. // Information (current data)
  204. /*!
  205. * Get the current program number (-1 if unset).
  206. *
  207. * \see setProgram()
  208. */
  209. int32_t currentProgram() const;
  210. /*!
  211. * Get the current MIDI program number (-1 if unset).
  212. *
  213. * \see setMidiProgram()
  214. * \see setMidiProgramById()
  215. */
  216. int32_t currentMidiProgram() const;
  217. /*!
  218. * Get the parameter data of \a parameterId.
  219. */
  220. const ParameterData& parameterData(const uint32_t parameterId) const;
  221. /*!
  222. * Get the parameter ranges of \a parameterId.
  223. */
  224. const ParameterRanges& parameterRanges(const uint32_t parameterId) const;
  225. /*!
  226. * Check if parameter \a parameterId is of output type.
  227. */
  228. bool parameterIsOutput(const uint32_t parameterId) const;
  229. /*!
  230. * Get the MIDI program at \a index.
  231. *
  232. * \see getMidiProgramName()
  233. */
  234. const MidiProgramData& midiProgramData(const uint32_t index) const;
  235. /*!
  236. * Get the custom data set at \a index.
  237. *
  238. * \see setCustomData()
  239. */
  240. const CustomData& customData(const size_t index) const;
  241. /*!
  242. * Get the complete plugin chunk data into \a dataPtr.
  243. *
  244. * \return The size of the chunk or 0 if invalid.
  245. *
  246. * \note Make sure to verify the plugin supports chunks before calling this function!
  247. *
  248. * \see setChunkData()
  249. */
  250. virtual int32_t chunkData(void** const dataPtr);
  251. // -------------------------------------------------------------------
  252. // Information (per-plugin data)
  253. /*!
  254. * Get the current parameter value of \a parameterId.
  255. */
  256. virtual float getParameterValue(const uint32_t parameterId);
  257. /*!
  258. * Get the scalepoint \a scalePointId value of the parameter \a parameterId.
  259. */
  260. virtual float getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId);
  261. /*!
  262. * Get the plugin's label (URI for PLUGIN_LV2).
  263. */
  264. virtual void getLabel(char* const strBuf);
  265. /*!
  266. * Get the plugin's maker.
  267. */
  268. virtual void getMaker(char* const strBuf);
  269. /*!
  270. * Get the plugin's copyright/license.
  271. */
  272. virtual void getCopyright(char* const strBuf);
  273. /*!
  274. * Get the plugin's (real) name.
  275. *
  276. * \see name()
  277. */
  278. virtual void getRealName(char* const strBuf);
  279. /*!
  280. * Get the name of the parameter \a parameterId.
  281. */
  282. virtual void getParameterName(const uint32_t parameterId, char* const strBuf);
  283. /*!
  284. * Get the symbol of the parameter \a parameterId.
  285. */
  286. virtual void getParameterSymbol(const uint32_t parameterId, char* const strBuf);
  287. /*!
  288. * Get the custom text of the parameter \a parameterId.
  289. */
  290. virtual void getParameterText(const uint32_t parameterId, char* const strBuf);
  291. /*!
  292. * Get the unit of the parameter \a parameterId.
  293. */
  294. virtual void getParameterUnit(const uint32_t parameterId, char* const strBuf);
  295. /*!
  296. * Get the scalepoint \a scalePointId label of the parameter \a parameterId.
  297. */
  298. virtual void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf);
  299. /*!
  300. * Get the name of the program at \a index.
  301. */
  302. void getProgramName(const uint32_t index, char* const strBuf);
  303. /*!
  304. * Get the name of the MIDI program at \a index.
  305. *
  306. * \see getMidiProgramInfo()
  307. */
  308. void getMidiProgramName(const uint32_t index, char* const strBuf);
  309. /*!
  310. * Get information about the plugin's parameter count.\n
  311. * This is used to check how many input, output and total parameters are available.\n
  312. *
  313. * \note Some parameters might not be input or output (ie, invalid).
  314. *
  315. * \see parameterCount()
  316. */
  317. void getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total);
  318. // -------------------------------------------------------------------
  319. // Set data (internal stuff)
  320. /*!
  321. * Set the plugin's id to \a id.
  322. *
  323. * \see id()
  324. */
  325. void setId(const unsigned int id);
  326. /*!
  327. * Enable or disable the plugin according to \a yesNo.
  328. *
  329. * When a plugin is disabled, it will never be processed or managed in any way.\n
  330. * To 'bypass' a plugin use setActive() instead.
  331. *
  332. * \see enabled()
  333. */
  334. void setEnabled(const bool yesNo);
  335. /*!
  336. * Set plugin as active according to \a active.
  337. *
  338. * \param sendOsc Send message change over OSC
  339. * \param sendCallback Send message change to registered callback
  340. */
  341. void setActive(const bool active, const bool sendOsc, const bool sendCallback);
  342. /*!
  343. * Set the plugin's dry/wet signal value to \a value.\n
  344. * \a value must be between 0.0 and 1.0.
  345. *
  346. * \param sendOsc Send message change over OSC
  347. * \param sendCallback Send message change to registered callback
  348. */
  349. void setDryWet(const float value, const bool sendOsc, const bool sendCallback);
  350. /*!
  351. * Set the plugin's output volume to \a value.\n
  352. * \a value must be between 0.0 and 1.27.
  353. *
  354. * \param sendOsc Send message change over OSC
  355. * \param sendCallback Send message change to registered callback
  356. */
  357. void setVolume(const float value, const bool sendOsc, const bool sendCallback);
  358. /*!
  359. * Set the plugin's output left balance value to \a value.\n
  360. * \a value must be between -1.0 and 1.0.
  361. *
  362. * \param sendOsc Send message change over OSC
  363. * \param sendCallback Send message change to registered callback
  364. *
  365. * \note Pure-Stereo plugins only!
  366. */
  367. void setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback);
  368. /*!
  369. * Set the plugin's output right balance value to \a value.\n
  370. * \a value must be between -1.0 and 1.0.
  371. *
  372. * \param sendOsc Send message change over OSC
  373. * \param sendCallback Send message change to registered callback
  374. *
  375. * \note Pure-Stereo plugins only!
  376. */
  377. void setBalanceRight(const float value, const bool sendOsc, const bool sendCallback);
  378. /*!
  379. * Set the plugin's output panning value to \a value.\n
  380. * \a value must be between -1.0 and 1.0.
  381. *
  382. * \param sendOsc Send message change over OSC
  383. * \param sendCallback Send message change to registered callback
  384. *
  385. * \note Force-Stereo plugins only!
  386. */
  387. void setPanning(const float value, const bool sendOsc, const bool sendCallback);
  388. #if 0 //ndef BUILD_BRIDGE
  389. /*!
  390. * BridgePlugin call used to set internal data.
  391. */
  392. virtual int setOscBridgeInfo(const PluginBridgeInfoType type, const int argc, const lo_arg* const* const argv, const char* const types);
  393. #endif
  394. // -------------------------------------------------------------------
  395. // Set data (plugin-specific stuff)
  396. /*!
  397. * Set a plugin's parameter value.
  398. *
  399. * \param parameterId The parameter to change
  400. * \param value The new parameter value, must be within the parameter's range
  401. * \param sendGui Send message change to plugin's custom GUI, if any
  402. * \param sendOsc Send message change over OSC
  403. * \param sendCallback Send message change to registered callback
  404. *
  405. * \see getParameterValue()
  406. */
  407. virtual void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback);
  408. /*!
  409. * Set a plugin's parameter value, including internal parameters.\n
  410. * \a rindex can be negative to allow internal parameters change (as defined in InternalParametersIndex).
  411. *
  412. * \see setParameterValue()
  413. * \see setActive()
  414. * \see setDryWet()
  415. * \see setVolume()
  416. * \see setBalanceLeft()
  417. * \see setBalanceRight()
  418. */
  419. void setParameterValueByRIndex(const int32_t rindex, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback);
  420. /*!
  421. * Set parameter's \a parameterId MIDI channel to \a channel.\n
  422. * \a channel must be between 0 and 15.
  423. */
  424. void setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback);
  425. /*!
  426. * Set parameter's \a parameterId MIDI CC to \a cc.\n
  427. * \a cc must be between 0 and 95 (0x5F), or -1 for invalid.
  428. */
  429. void setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback);
  430. /*!
  431. * Add a custom data set.\n
  432. * If \a key already exists, its current value will be swapped with \a value.
  433. *
  434. * \param type Type of data used in \a value.
  435. * \param key A key identifing this data set.
  436. * \param value The value of the data set, of type \a type.
  437. * \param sendGui Send message change to plugin's custom GUI, if any
  438. *
  439. * \see customData()
  440. */
  441. virtual void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui);
  442. /*!
  443. * Set the complete chunk data as \a stringData.\n
  444. * \a stringData must a base64 encoded string of binary data.
  445. *
  446. * \see chunkData()
  447. *
  448. * \note Make sure to verify the plugin supports chunks before calling this function!
  449. */
  450. virtual void setChunkData(const char* const stringData);
  451. /*!
  452. * Change the current plugin program to \a index.
  453. *
  454. * If \a index is negative the plugin's program will be considered unset.\n
  455. * The plugin's default parameter values will be updated when this function is called.
  456. *
  457. * \param index New program index to use
  458. * \param sendGui Send message change to plugin's custom GUI, if any
  459. * \param sendOsc Send message change over OSC
  460. * \param sendCallback Send message change to registered callback
  461. * \param block Block the audio callback
  462. */
  463. virtual void setProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block);
  464. /*!
  465. * Change the current MIDI plugin program to \a index.
  466. *
  467. * If \a index is negative the plugin's program will be considered unset.\n
  468. * The plugin's default parameter values will be updated when this function is called.
  469. *
  470. * \param index New program index to use
  471. * \param sendGui Send message change to plugin's custom GUI, if any
  472. * \param sendOsc Send message change over OSC
  473. * \param sendCallback Send message change to registered callback
  474. * \param block Block the audio callback
  475. */
  476. virtual void setMidiProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block);
  477. /*!
  478. * This is an overloaded call to setMidiProgram().\n
  479. * It changes the current MIDI program using \a bank and \a program values instead of index.
  480. */
  481. void setMidiProgramById(const uint32_t bank, const uint32_t program, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block);
  482. // -------------------------------------------------------------------
  483. // Set gui stuff
  484. /*!
  485. * Show (or hide) the plugin's custom GUI according to \a yesNo.
  486. *
  487. * \note This function must be always called from the main thread.
  488. */
  489. virtual void showGui(const bool yesNo);
  490. /*!
  491. * Idle the plugin's custom GUI.
  492. *
  493. * \note This function must be always called from the main thread.
  494. */
  495. virtual void idleGui();
  496. // -------------------------------------------------------------------
  497. // Plugin state
  498. /*!
  499. * Reload the plugin's entire state (including programs).\n
  500. * The plugin will be disabled during this call.
  501. */
  502. virtual void reload();
  503. /*!
  504. * Reload the plugin's programs state.
  505. */
  506. virtual void reloadPrograms(const bool init);
  507. /*!
  508. * Tell the plugin to prepare for save.
  509. */
  510. virtual void prepareForSave();
  511. // -------------------------------------------------------------------
  512. // Plugin processing
  513. /*!
  514. * Plugin process callback.
  515. */
  516. virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t framesOffset = 0);
  517. /*!
  518. * Tell the plugin the current buffer size has changed.
  519. */
  520. virtual void bufferSizeChanged(const uint32_t newBufferSize);
  521. /*!
  522. * Tell the plugin the current sample rate has changed.
  523. */
  524. virtual void sampleRateChanged(const double newSampleRate);
  525. /*!
  526. * Recreate latency audio buffers.
  527. */
  528. void recreateLatencyBuffers();
  529. // -------------------------------------------------------------------
  530. // OSC stuff
  531. /*!
  532. * Register this plugin to the engine's OSC client (controller or bridge).
  533. */
  534. void registerToOscClient();
  535. /*!
  536. * Update the plugin's internal OSC data according to \a source and \a url.\n
  537. * This is used for OSC-GUI bridges.
  538. */
  539. void updateOscData(const lo_address& source, const char* const url);
  540. /*!
  541. * Free the plugin's internal OSC memory data.
  542. */
  543. void freeOscData();
  544. /*!
  545. * Show the plugin's OSC based GUI.\n
  546. * This is a handy function that waits for the GUI to respond and automatically asks it to show itself.
  547. */
  548. bool waitForOscGuiShow();
  549. // -------------------------------------------------------------------
  550. // MIDI events
  551. /*!
  552. * Send a single midi note to be processed in the next audio callback.\n
  553. * A note with 0 velocity means note-off.
  554. * \note Non-RT call
  555. */
  556. void sendMidiSingleNote(const uint8_t channel, const uint8_t note, const uint8_t velo, const bool sendGui, const bool sendOsc, const bool sendCallback);
  557. /*!
  558. * Send all midi notes off for the next audio callback.\n
  559. * This doesn't send the actual MIDI All-Notes-Off event, but 128 note-offs instead.
  560. */
  561. void sendMidiAllNotesOff();
  562. // -------------------------------------------------------------------
  563. // Post-poned events
  564. /*!
  565. * Post pone an event of type \a type.\n
  566. * The event will be processed later, but as soon as possible.
  567. */
  568. void postponeRtEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const double value3);
  569. /*!
  570. * Process all the post-poned events.
  571. * This function must be called from the main thread (ie, idleGui()) if PLUGIN_USES_SINGLE_THREAD is set.
  572. */
  573. void postRtEventsRun();
  574. /*!
  575. * Tell the UI a parameter has changed.
  576. */
  577. virtual void uiParameterChange(const uint32_t index, const double value);
  578. /*!
  579. * Tell the UI the current program has changed.
  580. */
  581. virtual void uiProgramChange(const uint32_t index);
  582. /*!
  583. * Tell the UI the current midi program has changed.
  584. */
  585. virtual void uiMidiProgramChange(const uint32_t index);
  586. /*!
  587. * Tell the UI a note has been pressed.
  588. */
  589. virtual void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo);
  590. /*!
  591. * Tell the UI a note has been released.
  592. */
  593. virtual void uiNoteOff(const uint8_t channel, const uint8_t note);
  594. // -------------------------------------------------------------------
  595. // Cleanup
  596. /*!
  597. * Initialize all RT buffers of the plugin.
  598. */
  599. virtual void initBuffers();
  600. /*!
  601. * Delete all temporary buffers of the plugin.
  602. */
  603. virtual void deleteBuffers();
  604. // -------------------------------------------------------------------
  605. // Library functions
  606. /*!
  607. * Open the DLL \a filename.
  608. */
  609. bool libOpen(const char* const filename);
  610. /*!
  611. * Close the DLL previously loaded in libOpen().
  612. */
  613. bool libClose();
  614. /*!
  615. * Get the symbol entry \a symbol of the currently loaded DLL.
  616. */
  617. void* libSymbol(const char* const symbol);
  618. /*!
  619. * Get the last DLL related error.
  620. */
  621. const char* libError(const char* const filename);
  622. // -------------------------------------------------------------------
  623. // Engine helpers
  624. /*!
  625. * TODO.
  626. */
  627. float* getAudioInPortBuffer(uint32_t index);
  628. /*!
  629. * TODO.
  630. */
  631. float* getAudioOutPortBuffer(uint32_t index);
  632. /*!
  633. * TODO.
  634. */
  635. CarlaEngine* getEngine() const;
  636. // -------------------------------------------------------------------
  637. // Plugin initializers
  638. struct Initializer {
  639. CarlaEngine* const engine;
  640. const unsigned int id;
  641. const char* const filename;
  642. const char* const name;
  643. const char* const label;
  644. };
  645. #ifndef BUILD_BRIDGE
  646. static size_t getNativePluginCount();
  647. static const PluginDescriptor* getNativePluginDescriptor(const size_t index);
  648. static CarlaPlugin* newNative(const Initializer& init);
  649. static CarlaPlugin* newBridge(const Initializer& init, const BinaryType btype, const PluginType ptype, const char* const bridgeFilename);
  650. #endif
  651. static CarlaPlugin* newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor);
  652. static CarlaPlugin* newDSSI(const Initializer& init, const char* const guiFilename);
  653. static CarlaPlugin* newLV2(const Initializer& init);
  654. static CarlaPlugin* newVST(const Initializer& init);
  655. static CarlaPlugin* newGIG(const Initializer& init);
  656. static CarlaPlugin* newSFZ(const Initializer& init);
  657. static CarlaPlugin* newSF2(const Initializer& init);
  658. // -------------------------------------------------------------------
  659. protected:
  660. ScopedPointer<CarlaPluginProtectedData> const fData;
  661. class ScopedDisabler
  662. {
  663. public:
  664. ScopedDisabler(CarlaPlugin* const plugin);
  665. ~ScopedDisabler();
  666. private:
  667. CarlaPlugin* const kPlugin;
  668. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedDisabler)
  669. };
  670. private:
  671. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPlugin)
  672. };
  673. /**@}*/
  674. CARLA_BACKEND_END_NAMESPACE
  675. #endif // __CARLA_PLUGIN_HPP__