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.

902 lines
26KB

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