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.

905 lines
27KB

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