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.

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