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.

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