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.

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