Collection of tools useful for audio production
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.

2248 lines
62KB

  1. /*
  2. * Carla Backend
  3. * Copyright (C) 2011-2012 Filipe Coelho <falktx@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * 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 COPYING file
  16. */
  17. #ifndef CARLA_PLUGIN_H
  18. #define CARLA_PLUGIN_H
  19. #include "carla_engine.h"
  20. #include "carla_midi.h"
  21. #include "carla_shared.h"
  22. #include "carla_lib_includes.h"
  23. #ifdef BUILD_BRIDGE
  24. # include "carla_bridge_osc.h"
  25. #endif
  26. // common includes
  27. #include <cmath>
  28. #include <cstdio>
  29. #include <cstdlib>
  30. #include <vector>
  31. #include <QtGui/QDialog>
  32. CARLA_BACKEND_START_NAMESPACE
  33. /*!
  34. * @defgroup CarlaBackendPlugin Carla Backend Plugin
  35. *
  36. * The Carla Backend Plugin.
  37. * @{
  38. */
  39. #define CARLA_PROCESS_CONTINUE_CHECK if (! m_enabled) { x_engine->callback(CALLBACK_DEBUG, m_id, m_enabled, 0, 0.0); return; }
  40. const unsigned short MAX_MIDI_EVENTS = 512;
  41. const unsigned short MAX_POST_EVENTS = 152;
  42. const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
  43. const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved
  44. const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now
  45. const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value
  46. const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue").\n If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file.
  47. #ifndef BUILD_BRIDGE
  48. enum PluginBridgeInfoType {
  49. PluginBridgeAudioCount,
  50. PluginBridgeMidiCount,
  51. PluginBridgeParameterCount,
  52. PluginBridgeProgramCount,
  53. PluginBridgeMidiProgramCount,
  54. PluginBridgePluginInfo,
  55. PluginBridgeParameterInfo,
  56. PluginBridgeParameterData,
  57. PluginBridgeParameterRanges,
  58. PluginBridgeProgramInfo,
  59. PluginBridgeMidiProgramInfo,
  60. PluginBridgeSetParameterValue,
  61. PluginBridgeSetDefaultValue,
  62. PluginBridgeSetProgram,
  63. PluginBridgeSetMidiProgram,
  64. PluginBridgeSetCustomData,
  65. PluginBridgeSetChunkData,
  66. PluginBridgeUpdateNow,
  67. PluginBridgeSaved
  68. };
  69. #endif
  70. enum PluginPostEventType {
  71. PluginPostEventNull,
  72. PluginPostEventDebug,
  73. PluginPostEventParameterChange, // param, N, value
  74. PluginPostEventProgramChange, // index
  75. PluginPostEventMidiProgramChange, // index
  76. PluginPostEventNoteOn, // channel, note, velo
  77. PluginPostEventNoteOff, // channel, note
  78. PluginPostEventCustom
  79. };
  80. struct PluginAudioData {
  81. uint32_t count;
  82. uint32_t* rindexes;
  83. CarlaEngineAudioPort** ports;
  84. PluginAudioData()
  85. : count(0),
  86. rindexes(nullptr),
  87. ports(nullptr) {}
  88. };
  89. struct PluginMidiData {
  90. CarlaEngineMidiPort* portMin;
  91. CarlaEngineMidiPort* portMout;
  92. PluginMidiData()
  93. : portMin(nullptr),
  94. portMout(nullptr) {}
  95. };
  96. struct PluginParameterData {
  97. uint32_t count;
  98. ParameterData* data;
  99. ParameterRanges* ranges;
  100. CarlaEngineControlPort* portCin;
  101. CarlaEngineControlPort* portCout;
  102. PluginParameterData()
  103. : count(0),
  104. data(nullptr),
  105. ranges(nullptr),
  106. portCin(nullptr),
  107. portCout(nullptr) {}
  108. };
  109. struct PluginProgramData {
  110. uint32_t count;
  111. int32_t current;
  112. const char** names;
  113. PluginProgramData()
  114. : count(0),
  115. current(-1),
  116. names(nullptr) {}
  117. };
  118. struct PluginMidiProgramData {
  119. uint32_t count;
  120. int32_t current;
  121. midi_program_t* data;
  122. PluginMidiProgramData()
  123. : count(0),
  124. current(-1),
  125. data(nullptr) {}
  126. };
  127. struct PluginPostEvent {
  128. PluginPostEventType type;
  129. int32_t value1;
  130. int32_t value2;
  131. double value3;
  132. const void* cdata;
  133. PluginPostEvent()
  134. : type(PluginPostEventNull),
  135. value1(-1),
  136. value2(-1),
  137. value3(0.0),
  138. cdata(nullptr) {}
  139. };
  140. struct ExternalMidiNote {
  141. int8_t channel; // invalid = -1
  142. uint8_t note;
  143. uint8_t velo;
  144. ExternalMidiNote()
  145. : channel(-1),
  146. note(0),
  147. velo(0) {}
  148. };
  149. // fallback data
  150. static ParameterData paramDataNull;
  151. static ParameterRanges paramRangesNull;
  152. static midi_program_t midiProgramNull;
  153. static CustomData customDataNull;
  154. /*!
  155. * \class CarlaPlugin
  156. *
  157. * \brief Carla Backend base plugin class
  158. *
  159. * This is the base class for all available plugin types available in Carla Backend.\n
  160. * All virtual calls are implemented in this class as fallback, so it's safe to only override needed calls.
  161. *
  162. * \see PluginType
  163. */
  164. class CarlaPlugin
  165. {
  166. public:
  167. /*!
  168. * This is the constructor of the base plugin class.
  169. *
  170. * \param engine The engine which this plugin belongs to, must not be null
  171. * \param id The 'id' of this plugin, must between 0 and CarlaEngine::maxPluginNumber()
  172. */
  173. CarlaPlugin(CarlaEngine* const engine, const unsigned short id)
  174. : m_id(id),
  175. x_engine(engine),
  176. x_client(nullptr),
  177. x_dryWet(1.0),
  178. x_volume(1.0),
  179. x_balanceLeft(-1.0),
  180. x_balanceRight(1.0)
  181. {
  182. Q_ASSERT(engine);
  183. Q_ASSERT(id < CarlaEngine::maxPluginNumber());
  184. qDebug("CarlaPlugin::CarlaPlugin(%p, %i)", engine, id);
  185. m_type = PLUGIN_NONE;
  186. m_hints = 0;
  187. m_active = false;
  188. m_activeBefore = false;
  189. m_enabled = false;
  190. m_lib = nullptr;
  191. m_name = nullptr;
  192. m_filename = nullptr;
  193. #ifndef BUILD_BRIDGE
  194. if (carlaOptions.processMode == PROCESS_MODE_CONTINUOUS_RACK)
  195. m_ctrlInChannel = m_id;
  196. else
  197. #endif
  198. m_ctrlInChannel = 0;
  199. #ifndef BUILD_BRIDGE
  200. osc.data.path = nullptr;
  201. osc.data.source = nullptr;
  202. osc.data.target = nullptr;
  203. osc.thread = nullptr;
  204. #endif
  205. }
  206. /*!
  207. * This is the de-constructor of the base plugin class.
  208. */
  209. virtual ~CarlaPlugin()
  210. {
  211. qDebug("CarlaPlugin::~CarlaPlugin()");
  212. // Remove client and ports
  213. if (x_client)
  214. {
  215. if (x_client->isActive())
  216. x_client->deactivate();
  217. removeClientPorts();
  218. delete x_client;
  219. }
  220. // Delete data
  221. deleteBuffers();
  222. // Unload DLL
  223. libClose();
  224. if (m_name)
  225. free((void*)m_name);
  226. if (m_filename)
  227. free((void*)m_filename);
  228. if (prog.count > 0)
  229. {
  230. for (uint32_t i=0; i < prog.count; i++)
  231. {
  232. if (prog.names[i])
  233. free((void*)prog.names[i]);
  234. }
  235. delete[] prog.names;
  236. }
  237. if (midiprog.count > 0)
  238. {
  239. for (uint32_t i=0; i < midiprog.count; i++)
  240. {
  241. if (midiprog.data[i].name)
  242. free((void*)midiprog.data[i].name);
  243. }
  244. delete[] midiprog.data;
  245. }
  246. if (custom.size() > 0)
  247. {
  248. for (size_t i=0; i < custom.size(); i++)
  249. {
  250. if (custom[i].key)
  251. free((void*)custom[i].key);
  252. if (custom[i].value)
  253. free((void*)custom[i].value);
  254. }
  255. custom.clear();
  256. }
  257. }
  258. // -------------------------------------------------------------------
  259. // Information (base)
  260. /*!
  261. * Get the plugin's type (ie, a subclass of CarlaPlugin).
  262. *
  263. * \note Plugin bridges will return their respective plugin type, there is no plugin type such as "bridge".\n
  264. * To check if a plugin is a bridge use:
  265. * \code
  266. * if (m_hints & PLUGIN_IS_BRIDGE)
  267. * ...
  268. * \endcode
  269. */
  270. PluginType type() const
  271. {
  272. return m_type;
  273. }
  274. /*!
  275. * Get the plugin's id (as passed in the constructor).
  276. *
  277. * \see setId()
  278. */
  279. unsigned short id() const
  280. {
  281. return m_id;
  282. }
  283. /*!
  284. * Get the plugin's hints.
  285. *
  286. * \see PluginHints
  287. */
  288. unsigned int hints() const
  289. {
  290. return m_hints;
  291. }
  292. /*!
  293. * Check if the plugin is enabled.
  294. *
  295. * \see setEnabled()
  296. */
  297. bool enabled() const
  298. {
  299. return m_enabled;
  300. }
  301. /*!
  302. * Get the plugin's internal name.\n
  303. * This name is unique within all plugins in an engine.
  304. *
  305. * \see getRealName()
  306. */
  307. const char* name() const
  308. {
  309. return m_name;
  310. }
  311. /*!
  312. * Get the currently loaded DLL filename for this plugin.\n
  313. * (Sound kits return their exact filename).
  314. */
  315. const char* filename() const
  316. {
  317. return m_filename;
  318. }
  319. /*!
  320. * Get the plugin's category (delay, filter, synth, etc).
  321. */
  322. virtual PluginCategory category()
  323. {
  324. return PLUGIN_CATEGORY_NONE;
  325. }
  326. /*!
  327. * Get the plugin's native unique Id.\n
  328. * May return 0 on plugin types that don't support Ids.
  329. */
  330. virtual long uniqueId()
  331. {
  332. return 0;
  333. }
  334. // -------------------------------------------------------------------
  335. // Information (count)
  336. /*!
  337. * Get the number of audio inputs.
  338. */
  339. virtual uint32_t audioInCount()
  340. {
  341. return aIn.count;
  342. }
  343. /*!
  344. * Get the number of audio outputs.
  345. */
  346. virtual uint32_t audioOutCount()
  347. {
  348. return aOut.count;
  349. }
  350. /*!
  351. * Get the number of MIDI inputs.
  352. */
  353. virtual uint32_t midiInCount()
  354. {
  355. return midi.portMin ? 1 : 0;
  356. }
  357. /*!
  358. * Get the number of MIDI outputs.
  359. */
  360. virtual uint32_t midiOutCount()
  361. {
  362. return midi.portMout ? 1 : 0;
  363. }
  364. /*!
  365. * Get the number of parameters.\n
  366. * To know the number of parameter inputs and outputs separately use getParameterCountInfo() instead.
  367. */
  368. uint32_t parameterCount() const
  369. {
  370. return param.count;
  371. }
  372. /*!
  373. * Get the number of scalepoints for parameter \a parameterId.
  374. */
  375. virtual uint32_t parameterScalePointCount(const uint32_t parameterId)
  376. {
  377. Q_ASSERT(parameterId < param.count);
  378. return 0;
  379. }
  380. /*!
  381. * Get the number of programs.
  382. */
  383. uint32_t programCount() const
  384. {
  385. return prog.count;
  386. }
  387. /*!
  388. * Get the number of MIDI programs.
  389. */
  390. uint32_t midiProgramCount() const
  391. {
  392. return midiprog.count;
  393. }
  394. /*!
  395. * Get the number of custom data sets.
  396. */
  397. size_t customDataCount() const
  398. {
  399. return custom.size();
  400. }
  401. // -------------------------------------------------------------------
  402. // Information (current data)
  403. /*!
  404. * Get the current program number (-1 if unset).
  405. *
  406. * \see setProgram()
  407. */
  408. int32_t currentProgram() const
  409. {
  410. return prog.current;
  411. }
  412. /*!
  413. * Get the current MIDI program number (-1 if unset).
  414. *
  415. * \see setMidiProgram()
  416. * \see setMidiProgramById()
  417. */
  418. int32_t currentMidiProgram() const
  419. {
  420. return midiprog.current;
  421. }
  422. /*!
  423. * Get the parameter data of \a parameterId.
  424. */
  425. const ParameterData* parameterData(const uint32_t parameterId) const
  426. {
  427. Q_ASSERT(parameterId < param.count);
  428. if (parameterId < param.count)
  429. return &param.data[parameterId];
  430. return &paramDataNull;
  431. }
  432. /*!
  433. * Get the parameter ranges of \a parameterId.
  434. */
  435. const ParameterRanges* parameterRanges(const uint32_t parameterId) const
  436. {
  437. Q_ASSERT(parameterId < param.count);
  438. if (parameterId < param.count)
  439. return &param.ranges[parameterId];
  440. return &paramRangesNull;
  441. }
  442. /*!
  443. * Check if parameter \a parameterId is of output type.
  444. */
  445. bool parameterIsOutput(const uint32_t parameterId) const
  446. {
  447. Q_ASSERT(parameterId < param.count);
  448. if (parameterId < param.count)
  449. return (param.data[parameterId].type == PARAMETER_OUTPUT);
  450. return false;
  451. }
  452. /*!
  453. * Get the MIDI program at \a index.
  454. *
  455. * \see getMidiProgramName()
  456. */
  457. const midi_program_t* midiProgramData(const uint32_t index) const
  458. {
  459. Q_ASSERT(index < midiprog.count);
  460. if (index < midiprog.count)
  461. return &midiprog.data[index];
  462. return &midiProgramNull;
  463. }
  464. /*!
  465. * Get the custom data set at \a index.
  466. *
  467. * \see setCustomData()
  468. */
  469. const CustomData* customData(const size_t index) const
  470. {
  471. Q_ASSERT(index < custom.size());
  472. if (index < custom.size())
  473. return &custom[index];
  474. return &customDataNull;
  475. }
  476. /*!
  477. * Get the complete plugin chunk data into \a dataPtr.
  478. *
  479. * \return The size of the chunk or 0 if invalid.
  480. *
  481. * \note Make sure to verify the plugin supports chunks before calling this function!
  482. *
  483. * \see setChunkData()
  484. */
  485. virtual int32_t chunkData(void** const dataPtr)
  486. {
  487. Q_ASSERT(dataPtr);
  488. return 0;
  489. }
  490. // -------------------------------------------------------------------
  491. // Information (per-plugin data)
  492. /*!
  493. * Get the current parameter value of \a parameterId.
  494. */
  495. virtual double getParameterValue(const uint32_t parameterId)
  496. {
  497. Q_ASSERT(parameterId < param.count);
  498. return 0.0;
  499. }
  500. /*!
  501. * Get the scalepoint \a scalePointId value of the parameter \a parameterId.
  502. */
  503. virtual double getParameterScalePointValue(const uint32_t parameterId, const uint32_t scalePointId)
  504. {
  505. Q_ASSERT(parameterId < param.count);
  506. Q_ASSERT(scalePointId < parameterScalePointCount(parameterId));
  507. return 0.0;
  508. }
  509. /*!
  510. * Get the plugin's label (URI for PLUGIN_LV2).
  511. */
  512. virtual void getLabel(char* const strBuf)
  513. {
  514. *strBuf = 0;
  515. }
  516. /*!
  517. * Get the plugin's maker.
  518. */
  519. virtual void getMaker(char* const strBuf)
  520. {
  521. *strBuf = 0;
  522. }
  523. /*!
  524. * Get the plugin's copyright/license.
  525. */
  526. virtual void getCopyright(char* const strBuf)
  527. {
  528. *strBuf = 0;
  529. }
  530. /*!
  531. * Get the plugin's (real) name.
  532. *
  533. * \see name()
  534. */
  535. virtual void getRealName(char* const strBuf)
  536. {
  537. *strBuf = 0;;
  538. }
  539. /*!
  540. * Get the name of the parameter \a parameterId.
  541. */
  542. virtual void getParameterName(const uint32_t parameterId, char* const strBuf)
  543. {
  544. Q_ASSERT(parameterId < param.count);
  545. *strBuf = 0;
  546. }
  547. /*!
  548. * Get the symbol of the parameter \a parameterId.
  549. */
  550. virtual void getParameterSymbol(const uint32_t parameterId, char* const strBuf)
  551. {
  552. Q_ASSERT(parameterId < param.count);
  553. *strBuf = 0;
  554. }
  555. /*!
  556. * Get the custom text of the parameter \a parameterId.
  557. */
  558. virtual void getParameterText(const uint32_t parameterId, char* const strBuf)
  559. {
  560. Q_ASSERT(parameterId < param.count);
  561. *strBuf = 0;
  562. }
  563. /*!
  564. * Get the unit of the parameter \a parameterId.
  565. */
  566. virtual void getParameterUnit(const uint32_t parameterId, char* const strBuf)
  567. {
  568. Q_ASSERT(parameterId < param.count);
  569. *strBuf = 0;
  570. }
  571. /*!
  572. * Get the scalepoint \a scalePointId label of the parameter \a parameterId.
  573. */
  574. virtual void getParameterScalePointLabel(const uint32_t parameterId, const uint32_t scalePointId, char* const strBuf)
  575. {
  576. Q_ASSERT(parameterId < param.count);
  577. Q_ASSERT(scalePointId < parameterScalePointCount(parameterId));
  578. *strBuf = 0;
  579. }
  580. /*!
  581. * Get the name of the program at \a index.
  582. */
  583. void getProgramName(const uint32_t index, char* const strBuf)
  584. {
  585. Q_ASSERT(index < prog.count);
  586. if (index < prog.count && prog.names[index])
  587. strncpy(strBuf, prog.names[index], STR_MAX);
  588. else
  589. *strBuf = 0;
  590. }
  591. /*!
  592. * Get the name of the MIDI program at \a index.
  593. *
  594. * \see getMidiProgramInfo()
  595. */
  596. void getMidiProgramName(const uint32_t index, char* const strBuf)
  597. {
  598. Q_ASSERT(index < midiprog.count);
  599. if (index < midiprog.count && midiprog.data[index].name)
  600. strncpy(strBuf, midiprog.data[index].name, STR_MAX);
  601. else
  602. *strBuf = 0;
  603. }
  604. /*!
  605. * Get information about the plugin's parameter count.\n
  606. * This is used to check how many input, output and total parameters are available.\n
  607. *
  608. * \note Some parameters might not be input or output (ie, invalid).
  609. *
  610. * \see parameterCount()
  611. */
  612. void getParameterCountInfo(uint32_t* const ins, uint32_t* const outs, uint32_t* const total)
  613. {
  614. *ins = 0;
  615. *outs = 0;
  616. *total = param.count;
  617. for (uint32_t i=0; i < param.count; i++)
  618. {
  619. if (param.data[i].type == PARAMETER_INPUT)
  620. *ins += 1;
  621. else if (param.data[i].type == PARAMETER_OUTPUT)
  622. *outs += 1;
  623. }
  624. }
  625. /*!
  626. * Get information about the plugin's custom GUI, if provided.
  627. */
  628. virtual void getGuiInfo(GuiType* const type, bool* const resizable)
  629. {
  630. *type = GUI_NONE;
  631. *resizable = false;
  632. }
  633. // -------------------------------------------------------------------
  634. // Set data (internal stuff)
  635. #ifndef BUILD_BRIDGE
  636. /*!
  637. * Set the plugin's id to \a id.
  638. *
  639. * \see id()
  640. */
  641. void setId(const unsigned short id)
  642. {
  643. m_id = id;
  644. if (carlaOptions.processMode == PROCESS_MODE_CONTINUOUS_RACK)
  645. m_ctrlInChannel = id;
  646. }
  647. #endif
  648. /*!
  649. * Enable or disable the plugin according to \a yesNo.
  650. *
  651. * When a plugin is disabled, it will never be processed or managed in any way.\n
  652. * To 'bypass' a plugin use setActive() instead.
  653. *
  654. * \see enabled()
  655. */
  656. void setEnabled(const bool yesNo)
  657. {
  658. m_enabled = yesNo;
  659. }
  660. /*!
  661. * Set plugin as active according to \a active.
  662. *
  663. * \param sendOsc Send message change over OSC
  664. * \param sendCallback Send message change to registered callback
  665. */
  666. void setActive(const bool active, const bool sendOsc, const bool sendCallback)
  667. {
  668. m_active = active;
  669. double value = active ? 1.0 : 0.0;
  670. #ifndef BUILD_BRIDGE
  671. if (sendOsc)
  672. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_ACTIVE, value);
  673. #else
  674. Q_UNUSED(sendOsc);
  675. #endif
  676. if (sendCallback)
  677. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, PARAMETER_ACTIVE, 0, value);
  678. #ifndef BUILD_BRIDGE
  679. else if (m_hints & PLUGIN_IS_BRIDGE)
  680. osc_send_control(&osc.data, PARAMETER_ACTIVE, value);
  681. #endif
  682. }
  683. /*!
  684. * Set the plugin's dry/wet signal value to \a value.\n
  685. * \a value must be between 0.0 and 1.0.
  686. *
  687. * \param sendOsc Send message change over OSC
  688. * \param sendCallback Send message change to registered callback
  689. */
  690. void setDryWet(double value, const bool sendOsc, const bool sendCallback)
  691. {
  692. Q_ASSERT(value >= 0.0 && value <= 1.0);
  693. if (value < 0.0)
  694. value = 0.0;
  695. else if (value > 1.0)
  696. value = 1.0;
  697. x_dryWet = value;
  698. #ifndef BUILD_BRIDGE
  699. if (sendOsc)
  700. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_DRYWET, value);
  701. #else
  702. Q_UNUSED(sendOsc);
  703. #endif
  704. if (sendCallback)
  705. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, PARAMETER_DRYWET, 0, value);
  706. #ifndef BUILD_BRIDGE
  707. else if (m_hints & PLUGIN_IS_BRIDGE)
  708. osc_send_control(&osc.data, PARAMETER_DRYWET, value);
  709. #endif
  710. }
  711. /*!
  712. * Set the plugin's output volume to \a value.\n
  713. * \a value must be between 0.0 and 1.27.
  714. *
  715. * \param sendOsc Send message change over OSC
  716. * \param sendCallback Send message change to registered callback
  717. */
  718. void setVolume(double value, const bool sendOsc, const bool sendCallback)
  719. {
  720. Q_ASSERT(value >= 0.0 && value <= 1.27);
  721. if (value < 0.0)
  722. value = 0.0;
  723. else if (value > 1.27)
  724. value = 1.27;
  725. x_volume = value;
  726. #ifndef BUILD_BRIDGE
  727. if (sendOsc)
  728. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_VOLUME, value);
  729. #else
  730. Q_UNUSED(sendOsc);
  731. #endif
  732. if (sendCallback)
  733. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, PARAMETER_VOLUME, 0, value);
  734. #ifndef BUILD_BRIDGE
  735. else if (m_hints & PLUGIN_IS_BRIDGE)
  736. osc_send_control(&osc.data, PARAMETER_VOLUME, value);
  737. #endif
  738. }
  739. /*!
  740. * Set the plugin's output left balance value to \a value.\n
  741. * \a value must be between -1.0 and 1.0.
  742. *
  743. * \param sendOsc Send message change over OSC
  744. * \param sendCallback Send message change to registered callback
  745. */
  746. void setBalanceLeft(double value, const bool sendOsc, const bool sendCallback)
  747. {
  748. Q_ASSERT(value >= -1.0 && value <= 1.0);
  749. if (value < -1.0)
  750. value = -1.0;
  751. else if (value > 1.0)
  752. value = 1.0;
  753. x_balanceLeft = value;
  754. #ifndef BUILD_BRIDGE
  755. if (sendOsc)
  756. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, value);
  757. #else
  758. Q_UNUSED(sendOsc);
  759. #endif
  760. if (sendCallback)
  761. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, PARAMETER_BALANCE_LEFT, 0, value);
  762. #ifndef BUILD_BRIDGE
  763. else if (m_hints & PLUGIN_IS_BRIDGE)
  764. osc_send_control(&osc.data, PARAMETER_BALANCE_LEFT, value);
  765. #endif
  766. }
  767. /*!
  768. * Set the plugin's output right balance value to \a value.\n
  769. * \a value must be between -1.0 and 1.0.
  770. *
  771. * \param sendOsc Send message change over OSC
  772. * \param sendCallback Send message change to registered callback
  773. */
  774. void setBalanceRight(double value, const bool sendOsc, const bool sendCallback)
  775. {
  776. Q_ASSERT(value >= -1.0 && value <= 1.0);
  777. if (value < -1.0)
  778. value = -1.0;
  779. else if (value > 1.0)
  780. value = 1.0;
  781. x_balanceRight = value;
  782. #ifndef BUILD_BRIDGE
  783. if (sendOsc)
  784. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, value);
  785. #else
  786. Q_UNUSED(sendOsc);
  787. #endif
  788. if (sendCallback)
  789. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, PARAMETER_BALANCE_RIGHT, 0, value);
  790. #ifndef BUILD_BRIDGE
  791. else if (m_hints & PLUGIN_IS_BRIDGE)
  792. osc_send_control(&osc.data, PARAMETER_BALANCE_RIGHT, value);
  793. #endif
  794. }
  795. #ifndef BUILD_BRIDGE
  796. /*!
  797. * BridgePlugin call used to set internal data.
  798. */
  799. virtual int setOscBridgeInfo(const PluginBridgeInfoType type, const int argc, const lo_arg* const* const argv, const char* const types)
  800. {
  801. return 1;
  802. Q_UNUSED(type);
  803. Q_UNUSED(argc);
  804. Q_UNUSED(argv);
  805. Q_UNUSED(types);
  806. }
  807. #endif
  808. // -------------------------------------------------------------------
  809. // Set data (plugin-specific stuff)
  810. /*!
  811. * Set a plugin's parameter value.
  812. *
  813. * \param parameterId The parameter to change
  814. * \param value The new parameter value, must be within the parameter's range
  815. * \param sendGui Send message change to plugin's custom GUI, if any
  816. * \param sendOsc Send message change over OSC
  817. * \param sendCallback Send message change to registered callback
  818. *
  819. * \see getParameterValue()
  820. */
  821. virtual void setParameterValue(const uint32_t parameterId, double value, const bool sendGui, const bool sendOsc, const bool sendCallback)
  822. {
  823. Q_ASSERT(parameterId < param.count);
  824. if (sendGui)
  825. uiParameterChange(parameterId, value);
  826. #ifndef BUILD_BRIDGE
  827. if (sendOsc)
  828. x_engine->osc_send_control_set_parameter_value(m_id, parameterId, value);
  829. #else
  830. Q_UNUSED(sendOsc);
  831. #endif
  832. if (sendCallback)
  833. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, parameterId, 0, value);
  834. }
  835. /*!
  836. * Set a plugin's parameter value, including internal parameters.\n
  837. * \a rindex can be negative to allow internal parameters change (as defined in InternalParametersIndex).
  838. *
  839. * \see setParameterValue()
  840. * \see setActive()
  841. * \see setDryWet()
  842. * \see setVolume()
  843. * \see setBalanceLeft()
  844. * \see setBalanceRight()
  845. */
  846. void setParameterValueByRIndex(const int32_t rindex, const double value, const bool sendGui, const bool sendOsc, const bool sendCallback)
  847. {
  848. Q_ASSERT(rindex >= PARAMETER_BALANCE_RIGHT && rindex != PARAMETER_NULL);
  849. if (rindex == PARAMETER_ACTIVE)
  850. return setActive(value > 0.0, sendOsc, sendCallback);
  851. if (rindex == PARAMETER_DRYWET)
  852. return setDryWet(value, sendOsc, sendCallback);
  853. if (rindex == PARAMETER_VOLUME)
  854. return setVolume(value, sendOsc, sendCallback);
  855. if (rindex == PARAMETER_BALANCE_LEFT)
  856. return setBalanceLeft(value, sendOsc, sendCallback);
  857. if (rindex == PARAMETER_BALANCE_RIGHT)
  858. return setBalanceRight(value, sendOsc, sendCallback);
  859. for (uint32_t i=0; i < param.count; i++)
  860. {
  861. if (param.data[i].rindex == rindex)
  862. return setParameterValue(i, value, sendGui, sendOsc, sendCallback);
  863. }
  864. }
  865. /*!
  866. * Set parameter's \a parameterId MIDI channel to \a channel.\n
  867. * \a channel must be between 0 and 15.
  868. */
  869. void setParameterMidiChannel(const uint32_t parameterId, uint8_t channel, const bool sendOsc, const bool sendCallback)
  870. {
  871. Q_ASSERT(parameterId < param.count && channel < 16);
  872. if (channel >= 16)
  873. channel = 16;
  874. param.data[parameterId].midiChannel = channel;
  875. #ifndef BUILD_BRIDGE
  876. if (sendOsc)
  877. x_engine->osc_send_control_set_parameter_midi_channel(m_id, parameterId, channel);
  878. #else
  879. Q_UNUSED(sendOsc);
  880. #endif
  881. if (sendCallback)
  882. x_engine->callback(CALLBACK_PARAMETER_MIDI_CHANNEL_CHANGED, m_id, parameterId, channel, 0.0);
  883. }
  884. /*!
  885. * Set parameter's \a parameterId MIDI CC to \a cc.\n
  886. * \a cc must be between 0 and 95 (0x5F), or -1 for invalid.
  887. */
  888. void setParameterMidiCC(const uint32_t parameterId, int16_t cc, const bool sendOsc, const bool sendCallback)
  889. {
  890. Q_ASSERT(parameterId < param.count && cc >= -1);
  891. if (cc < -1 || cc > 0x5F)
  892. cc = -1;
  893. param.data[parameterId].midiCC = cc;
  894. #ifndef BUILD_BRIDGE
  895. if (sendOsc)
  896. x_engine->osc_send_control_set_parameter_midi_cc(m_id, parameterId, cc);
  897. #else
  898. Q_UNUSED(sendOsc);
  899. #endif
  900. if (sendCallback)
  901. x_engine->callback(CALLBACK_PARAMETER_MIDI_CC_CHANGED, m_id, parameterId, cc, 0.0);
  902. }
  903. /*!
  904. * Add a custom data set.\n
  905. * If \a key already exists, its current value will be swapped with \a value.
  906. *
  907. * \param type Type of data used in \a value.
  908. * \param key A key identifing this data set.
  909. * \param value The value of the data set, of type \a type.
  910. * \param sendGui Send message change to plugin's custom GUI, if any
  911. *
  912. * \see customData()
  913. */
  914. virtual void setCustomData(const CustomDataType type, const char* const key, const char* const value, const bool sendGui)
  915. {
  916. Q_ASSERT(type != CUSTOM_DATA_INVALID);
  917. Q_ASSERT(key);
  918. Q_ASSERT(value);
  919. if (type == CUSTOM_DATA_INVALID)
  920. return qCritical("CarlaPlugin::setCustomData(%s, \"%s\", \"%s\", %s) - type is invalid", CustomDataType2str(type), key, value, bool2str(sendGui));
  921. if (! key)
  922. return qCritical("CarlaPlugin::setCustomData(%s, \"%s\", \"%s\", %s) - key is null", CustomDataType2str(type), key, value, bool2str(sendGui));
  923. if (! value)
  924. return qCritical("CarlaPlugin::setCustomData(%s, \"%s\", \"%s\", %s) - value is null", CustomDataType2str(type), key, value, bool2str(sendGui));
  925. bool saveData = true;
  926. switch (type)
  927. {
  928. case CUSTOM_DATA_INVALID:
  929. saveData = false;
  930. break;
  931. case CUSTOM_DATA_STRING:
  932. // Ignore some keys
  933. if (strncmp(key, "OSC:", 4) == 0 || strcmp(key, "guiVisible") == 0)
  934. saveData = false;
  935. else if (strcmp(key, CARLA_BRIDGE_MSG_SAVE_NOW) == 0 || strcmp(key, CARLA_BRIDGE_MSG_SET_CHUNK) == 0 || strcmp(key, CARLA_BRIDGE_MSG_SET_CUSTOM) == 0)
  936. saveData = false;
  937. break;
  938. default:
  939. break;
  940. }
  941. if (saveData)
  942. {
  943. // Check if we already have this key
  944. for (size_t i=0; i < custom.size(); i++)
  945. {
  946. if (strcmp(custom[i].key, key) == 0)
  947. {
  948. free((void*)custom[i].value);
  949. custom[i].value = strdup(value);
  950. return;
  951. }
  952. }
  953. // Otherwise store it
  954. CustomData newData;
  955. newData.type = type;
  956. newData.key = strdup(key);
  957. newData.value = strdup(value);
  958. custom.push_back(newData);
  959. }
  960. }
  961. /*!
  962. * Set the complete chunk data as \a stringData.\n
  963. * \a stringData must a base64 encoded string of binary data.
  964. *
  965. * \see chunkData()
  966. *
  967. * \note Make sure to verify the plugin supports chunks before calling this function!
  968. */
  969. virtual void setChunkData(const char* const stringData)
  970. {
  971. Q_ASSERT(stringData);
  972. }
  973. /*!
  974. * Change the current plugin program to \a index.
  975. *
  976. * If \a index is negative the plugin's program will be considered unset.\n
  977. * The plugin's default parameter values will be updated when this function is called.
  978. *
  979. * \param index New program index to use
  980. * \param sendGui Send message change to plugin's custom GUI, if any
  981. * \param sendOsc Send message change over OSC
  982. * \param sendCallback Send message change to registered callback
  983. * \param block Block the audio callback
  984. */
  985. virtual void setProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block)
  986. {
  987. Q_ASSERT(index >= -1 && index < (int32_t)prog.count);
  988. if (index < -1)
  989. index = -1;
  990. else if (index > (int32_t)prog.count)
  991. return;
  992. prog.current = index;
  993. if (sendGui && index >= 0)
  994. uiProgramChange(index);
  995. #ifndef BUILD_BRIDGE
  996. if (sendOsc)
  997. x_engine->osc_send_control_set_program(m_id, index);
  998. #else
  999. Q_UNUSED(sendOsc);
  1000. #endif
  1001. // Change default parameter values
  1002. if (index >= 0)
  1003. {
  1004. for (uint32_t i=0; i < param.count; i++)
  1005. {
  1006. param.ranges[i].def = getParameterValue(i);
  1007. #ifndef BUILD_BRIDGE
  1008. if (sendOsc)
  1009. x_engine->osc_send_control_set_default_value(m_id, i, param.ranges[i].def);
  1010. #endif
  1011. }
  1012. }
  1013. if (sendCallback)
  1014. x_engine->callback(CALLBACK_PROGRAM_CHANGED, m_id, index, 0, 0.0);
  1015. Q_UNUSED(block);
  1016. }
  1017. /*!
  1018. * Change the current MIDI plugin program to \a index.
  1019. *
  1020. * If \a index is negative the plugin's program will be considered unset.\n
  1021. * The plugin's default parameter values will be updated when this function is called.
  1022. *
  1023. * \param index New program index to use
  1024. * \param sendGui Send message change to plugin's custom GUI, if any
  1025. * \param sendOsc Send message change over OSC
  1026. * \param sendCallback Send message change to registered callback
  1027. * \param block Block the audio callback
  1028. */
  1029. virtual void setMidiProgram(int32_t index, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block)
  1030. {
  1031. Q_ASSERT(index >= -1 && index < (int32_t)midiprog.count);
  1032. if (index < -1)
  1033. index = -1;
  1034. else if (index > (int32_t)midiprog.count)
  1035. return;
  1036. midiprog.current = index;
  1037. if (sendGui && index >= 0)
  1038. uiMidiProgramChange(index);
  1039. #ifndef BUILD_BRIDGE
  1040. if (sendOsc)
  1041. x_engine->osc_send_control_set_midi_program(m_id, index);
  1042. #else
  1043. Q_UNUSED(sendOsc);
  1044. #endif
  1045. // Change default parameter values (sound banks never change defaults)
  1046. if (index >= 0 && m_type != PLUGIN_GIG && m_type != PLUGIN_SF2 && m_type != PLUGIN_SFZ)
  1047. {
  1048. for (uint32_t i=0; i < param.count; i++)
  1049. {
  1050. param.ranges[i].def = getParameterValue(i);
  1051. #ifndef BUILD_BRIDGE
  1052. if (sendOsc)
  1053. x_engine->osc_send_control_set_default_value(m_id, i, param.ranges[i].def);
  1054. #endif
  1055. }
  1056. }
  1057. if (sendCallback)
  1058. x_engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, m_id, index, 0, 0.0);
  1059. Q_UNUSED(block);
  1060. }
  1061. /*!
  1062. * This is an overloaded call to setMidiProgram().\n
  1063. * It changes the current MIDI program using \a bank and \a program values instead of index.
  1064. */
  1065. void setMidiProgramById(const uint32_t bank, const uint32_t program, const bool sendGui, const bool sendOsc, const bool sendCallback, const bool block)
  1066. {
  1067. Q_ASSERT(program < 128);
  1068. for (uint32_t i=0; i < midiprog.count; i++)
  1069. {
  1070. if (midiprog.data[i].bank == bank && midiprog.data[i].program == program)
  1071. return setMidiProgram(i, sendGui, sendOsc, sendCallback, block);
  1072. }
  1073. }
  1074. // -------------------------------------------------------------------
  1075. // Set gui stuff
  1076. /*!
  1077. * Set the plugin's custom GUI data.\n
  1078. * Parameters change between plugin types.
  1079. *
  1080. * \note This function must be always called from the main thread.
  1081. */
  1082. virtual void setGuiData(QDialog* const dialog)
  1083. {
  1084. Q_UNUSED(dialog);
  1085. }
  1086. /*!
  1087. * Show (or hide) the plugin's custom GUI according to \a yesNo.
  1088. *
  1089. * \note This function must be always called from the main thread.
  1090. */
  1091. virtual void showGui(const bool yesNo)
  1092. {
  1093. Q_UNUSED(yesNo);
  1094. }
  1095. /*!
  1096. * Idle the plugin's custom GUI.
  1097. *
  1098. * \note This function must be always called from the main thread.
  1099. */
  1100. virtual void idleGui()
  1101. {
  1102. if (! m_enabled)
  1103. return;
  1104. if (m_hints & PLUGIN_USES_SINGLE_THREAD)
  1105. {
  1106. // Process postponed events
  1107. postEventsRun();
  1108. // Update parameter outputs
  1109. for (uint32_t i=0; i < param.count; i++)
  1110. {
  1111. if (param.data[i].type == PARAMETER_OUTPUT)
  1112. uiParameterChange(i, getParameterValue(i));
  1113. }
  1114. }
  1115. }
  1116. // -------------------------------------------------------------------
  1117. // Plugin state
  1118. /*!
  1119. * Reload the plugin's entire state (including programs).\n
  1120. * The plugin will be disabled during this call.
  1121. */
  1122. virtual void reload()
  1123. {
  1124. }
  1125. /*!
  1126. * Reload the plugin's programs state.
  1127. */
  1128. virtual void reloadPrograms(const bool init)
  1129. {
  1130. Q_UNUSED(init);
  1131. }
  1132. /*!
  1133. * Tell the plugin to prepare for save.
  1134. */
  1135. virtual void prepareForSave()
  1136. {
  1137. }
  1138. // -------------------------------------------------------------------
  1139. // Plugin processing
  1140. /*!
  1141. * Plugin process callback.
  1142. */
  1143. virtual void process(float** const inBuffer, float** const outBuffer, const uint32_t frames, const uint32_t framesOffset = 0)
  1144. {
  1145. Q_UNUSED(inBuffer);
  1146. Q_UNUSED(outBuffer);
  1147. Q_UNUSED(frames);
  1148. Q_UNUSED(framesOffset);
  1149. }
  1150. #ifdef CARLA_ENGINE_JACK
  1151. /*!
  1152. * Plugin process callback, JACK helper version.
  1153. */
  1154. void process_jack(const uint32_t nframes)
  1155. {
  1156. float* inBuffer[aIn.count];
  1157. float* outBuffer[aOut.count];
  1158. for (uint32_t i=0; i < aIn.count; i++)
  1159. inBuffer[i] = aIn.ports[i]->getJackAudioBuffer(nframes);
  1160. for (uint32_t i=0; i < aOut.count; i++)
  1161. outBuffer[i] = aOut.ports[i]->getJackAudioBuffer(nframes);
  1162. #ifndef BUILD_BRIDGE
  1163. if (carlaOptions.processHighPrecision)
  1164. {
  1165. float* inBuffer2[aIn.count];
  1166. float* outBuffer2[aOut.count];
  1167. for (uint32_t i=0, j; i < nframes; i += 8)
  1168. {
  1169. for (j=0; j < aIn.count; j++)
  1170. inBuffer2[j] = inBuffer[j] + i;
  1171. for (j=0; j < aOut.count; j++)
  1172. outBuffer2[j] = outBuffer[j] + i;
  1173. process(inBuffer2, outBuffer2, 8, i);
  1174. }
  1175. }
  1176. else
  1177. #endif
  1178. process(inBuffer, outBuffer, nframes);
  1179. }
  1180. #endif
  1181. /*!
  1182. * Tell the plugin the current buffer size has changed.
  1183. */
  1184. virtual void bufferSizeChanged(const uint32_t newBufferSize)
  1185. {
  1186. Q_UNUSED(newBufferSize);
  1187. }
  1188. // -------------------------------------------------------------------
  1189. // OSC stuff
  1190. /*!
  1191. * Register this plugin to the engine's OSC controller.
  1192. */
  1193. void registerToOsc()
  1194. {
  1195. #ifndef BUILD_BRIDGE
  1196. if (! x_engine->isOscControllerRegisted())
  1197. return;
  1198. x_engine->osc_send_control_add_plugin(m_id, m_name);
  1199. #endif
  1200. // Base data
  1201. {
  1202. char bufName[STR_MAX] = { 0 };
  1203. char bufLabel[STR_MAX] = { 0 };
  1204. char bufMaker[STR_MAX] = { 0 };
  1205. char bufCopyright[STR_MAX] = { 0 };
  1206. getRealName(bufName);
  1207. getLabel(bufLabel);
  1208. getMaker(bufMaker);
  1209. getCopyright(bufCopyright);
  1210. #ifdef BUILD_BRIDGE
  1211. x_engine->osc_send_bridge_plugin_info(category(), m_hints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId());
  1212. #else
  1213. x_engine->osc_send_control_set_plugin_data(m_id, m_type, category(), m_hints, bufName, bufLabel, bufMaker, bufCopyright, uniqueId());
  1214. #endif
  1215. }
  1216. // Base count
  1217. {
  1218. uint32_t cIns, cOuts, cTotals;
  1219. getParameterCountInfo(&cIns, &cOuts, &cTotals);
  1220. #ifdef BUILD_BRIDGE
  1221. x_engine->osc_send_bridge_audio_count(audioInCount(), audioOutCount(), audioInCount() + audioOutCount());
  1222. x_engine->osc_send_bridge_midi_count(midiInCount(), midiOutCount(), midiInCount() + midiOutCount());
  1223. x_engine->osc_send_bridge_parameter_count(cIns, cOuts, cTotals);
  1224. #else
  1225. x_engine->osc_send_control_set_plugin_ports(m_id, audioInCount(), audioOutCount(), midiInCount(), midiOutCount(), cIns, cOuts, cTotals);
  1226. #endif
  1227. }
  1228. // Internal Parameters
  1229. {
  1230. #ifndef BUILD_BRIDGE
  1231. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_ACTIVE, m_active ? 1.0 : 0.0);
  1232. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_DRYWET, x_dryWet);
  1233. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_VOLUME, x_volume);
  1234. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_LEFT, x_balanceLeft);
  1235. x_engine->osc_send_control_set_parameter_value(m_id, PARAMETER_BALANCE_RIGHT, x_balanceRight);
  1236. #endif
  1237. }
  1238. // Plugin Parameters
  1239. #ifdef BUILD_BRIDGE
  1240. uint32_t maxParameters = MAX_PARAMETERS;
  1241. #else
  1242. uint32_t maxParameters = carlaOptions.maxParameters;
  1243. #endif
  1244. if (param.count > 0 && param.count < maxParameters)
  1245. {
  1246. char bufName[STR_MAX], bufUnit[STR_MAX];
  1247. for (uint32_t i=0; i < param.count; i++)
  1248. {
  1249. getParameterName(i, bufName);
  1250. getParameterUnit(i, bufUnit);
  1251. #ifdef BUILD_BRIDGE
  1252. x_engine->osc_send_bridge_parameter_info(i, bufName, bufUnit);
  1253. x_engine->osc_send_bridge_parameter_data(i, param.data[i].type, param.data[i].rindex, param.data[i].hints, param.data[i].midiChannel, param.data[i].midiCC);
  1254. x_engine->osc_send_bridge_parameter_ranges(i, param.ranges[i].def, param.ranges[i].min, param.ranges[i].max, param.ranges[i].step, param.ranges[i].stepSmall, param.ranges[i].stepLarge);
  1255. x_engine->osc_send_bridge_set_parameter_value(i, getParameterValue(i));
  1256. #else
  1257. x_engine->osc_send_control_set_parameter_data(m_id, i, param.data[i].type, param.data[i].hints, bufName, bufUnit, getParameterValue(i));
  1258. x_engine->osc_send_control_set_parameter_ranges(m_id, i, param.ranges[i].min, param.ranges[i].max, param.ranges[i].def, param.ranges[i].step, param.ranges[i].stepSmall, param.ranges[i].stepLarge);
  1259. x_engine->osc_send_control_set_parameter_value(m_id, i, getParameterValue(i));
  1260. #endif
  1261. }
  1262. }
  1263. // Programs
  1264. {
  1265. #ifdef BUILD_BRIDGE
  1266. x_engine->osc_send_bridge_program_count(prog.count);
  1267. for (uint32_t i=0; i < prog.count; i++)
  1268. x_engine->osc_send_bridge_program_info(i, prog.names[i]);
  1269. x_engine->osc_send_bridge_set_program(prog.current);
  1270. #else
  1271. x_engine->osc_send_control_set_program_count(m_id, prog.count);
  1272. for (uint32_t i=0; i < prog.count; i++)
  1273. x_engine->osc_send_control_set_program_name(m_id, i, prog.names[i]);
  1274. x_engine->osc_send_control_set_program(m_id, prog.current);
  1275. #endif
  1276. }
  1277. // MIDI Programs
  1278. {
  1279. #ifdef BUILD_BRIDGE
  1280. x_engine->osc_send_bridge_midi_program_count(midiprog.count);
  1281. for (uint32_t i=0; i < midiprog.count; i++)
  1282. x_engine->osc_send_bridge_midi_program_info(i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
  1283. x_engine->osc_send_bridge_set_midi_program(prog.current);
  1284. #else
  1285. x_engine->osc_send_control_set_midi_program_count(m_id, midiprog.count);
  1286. for (uint32_t i=0; i < midiprog.count; i++)
  1287. x_engine->osc_send_control_set_midi_program_data(m_id, i, midiprog.data[i].bank, midiprog.data[i].program, midiprog.data[i].name);
  1288. x_engine->osc_send_control_set_midi_program(m_id, midiprog.current);
  1289. #endif
  1290. }
  1291. }
  1292. #ifndef BUILD_BRIDGE
  1293. /*!
  1294. * Update the plugin's internal OSC data according to \a source and \a url.\n
  1295. * This is used for OSC-GUI bridges.
  1296. */
  1297. void updateOscData(const lo_address source, const char* const url)
  1298. {
  1299. const char* host;
  1300. const char* port;
  1301. osc_clear_data(&osc.data);
  1302. host = lo_address_get_hostname(source);
  1303. port = lo_address_get_port(source);
  1304. osc.data.source = lo_address_new(host, port);
  1305. host = lo_url_get_hostname(url);
  1306. port = lo_url_get_port(url);
  1307. osc.data.path = lo_url_get_path(url);
  1308. osc.data.target = lo_address_new(host, port);
  1309. free((void*)host);
  1310. free((void*)port);
  1311. if (m_hints & PLUGIN_IS_BRIDGE)
  1312. return;
  1313. osc_send_sample_rate(&osc.data, x_engine->getSampleRate());
  1314. for (size_t i=0; i < custom.size(); i++)
  1315. {
  1316. // TODO
  1317. //if (m_type == PLUGIN_LV2)
  1318. //osc_send_lv2_transfer_event(&osc.data, getCustomDataTypeString(custom[i].type), /*custom[i].key,*/ custom[i].value);
  1319. //else
  1320. if (custom[i].type == CUSTOM_DATA_STRING)
  1321. osc_send_configure(&osc.data, custom[i].key, custom[i].value);
  1322. }
  1323. if (prog.current >= 0)
  1324. osc_send_program(&osc.data, prog.current);
  1325. if (midiprog.current >= 0)
  1326. {
  1327. if (m_type == PLUGIN_DSSI)
  1328. osc_send_program(&osc.data, midiprog.data[midiprog.current].bank, midiprog.data[midiprog.current].program);
  1329. else
  1330. osc_send_midi_program(&osc.data, midiprog.data[midiprog.current].bank, midiprog.data[midiprog.current].program);
  1331. }
  1332. for (uint32_t i=0; i < param.count; i++)
  1333. osc_send_control(&osc.data, param.data[i].rindex, getParameterValue(i));
  1334. // if (m_hints & PLUGIN_IS_BRIDGE)
  1335. // {
  1336. // osc_send_control(&osc.data, PARAMETER_ACTIVE, m_active ? 1.0 : 0.0);
  1337. // osc_send_control(&osc.data, PARAMETER_DRYWET, x_dryWet);
  1338. // osc_send_control(&osc.data, PARAMETER_VOLUME, x_volume);
  1339. // osc_send_control(&osc.data, PARAMETER_BALANCE_LEFT, x_balanceLeft);
  1340. // osc_send_control(&osc.data, PARAMETER_BALANCE_RIGHT, x_balanceRight);
  1341. // }
  1342. }
  1343. /*!
  1344. * Clear the plugin's internal OSC data.
  1345. */
  1346. void clearOscData()
  1347. {
  1348. osc_clear_data(&osc.data);
  1349. }
  1350. /*!
  1351. * Show the plugin's OSC based GUI.\n
  1352. * This is a handy function that waits for the GUI to respond and automatically asks it to show itself.
  1353. */
  1354. bool showOscGui()
  1355. {
  1356. // wait for UI 'update' call
  1357. for (uint i=0; i < carlaOptions.oscUiTimeout; i++)
  1358. {
  1359. if (osc.data.target)
  1360. {
  1361. osc_send_show(&osc.data);
  1362. return true;
  1363. }
  1364. else
  1365. carla_msleep(100);
  1366. }
  1367. return false;
  1368. }
  1369. #endif
  1370. // -------------------------------------------------------------------
  1371. // MIDI events
  1372. /*!
  1373. * Send a single midi note to be processed in the next audio callback.\n
  1374. * A note with 0 velocity means note-off.
  1375. */
  1376. void sendMidiSingleNote(const uint8_t channel, const uint8_t note, const uint8_t velo, const bool sendGui, const bool sendOsc, const bool sendCallback)
  1377. {
  1378. Q_ASSERT(channel < 16);
  1379. Q_ASSERT(note < 128);
  1380. Q_ASSERT(velo < 128);
  1381. engineMidiLock();
  1382. for (unsigned short i=0; i < MAX_MIDI_EVENTS; i++)
  1383. {
  1384. if (extMidiNotes[i].channel < 0)
  1385. {
  1386. extMidiNotes[i].channel = channel;
  1387. extMidiNotes[i].note = note;
  1388. extMidiNotes[i].velo = velo;
  1389. break;
  1390. }
  1391. }
  1392. engineMidiUnlock();
  1393. if (sendGui)
  1394. {
  1395. if (velo > 0)
  1396. uiNoteOn(channel, note, velo);
  1397. else
  1398. uiNoteOff(channel, note);
  1399. }
  1400. #ifndef BUILD_BRIDGE
  1401. if (sendOsc)
  1402. {
  1403. if (velo > 0)
  1404. x_engine->osc_send_control_note_on(m_id, channel, note, velo);
  1405. else
  1406. x_engine->osc_send_control_note_off(m_id, channel, note);
  1407. }
  1408. #else
  1409. Q_UNUSED(sendOsc);
  1410. #endif
  1411. if (sendCallback)
  1412. x_engine->callback(velo ? CALLBACK_NOTE_ON : CALLBACK_NOTE_OFF, m_id, note, velo, 0.0);
  1413. }
  1414. /*!
  1415. * Send all midi notes off for the next audio callback.\n
  1416. * This doesn't send the actual MIDI All-Notes-Off event, but 128 note-offs instead.
  1417. */
  1418. void sendMidiAllNotesOff()
  1419. {
  1420. engineMidiLock();
  1421. postEvents.mutex.lock();
  1422. unsigned short postPad = 0;
  1423. for (unsigned short i=0; i < MAX_POST_EVENTS; i++)
  1424. {
  1425. if (postEvents.data[i].type == PluginPostEventNull)
  1426. {
  1427. postPad = i;
  1428. break;
  1429. }
  1430. }
  1431. if (postPad == MAX_POST_EVENTS - 1)
  1432. {
  1433. qWarning("post-events buffer full, making room for all notes off now");
  1434. postPad -= 128;
  1435. }
  1436. for (unsigned short i=0; i < 128; i++)
  1437. {
  1438. extMidiNotes[i].channel = m_ctrlInChannel;
  1439. extMidiNotes[i].note = i;
  1440. extMidiNotes[i].velo = 0;
  1441. postEvents.data[i + postPad].type = PluginPostEventNoteOff;
  1442. postEvents.data[i + postPad].value1 = i;
  1443. postEvents.data[i + postPad].value2 = 0;
  1444. postEvents.data[i + postPad].value3 = 0.0;
  1445. }
  1446. postEvents.mutex.unlock();
  1447. engineMidiUnlock();
  1448. }
  1449. // -------------------------------------------------------------------
  1450. // Post-poned events
  1451. /*!
  1452. * Post pone an event of type \a type.\n
  1453. * The event will be processed later, but as soon as possible.
  1454. */
  1455. void postponeEvent(const PluginPostEventType type, const int32_t value1, const int32_t value2, const double value3, const void* const cdata = nullptr)
  1456. {
  1457. postEvents.mutex.lock();
  1458. for (unsigned short i=0; i < MAX_POST_EVENTS; i++)
  1459. {
  1460. if (postEvents.data[i].type == PluginPostEventNull)
  1461. {
  1462. postEvents.data[i].type = type;
  1463. postEvents.data[i].value1 = value1;
  1464. postEvents.data[i].value2 = value2;
  1465. postEvents.data[i].value3 = value3;
  1466. postEvents.data[i].cdata = cdata;
  1467. break;
  1468. }
  1469. }
  1470. postEvents.mutex.unlock();
  1471. }
  1472. /*!
  1473. * Process all the post-poned events.
  1474. * This function will only be called from the main thread if PLUGIN_USES_SINGLE_THREAD is set.
  1475. */
  1476. void postEventsRun()
  1477. {
  1478. PluginPostEvent newPostEvents[MAX_POST_EVENTS];
  1479. // Make a safe copy of events, and clear them
  1480. postEvents.mutex.lock();
  1481. memcpy(newPostEvents, postEvents.data, sizeof(PluginPostEvent)*MAX_POST_EVENTS);
  1482. for (unsigned short i=0; i < MAX_POST_EVENTS; i++)
  1483. postEvents.data[i].type = PluginPostEventNull;
  1484. postEvents.mutex.unlock();
  1485. // Handle events now
  1486. for (uint32_t i=0; i < MAX_POST_EVENTS; i++)
  1487. {
  1488. const PluginPostEvent* const event = &newPostEvents[i];
  1489. switch (event->type)
  1490. {
  1491. case PluginPostEventNull:
  1492. break;
  1493. case PluginPostEventDebug:
  1494. x_engine->callback(CALLBACK_DEBUG, m_id, event->value1, event->value2, event->value3);
  1495. break;
  1496. case PluginPostEventParameterChange:
  1497. // Update UI
  1498. if (event->value1 >= 0)
  1499. uiParameterChange(event->value1, event->value3);
  1500. #ifndef BUILD_BRIDGE
  1501. // Update OSC control client
  1502. x_engine->osc_send_control_set_parameter_value(m_id, event->value1, event->value3);
  1503. #endif
  1504. // Update Host
  1505. x_engine->callback(CALLBACK_PARAMETER_VALUE_CHANGED, m_id, event->value1, 0, event->value3);
  1506. break;
  1507. case PluginPostEventProgramChange:
  1508. // Update UI
  1509. if (event->value1 >= 0)
  1510. uiProgramChange(event->value1);
  1511. #ifndef BUILD_BRIDGE
  1512. // Update OSC control client
  1513. x_engine->osc_send_control_set_program(m_id, event->value1);
  1514. for (uint32_t j=0; j < param.count; j++)
  1515. x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def);
  1516. #endif
  1517. // Update Host
  1518. x_engine->callback(CALLBACK_PROGRAM_CHANGED, m_id, event->value1, 0, 0.0);
  1519. break;
  1520. case PluginPostEventMidiProgramChange:
  1521. // Update UI
  1522. if (event->value1 >= 0)
  1523. uiMidiProgramChange(event->value1);
  1524. #ifndef BUILD_BRIDGE
  1525. // Update OSC control client
  1526. x_engine->osc_send_control_set_midi_program(m_id, event->value1);
  1527. for (uint32_t j=0; j < param.count; j++)
  1528. x_engine->osc_send_control_set_default_value(m_id, j, param.ranges[j].def);
  1529. #endif
  1530. // Update Host
  1531. x_engine->callback(CALLBACK_MIDI_PROGRAM_CHANGED, m_id, event->value1, 0, 0.0);
  1532. break;
  1533. case PluginPostEventNoteOn:
  1534. // Update UI
  1535. uiNoteOn(event->value1, event->value2, rint(event->value3));
  1536. #ifndef BUILD_BRIDGE
  1537. // Update OSC control client
  1538. x_engine->osc_send_control_note_on(m_id, event->value1, event->value2, rint(event->value3));
  1539. #endif
  1540. // Update Host
  1541. x_engine->callback(CALLBACK_NOTE_ON, m_id, event->value1, event->value2, event->value3);
  1542. break;
  1543. case PluginPostEventNoteOff:
  1544. // Update UI
  1545. uiNoteOff(event->value1, event->value2);
  1546. #ifndef BUILD_BRIDGE
  1547. // Update OSC control client
  1548. x_engine->osc_send_control_note_off(m_id, event->value1, event->value2);
  1549. #endif
  1550. // Update Host
  1551. x_engine->callback(CALLBACK_NOTE_OFF, m_id, event->value1, event->value2, 0.0);
  1552. break;
  1553. case PluginPostEventCustom:
  1554. // Handle custom event
  1555. postEventHandleCustom(event->value1, event->value2, event->value3, event->cdata);
  1556. break;
  1557. }
  1558. }
  1559. }
  1560. /*!
  1561. * Handle custom post event.\n
  1562. * Implementation depends on plugin type.
  1563. */
  1564. virtual void postEventHandleCustom(const int32_t value1, const int32_t value2, const double value3, const void* const cdata)
  1565. {
  1566. Q_UNUSED(value1);
  1567. Q_UNUSED(value2);
  1568. Q_UNUSED(value3);
  1569. Q_UNUSED(cdata);
  1570. }
  1571. /*!
  1572. * Tell the UI a parameter has changed.
  1573. */
  1574. virtual void uiParameterChange(const uint32_t index, const double value)
  1575. {
  1576. Q_ASSERT(index < param.count);
  1577. Q_UNUSED(index);
  1578. Q_UNUSED(value);
  1579. }
  1580. /*!
  1581. * Tell the UI the current program has changed.
  1582. */
  1583. virtual void uiProgramChange(const uint32_t index)
  1584. {
  1585. Q_ASSERT(index < prog.count);
  1586. Q_UNUSED(index);
  1587. }
  1588. /*!
  1589. * Tell the UI the current midi program has changed.
  1590. */
  1591. virtual void uiMidiProgramChange(const uint32_t index)
  1592. {
  1593. Q_ASSERT(index < midiprog.count);
  1594. Q_UNUSED(index);
  1595. }
  1596. /*!
  1597. * Tell the UI a note has been pressed.
  1598. */
  1599. virtual void uiNoteOn(const uint8_t channel, const uint8_t note, const uint8_t velo)
  1600. {
  1601. Q_ASSERT(channel < 16);
  1602. Q_ASSERT(note < 128);
  1603. Q_ASSERT(velo > 0 && velo < 128);
  1604. Q_UNUSED(channel);
  1605. Q_UNUSED(note);
  1606. Q_UNUSED(velo);
  1607. }
  1608. /*!
  1609. * Tell the UI a note has been released.
  1610. */
  1611. virtual void uiNoteOff(const uint8_t channel, const uint8_t note)
  1612. {
  1613. Q_ASSERT(channel < 16);
  1614. Q_ASSERT(note < 128);
  1615. Q_UNUSED(channel);
  1616. Q_UNUSED(note);
  1617. }
  1618. // -------------------------------------------------------------------
  1619. // Cleanup
  1620. /*!
  1621. * Clear the engine client ports of the plugin.
  1622. */
  1623. virtual void removeClientPorts()
  1624. {
  1625. qDebug("CarlaPlugin::removeClientPorts() - start");
  1626. for (uint32_t i=0; i < aIn.count; i++)
  1627. {
  1628. delete aIn.ports[i];
  1629. aIn.ports[i] = nullptr;
  1630. }
  1631. for (uint32_t i=0; i < aOut.count; i++)
  1632. {
  1633. delete aOut.ports[i];
  1634. aOut.ports[i] = nullptr;
  1635. }
  1636. if (midi.portMin)
  1637. {
  1638. delete midi.portMin;
  1639. midi.portMin = nullptr;
  1640. }
  1641. if (midi.portMout)
  1642. {
  1643. delete midi.portMout;
  1644. midi.portMout = nullptr;
  1645. }
  1646. if (param.portCin)
  1647. {
  1648. delete param.portCin;
  1649. param.portCin = nullptr;
  1650. }
  1651. if (param.portCout)
  1652. {
  1653. delete param.portCout;
  1654. param.portCout = nullptr;
  1655. }
  1656. qDebug("CarlaPlugin::removeClientPorts() - end");
  1657. }
  1658. /*!
  1659. * Initializes all RT buffers of the plugin.
  1660. */
  1661. virtual void initBuffers()
  1662. {
  1663. uint32_t i;
  1664. for (i=0; i < aIn.count; i++)
  1665. {
  1666. if (aIn.ports[i])
  1667. aIn.ports[i]->initBuffer(x_engine);
  1668. }
  1669. for (i=0; i < aOut.count; i++)
  1670. {
  1671. if (aOut.ports[i])
  1672. aOut.ports[i]->initBuffer(x_engine);
  1673. }
  1674. if (param.portCin)
  1675. param.portCin->initBuffer(x_engine);
  1676. if (param.portCout)
  1677. param.portCout->initBuffer(x_engine);
  1678. if (midi.portMin)
  1679. midi.portMin->initBuffer(x_engine);
  1680. if (midi.portMout)
  1681. midi.portMout->initBuffer(x_engine);
  1682. }
  1683. /*!
  1684. * Delete all temporary buffers of the plugin.
  1685. */
  1686. virtual void deleteBuffers()
  1687. {
  1688. qDebug("CarlaPlugin::deleteBuffers() - start");
  1689. if (aIn.count > 0)
  1690. {
  1691. delete[] aIn.ports;
  1692. delete[] aIn.rindexes;
  1693. }
  1694. if (aOut.count > 0)
  1695. {
  1696. delete[] aOut.ports;
  1697. delete[] aOut.rindexes;
  1698. }
  1699. if (param.count > 0)
  1700. {
  1701. delete[] param.data;
  1702. delete[] param.ranges;
  1703. }
  1704. aIn.count = 0;
  1705. aIn.ports = nullptr;
  1706. aIn.rindexes = nullptr;
  1707. aOut.count = 0;
  1708. aOut.ports = nullptr;
  1709. aOut.rindexes = nullptr;
  1710. param.count = 0;
  1711. param.data = nullptr;
  1712. param.ranges = nullptr;
  1713. param.portCin = nullptr;
  1714. param.portCout = nullptr;
  1715. qDebug("CarlaPlugin::deleteBuffers() - end");
  1716. }
  1717. // -------------------------------------------------------------------
  1718. // Library functions
  1719. /*!
  1720. * Open the DLL \a filename.
  1721. */
  1722. bool libOpen(const char* const filename)
  1723. {
  1724. m_lib = lib_open(filename);
  1725. return bool(m_lib);
  1726. }
  1727. /*!
  1728. * Close the DLL previously loaded in libOpen().
  1729. */
  1730. bool libClose()
  1731. {
  1732. if (m_lib)
  1733. return lib_close(m_lib);
  1734. return false;
  1735. }
  1736. /*!
  1737. * Get the symbol entry \a symbol of the currently loaded DLL.
  1738. */
  1739. void* libSymbol(const char* const symbol)
  1740. {
  1741. if (m_lib)
  1742. return lib_symbol(m_lib, symbol);
  1743. return nullptr;
  1744. }
  1745. /*!
  1746. * Get the last DLL related error.
  1747. */
  1748. const char* libError(const char* const filename)
  1749. {
  1750. return lib_error(filename);
  1751. }
  1752. // -------------------------------------------------------------------
  1753. // Locks
  1754. void engineProcessLock()
  1755. {
  1756. x_engine->processLock();
  1757. }
  1758. void engineProcessUnlock()
  1759. {
  1760. x_engine->processUnlock();
  1761. }
  1762. void engineMidiLock()
  1763. {
  1764. x_engine->midiLock();
  1765. }
  1766. void engineMidiUnlock()
  1767. {
  1768. x_engine->midiUnlock();
  1769. }
  1770. // -------------------------------------------------------------------
  1771. // Plugin initializers
  1772. struct initializer {
  1773. CarlaEngine* const engine;
  1774. const char* const filename;
  1775. const char* const name;
  1776. const char* const label;
  1777. };
  1778. static CarlaPlugin* newLADSPA(const initializer& init, const void* const extra);
  1779. static CarlaPlugin* newDSSI(const initializer& init, const void* const extra);
  1780. static CarlaPlugin* newLV2(const initializer& init);
  1781. static CarlaPlugin* newVST(const initializer& init);
  1782. static CarlaPlugin* newGIG(const initializer& init);
  1783. static CarlaPlugin* newSF2(const initializer& init);
  1784. static CarlaPlugin* newSFZ(const initializer& init);
  1785. #ifndef BUILD_BRIDGE
  1786. static CarlaPlugin* newBridge(const initializer& init, const BinaryType btype, const PluginType ptype);
  1787. #endif
  1788. // -------------------------------------------------------------------
  1789. /*!
  1790. * \class CarlaPluginScopedDisabler
  1791. *
  1792. * \brief Carla plugin scoped disabler
  1793. *
  1794. * This is a handy class that temporarily disables a plugin during a function scope.\n
  1795. * It should be used when the plugin needs reload or state change, something like this:
  1796. * \code
  1797. * {
  1798. * const CarlaPluginScopedDisabler m(plugin);
  1799. * plugin->setChunkData(data);
  1800. * }
  1801. * \endcode
  1802. */
  1803. class ScopedDisabler
  1804. {
  1805. public:
  1806. /*!
  1807. * Disable plugin \a plugin if \a disable is true.
  1808. * The plugin is re-enabled in the deconstructor of this class if \a disable is true.
  1809. *
  1810. * \param plugin The plugin to disable
  1811. * \param disable Wherever to disable the plugin or not, true by default
  1812. */
  1813. ScopedDisabler(CarlaPlugin* const plugin, const bool disable = true) :
  1814. m_plugin(plugin),
  1815. m_disable(disable)
  1816. {
  1817. if (m_disable)
  1818. {
  1819. m_plugin->engineProcessLock();
  1820. m_plugin->setEnabled(false);
  1821. m_plugin->engineProcessUnlock();
  1822. }
  1823. }
  1824. ~ScopedDisabler()
  1825. {
  1826. if (m_disable)
  1827. {
  1828. m_plugin->engineProcessLock();
  1829. m_plugin->setEnabled(true);
  1830. m_plugin->engineProcessUnlock();
  1831. }
  1832. }
  1833. private:
  1834. CarlaPlugin* const m_plugin;
  1835. const bool m_disable;
  1836. };
  1837. // -------------------------------------------------------------------
  1838. protected:
  1839. unsigned short m_id;
  1840. CarlaEngine* const x_engine;
  1841. CarlaEngineClient* x_client;
  1842. double x_dryWet, x_volume;
  1843. double x_balanceLeft, x_balanceRight;
  1844. PluginType m_type;
  1845. unsigned int m_hints;
  1846. bool m_active;
  1847. bool m_activeBefore;
  1848. bool m_enabled;
  1849. void* m_lib;
  1850. const char* m_name;
  1851. const char* m_filename;
  1852. int8_t m_ctrlInChannel;
  1853. // -------------------------------------------------------------------
  1854. // Storage Data
  1855. PluginAudioData aIn;
  1856. PluginAudioData aOut;
  1857. PluginMidiData midi;
  1858. PluginParameterData param;
  1859. PluginProgramData prog;
  1860. PluginMidiProgramData midiprog;
  1861. std::vector<CustomData> custom;
  1862. // -------------------------------------------------------------------
  1863. // Extra
  1864. #ifndef BUILD_BRIDGE
  1865. struct {
  1866. CarlaOscData data;
  1867. CarlaPluginThread* thread;
  1868. } osc;
  1869. #endif
  1870. struct {
  1871. QMutex mutex;
  1872. PluginPostEvent data[MAX_POST_EVENTS];
  1873. } postEvents;
  1874. ExternalMidiNote extMidiNotes[MAX_MIDI_EVENTS];
  1875. // -------------------------------------------------------------------
  1876. // Utilities
  1877. static double fixParameterValue(double& value, const ParameterRanges& ranges)
  1878. {
  1879. if (value < ranges.min)
  1880. value = ranges.min;
  1881. else if (value > ranges.max)
  1882. value = ranges.max;
  1883. return value;
  1884. }
  1885. static float fixParameterValue(float& value, const ParameterRanges& ranges)
  1886. {
  1887. if (value < ranges.min)
  1888. value = ranges.min;
  1889. else if (value > ranges.max)
  1890. value = ranges.max;
  1891. return value;
  1892. }
  1893. static double abs(const double& value)
  1894. {
  1895. return (value < 0.0) ? -value : value;
  1896. }
  1897. };
  1898. /**@}*/
  1899. CARLA_BACKEND_END_NAMESPACE
  1900. #endif // CARLA_PLUGIN_H