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.

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