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.

880 lines
25KB

  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 "CarlaNative.h"
  21. #include "CarlaString.hpp"
  22. #ifndef DOXYGEN
  23. // Avoid including extra libs here
  24. struct LADSPA_RDF_Descriptor;
  25. typedef void* lo_address;
  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. public:
  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. /*!
  101. * This is the destructor of the base plugin class.
  102. */
  103. virtual ~CarlaPlugin();
  104. // -------------------------------------------------------------------
  105. // Information (base)
  106. /*!
  107. * Get the plugin's type (ie, a subclass of CarlaPlugin).
  108. *
  109. * \note Plugin bridges will return their respective plugin type, there is no plugin type such as "bridge".\n
  110. * To check if a plugin is a bridge use:
  111. * \code
  112. * if (hints() & PLUGIN_IS_BRIDGE)
  113. * ...
  114. * \endcode
  115. */
  116. virtual PluginType type() const = 0;
  117. /*!
  118. * Get the plugin's id (as passed in the constructor).
  119. *
  120. * \see setId()
  121. */
  122. unsigned int id() const
  123. {
  124. return fId;
  125. }
  126. /*!
  127. * Get the plugin's hints.
  128. *
  129. * \see PluginHints
  130. */
  131. unsigned int hints() const
  132. {
  133. return fHints;
  134. }
  135. /*!
  136. * Get the plugin's options.
  137. *
  138. * \see PluginOptions, availableOptions() and setOption()
  139. */
  140. unsigned int options() const
  141. {
  142. return fOptions;
  143. }
  144. /*!
  145. * Check if the plugin is enabled.\n
  146. * When a plugin is disabled, it will never be processed or managed in any way.\n
  147. * To 'bypass' a plugin use setActive() instead.
  148. *
  149. * \see setEnabled()
  150. */
  151. bool enabled() const
  152. {
  153. return fEnabled;
  154. }
  155. /*!
  156. * Get the plugin's internal name.\n
  157. * This name is unique within all plugins in an engine.
  158. *
  159. * \see getRealName()
  160. */
  161. const char* name() const
  162. {
  163. return (const char*)fName;
  164. }
  165. /*!
  166. * Get the currently loaded DLL filename for this plugin.\n
  167. * (Sound kits return their exact filename).
  168. */
  169. const char* filename() const
  170. {
  171. return (const char*)fFilename;
  172. }
  173. /*!
  174. * Get the plugin's category (delay, filter, synth, etc).
  175. */
  176. virtual PluginCategory category() const
  177. {
  178. return PLUGIN_CATEGORY_NONE;
  179. }
  180. /*!
  181. * Get the plugin's native unique Id.\n
  182. * May return 0 on plugin types that don't support Ids.
  183. */
  184. virtual long uniqueId() const
  185. {
  186. return 0;
  187. }
  188. /*!
  189. * Get the plugin's latency, in sample frames.
  190. */
  191. uint32_t latency() const;
  192. // -------------------------------------------------------------------
  193. // Information (count)
  194. /*!
  195. * Get the number of audio inputs.
  196. */
  197. virtual uint32_t audioInCount() const;
  198. /*!
  199. * Get the number of audio outputs.
  200. */
  201. virtual uint32_t audioOutCount() const;
  202. /*!
  203. * Get the number of MIDI inputs.
  204. */
  205. virtual uint32_t midiInCount() const;
  206. /*!
  207. * Get the number of MIDI outputs.
  208. */
  209. virtual uint32_t midiOutCount() const;
  210. /*!
  211. * Get the number of parameters.\n
  212. * To know the number of parameter inputs and outputs separately use getParameterCountInfo() instead.
  213. */
  214. uint32_t parameterCount() const;
  215. /*!
  216. * Get the number of scalepoints for parameter \a parameterId.
  217. */
  218. virtual uint32_t parameterScalePointCount(const uint32_t parameterId) const;
  219. /*!
  220. * Get the number of programs.
  221. */
  222. uint32_t programCount() const;
  223. /*!
  224. * Get the number of MIDI programs.
  225. */
  226. uint32_t midiProgramCount() const;
  227. /*!
  228. * Get the number of custom data sets.
  229. */
  230. uint32_t customDataCount() const;
  231. // -------------------------------------------------------------------
  232. // Information (current data)
  233. /*!
  234. * Get the current program number (-1 if unset).
  235. *
  236. * \see setProgram()
  237. */
  238. int32_t currentProgram() const;
  239. /*!
  240. * Get the current MIDI program number (-1 if unset).
  241. *
  242. * \see setMidiProgram()
  243. * \see setMidiProgramById()
  244. */
  245. int32_t currentMidiProgram() const;
  246. /*!
  247. * Get the parameter data of \a parameterId.
  248. */
  249. const ParameterData& parameterData(const uint32_t parameterId) const;
  250. /*!
  251. * Get the parameter ranges of \a parameterId.
  252. */
  253. const ParameterRanges& parameterRanges(const uint32_t parameterId) const;
  254. /*!
  255. * Check if parameter \a parameterId is of output type.
  256. */
  257. bool parameterIsOutput(const uint32_t parameterId) const;
  258. /*!
  259. * Get the MIDI program at \a index.
  260. *
  261. * \see getMidiProgramName()
  262. */
  263. const MidiProgramData& midiProgramData(const uint32_t index) const;
  264. /*!
  265. * Get the custom data set at \a index.
  266. *
  267. * \see setCustomData()
  268. */
  269. const CustomData& customData(const size_t index) const;
  270. /*!
  271. * Get the complete plugin chunk data into \a dataPtr.
  272. *
  273. * \return The size of the chunk or 0 if invalid.
  274. *
  275. * \note Make sure to verify the plugin supports chunks before calling this function!
  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. * Get the plugin's save state.\n
  357. * The plugin will automatically call prepareForSave() as needed.
  358. *
  359. * \see loadSaveState()
  360. */
  361. const SaveState& getSaveState();
  362. /*!
  363. * Get the plugin's save state.
  364. *
  365. * \see getSaveState()
  366. */
  367. void loadSaveState(const SaveState& saveState);
  368. // -------------------------------------------------------------------
  369. // Set data (internal stuff)
  370. /*!
  371. * Set the plugin's id to \a id.
  372. *
  373. * \see id()
  374. */
  375. void setId(const unsigned int id);
  376. /*!
  377. * Set a plugin's option.
  378. *
  379. * \see options()
  380. */
  381. void setOption(const unsigned int option, const bool yesNo);
  382. /*!
  383. * Enable or disable the plugin according to \a yesNo.
  384. *
  385. * When a plugin is disabled, it will never be processed or managed in any way.\n
  386. * To 'bypass' a plugin use setActive() instead.
  387. *
  388. * \see enabled()
  389. */
  390. void setEnabled(const bool yesNo);
  391. /*!
  392. * Set plugin as active according to \a active.
  393. *
  394. * \param sendOsc Send message change over OSC
  395. * \param sendCallback Send message change to registered callback
  396. */
  397. void setActive(const bool active, const bool sendOsc, const bool sendCallback);
  398. /*!
  399. * Set the plugin's dry/wet signal value to \a value.\n
  400. * \a value must be between 0.0 and 1.0.
  401. *
  402. * \param sendOsc Send message change over OSC
  403. * \param sendCallback Send message change to registered callback
  404. */
  405. void setDryWet(const float value, const bool sendOsc, const bool sendCallback);
  406. /*!
  407. * Set the plugin's output volume to \a value.\n
  408. * \a value must be between 0.0 and 1.27.
  409. *
  410. * \param sendOsc Send message change over OSC
  411. * \param sendCallback Send message change to registered callback
  412. */
  413. void setVolume(const float value, const bool sendOsc, const bool sendCallback);
  414. /*!
  415. * Set the plugin's output left balance value to \a value.\n
  416. * \a value must be between -1.0 and 1.0.
  417. *
  418. * \param sendOsc Send message change over OSC
  419. * \param sendCallback Send message change to registered callback
  420. *
  421. * \note Pure-Stereo plugins only!
  422. */
  423. void setBalanceLeft(const float value, const bool sendOsc, const bool sendCallback);
  424. /*!
  425. * Set the plugin's output right balance value to \a value.\n
  426. * \a value must be between -1.0 and 1.0.
  427. *
  428. * \param sendOsc Send message change over OSC
  429. * \param sendCallback Send message change to registered callback
  430. *
  431. * \note Pure-Stereo plugins only!
  432. */
  433. void setBalanceRight(const float value, const bool sendOsc, const bool sendCallback);
  434. /*!
  435. * Set the plugin's output panning value to \a value.\n
  436. * \a value must be between -1.0 and 1.0.
  437. *
  438. * \param sendOsc Send message change over OSC
  439. * \param sendCallback Send message change to registered callback
  440. *
  441. * \note Force-Stereo plugins only!
  442. */
  443. void setPanning(const float value, const bool sendOsc, const bool sendCallback);
  444. /*!
  445. * Set the plugin's midi control channel.
  446. *
  447. * \param sendOsc Send message change over OSC
  448. * \param sendCallback Send message change to registered callback
  449. */
  450. void setCtrlChannel(const int8_t channel, const bool sendOsc, const bool sendCallback);
  451. // -------------------------------------------------------------------
  452. // Set data (plugin-specific stuff)
  453. /*!
  454. * Set a plugin's parameter value.
  455. *
  456. * \param parameterId The parameter to change
  457. * \param value The new parameter value, must be within the parameter's range
  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. *
  462. * \see getParameterValue()
  463. */
  464. virtual void setParameterValue(const uint32_t parameterId, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback);
  465. /*!
  466. * Set a plugin's parameter value, including internal parameters.\n
  467. * \a rindex can be negative to allow internal parameters change (as defined in InternalParametersIndex).
  468. *
  469. * \see setParameterValue()
  470. * \see setActive()
  471. * \see setDryWet()
  472. * \see setVolume()
  473. * \see setBalanceLeft()
  474. * \see setBalanceRight()
  475. */
  476. void setParameterValueByRIndex(const int32_t rindex, const float value, const bool sendGui, const bool sendOsc, const bool sendCallback);
  477. /*!
  478. * Set parameter's \a parameterId MIDI channel to \a channel.\n
  479. * \a channel must be between 0 and 15.
  480. */
  481. void setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback);
  482. /*!
  483. * Set parameter's \a parameterId MIDI CC to \a cc.\n
  484. * \a cc must be between 0 and 95 (0x5F), or -1 for invalid.
  485. */
  486. void setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback);
  487. /*!
  488. * Add a custom data set.\n
  489. * If \a key already exists, its current value will be swapped with \a value.
  490. *
  491. * \param type Type of data used in \a value.
  492. * \param key A key identifing this data set.
  493. * \param value The value of the data set, of type \a type.
  494. * \param sendGui Send message change to plugin's custom GUI, if any
  495. *
  496. * \see customData()
  497. */
  498. virtual void setCustomData(const char* const type, const char* const key, const char* const value, const bool sendGui);
  499. /*!
  500. * Set the complete chunk data as \a stringData.\n
  501. * \a stringData must a base64 encoded string of binary data.
  502. *
  503. * \see chunkData()
  504. *
  505. * \note Make sure to verify the plugin supports chunks before calling this function!
  506. */
  507. virtual void setChunkData(const char* const stringData);
  508. /*!
  509. * Change the current plugin program to \a index.
  510. *
  511. * If \a index is negative the plugin's program will be considered unset.\n
  512. * The plugin's default parameter values will be updated when this function is called.
  513. *
  514. * \param index New program index to use
  515. * \param sendGui Send message change to plugin's custom GUI, if any
  516. * \param sendOsc Send message change over OSC
  517. * \param sendCallback Send message change to registered callback
  518. * \param block Block the audio callback
  519. */
  520. virtual void setProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback);
  521. /*!
  522. * Change the current MIDI plugin program to \a index.
  523. *
  524. * If \a index is negative the plugin's program will be considered unset.\n
  525. * The plugin's default parameter values will be updated when this function is called.
  526. *
  527. * \param index New program index to use
  528. * \param sendGui Send message change to plugin's custom GUI, if any
  529. * \param sendOsc Send message change over OSC
  530. * \param sendCallback Send message change to registered callback
  531. * \param block Block the audio callback
  532. */
  533. virtual void setMidiProgram(const int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback);
  534. /*!
  535. * This is an overloaded call to setMidiProgram().\n
  536. * It changes the current MIDI program using \a bank and \a program values instead of index.
  537. */
  538. void setMidiProgramById(const uint32_t bank, const uint32_t program, const bool sendGui, const bool sendOsc, const bool sendCallback);
  539. // -------------------------------------------------------------------
  540. // Set gui stuff
  541. /*!
  542. * Show (or hide) the plugin's custom GUI according to \a yesNo.
  543. *
  544. * \note This function must be always called from the main thread.
  545. */
  546. virtual void showGui(const bool yesNo);
  547. /*!
  548. * Idle the plugin's custom GUI.
  549. *
  550. * \note This function must be always called from the main thread.
  551. */
  552. virtual void idleGui();
  553. // -------------------------------------------------------------------
  554. // Plugin state
  555. /*!
  556. * Reload the plugin's entire state (including programs).\n
  557. * The plugin will be disabled during this call.
  558. */
  559. virtual void reload();
  560. /*!
  561. * Reload the plugin's programs state.
  562. */
  563. virtual void reloadPrograms(const bool init);
  564. /*!
  565. * Tell the plugin to prepare for save.
  566. */
  567. virtual void prepareForSave();
  568. // -------------------------------------------------------------------
  569. // Plugin processing
  570. /*!
  571. * Plugin process callback.
  572. */
  573. virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames);
  574. /*!
  575. * Tell the plugin the current buffer size has changed.
  576. */
  577. virtual void bufferSizeChanged(const uint32_t newBufferSize);
  578. /*!
  579. * Tell the plugin the current sample rate has changed.
  580. */
  581. virtual void sampleRateChanged(const double newSampleRate);
  582. /*!
  583. * Recreate latency audio buffers.
  584. */
  585. void recreateLatencyBuffers();
  586. // -------------------------------------------------------------------
  587. // OSC stuff
  588. /*!
  589. * Register this plugin to the engine's OSC client (controller or bridge).
  590. */
  591. void registerToOscClient();
  592. /*!
  593. * Update the plugin's internal OSC data according to \a source and \a url.\n
  594. * This is used for OSC-GUI bridges.
  595. */
  596. void updateOscData(const lo_address& source, const char* const url);
  597. /*!
  598. * Free the plugin's internal OSC memory data.
  599. */
  600. void freeOscData();
  601. /*!
  602. * Show the plugin's OSC based GUI.\n
  603. * This is a handy function that waits for the GUI to respond and automatically asks it to show itself.
  604. */
  605. bool waitForOscGuiShow();
  606. // -------------------------------------------------------------------
  607. // MIDI events
  608. /*!
  609. * Send a single midi note to be processed in the next audio callback.\n
  610. * A note with 0 velocity means note-off.
  611. * \note Non-RT call
  612. */
  613. void sendMidiSingleNote(const uint8_t channel, const uint8_t note, const uint8_t velo, const bool sendGui, const bool sendOsc, const bool sendCallback);
  614. /*!
  615. * Send all midi notes off for the next audio callback.\n
  616. * This doesn't send the actual MIDI All-Notes-Off event, but 128 note-offs instead.
  617. * \note RT call
  618. */
  619. void sendMidiAllNotesOff();
  620. // -------------------------------------------------------------------
  621. // Post-poned events
  622. /*!
  623. * Post pone an event of type \a type.\n
  624. * The event will be processed later, but as soon as possible.
  625. */
  626. void postponeRtEvent(const PluginPostRtEventType type, const int32_t value1, const int32_t value2, const float value3);
  627. /*!
  628. * Process all the post-poned events.
  629. * This function must be called from the main thread (ie, idleGui()) if PLUGIN_USES_SINGLE_THREAD is set.
  630. */
  631. void postRtEventsRun();
  632. /*!
  633. * Tell the UI a parameter has changed.
  634. */
  635. virtual void uiParameterChange(const uint32_t index, const float value);
  636. /*!
  637. * Tell the UI the current program has changed.
  638. */
  639. virtual void uiProgramChange(const uint32_t index);
  640. /*!
  641. * Tell the UI the current midi program has changed.
  642. */
  643. virtual void uiMidiProgramChange(const uint32_t index);
  644. /*!
  645. * Tell the UI a note has been pressed.
  646. */
  647. virtual void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo);
  648. /*!
  649. * Tell the UI a note has been released.
  650. */
  651. virtual void uiNoteOff(const uint8_t channel, const uint8_t note);
  652. // -------------------------------------------------------------------
  653. // Cleanup
  654. /*!
  655. * Initialize all RT buffers of the plugin.
  656. */
  657. virtual void initBuffers();
  658. /*!
  659. * Delete all temporary buffers of the plugin.
  660. */
  661. virtual void deleteBuffers();
  662. // -------------------------------------------------------------------
  663. // Library functions
  664. /*!
  665. * Open the DLL \a filename.
  666. */
  667. bool libOpen(const char* const filename);
  668. /*!
  669. * Close the DLL previously loaded in libOpen().
  670. */
  671. bool libClose();
  672. /*!
  673. * Get the symbol entry \a symbol of the currently loaded DLL.
  674. */
  675. void* libSymbol(const char* const symbol);
  676. /*!
  677. * Get the last DLL related error.
  678. */
  679. const char* libError(const char* const filename);
  680. // -------------------------------------------------------------------
  681. // Plugin initializers
  682. struct Initializer {
  683. CarlaEngine* const engine;
  684. const unsigned int id;
  685. const char* const filename;
  686. const char* const name;
  687. const char* const label;
  688. };
  689. static size_t getNativePluginCount();
  690. static const PluginDescriptor* getNativePluginDescriptor(const size_t index);
  691. static CarlaPlugin* newNative(const Initializer& init);
  692. static CarlaPlugin* newBridge(const Initializer& init, const BinaryType btype, const PluginType ptype, const char* const bridgeFilename);
  693. static CarlaPlugin* newLADSPA(const Initializer& init, const LADSPA_RDF_Descriptor* const rdfDescriptor);
  694. static CarlaPlugin* newDSSI(const Initializer& init, const char* const guiFilename);
  695. static CarlaPlugin* newLV2(const Initializer& init);
  696. static CarlaPlugin* newVST(const Initializer& init);
  697. static CarlaPlugin* newGIG(const Initializer& init);
  698. static CarlaPlugin* newSF2(const Initializer& init, const bool use16Outs);
  699. static CarlaPlugin* newSFZ(const Initializer& init);
  700. // -------------------------------------------------------------------
  701. protected:
  702. unsigned int fId;
  703. unsigned int fHints;
  704. unsigned int fOptions;
  705. bool fEnabled;
  706. CarlaString fName;
  707. CarlaString fFilename;
  708. friend struct CarlaPluginProtectedData;
  709. CarlaPluginProtectedData* const kData;
  710. // Fully disable plugin in scope and also its engine client
  711. // May wait-block on constructor for plugin process to end
  712. class ScopedDisabler
  713. {
  714. public:
  715. ScopedDisabler(CarlaPlugin* const plugin);
  716. ~ScopedDisabler();
  717. private:
  718. CarlaPlugin* const kPlugin;
  719. CARLA_PREVENT_HEAP_ALLOCATION
  720. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedDisabler)
  721. };
  722. // Lock the plugin's own run/process call
  723. // Plugin will still work as normal, but output only silence
  724. // On destructor needsReset flag is set, as the plugin might have missed some events
  725. class ScopedProcessLocker
  726. {
  727. public:
  728. ScopedProcessLocker(CarlaPlugin* const plugin, const bool block);
  729. ~ScopedProcessLocker();
  730. private:
  731. CarlaPlugin* const kPlugin;
  732. const bool kBlock;
  733. CARLA_PREVENT_HEAP_ALLOCATION
  734. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(ScopedProcessLocker)
  735. };
  736. private:
  737. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaPlugin)
  738. };
  739. /**@}*/
  740. CARLA_BACKEND_END_NAMESPACE
  741. #endif // __CARLA_PLUGIN_HPP__