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.

968 lines
26KB

  1. /*
  2. * Carla Engine API
  3. * Copyright (C) 2012-2013 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the GPL.txt file
  16. */
  17. #ifndef __CARLA_ENGINE_HPP__
  18. #define __CARLA_ENGINE_HPP__
  19. #include "carla_backend.hpp"
  20. #include "carla_utils.hpp"
  21. #ifdef BUILD_BRIDGE
  22. struct CarlaOscData;
  23. #else
  24. class QProcessEnvironment;
  25. #endif
  26. CARLA_BACKEND_START_NAMESPACE
  27. #if 0
  28. } // Fix editor indentation
  29. #endif
  30. // -----------------------------------------------------------------------
  31. /*!
  32. * The type of an engine.
  33. */
  34. enum EngineType {
  35. /*!
  36. * Null engine type.
  37. */
  38. kEngineTypeNull = 0,
  39. /*!
  40. * JACK engine type.\n
  41. * Provides all processing modes.
  42. */
  43. kEngineTypeJack = 1,
  44. /*!
  45. * RtAudio engine type, used to provide Native Audio and MIDI support.
  46. */
  47. kEngineTypeRtAudio = 2,
  48. /*!
  49. * Plugin engine type, used to export the engine as a plugin (DSSI, LV2 and VST) via the DISTRHO Plugin Toolkit.
  50. */
  51. kEngineTypePlugin = 3
  52. };
  53. /*!
  54. * The type of an engine port.
  55. */
  56. enum EnginePortType {
  57. /*!
  58. * Null port type.
  59. */
  60. kEnginePortTypeNull = 0,
  61. /*!
  62. * Audio port type.
  63. * \see CarlaEngineAudioPort
  64. */
  65. kEnginePortTypeAudio = 1,
  66. /*!
  67. * Event port type.
  68. ** \see CarlaEngineEventPort
  69. */
  70. kEnginePortTypeEvent = 2
  71. };
  72. /*!
  73. * The type of an engine event.
  74. */
  75. enum EngineEventType {
  76. /*!
  77. * Null port type.
  78. */
  79. kEngineEventTypeNull = 0,
  80. /*!
  81. * Control event type.
  82. * \see EngineControlEvent
  83. */
  84. kEngineEventTypeControl = 1,
  85. /*!
  86. * MIDI event type.
  87. * \see EngineMidiEvent
  88. */
  89. kEngineEventTypeMidi = 2
  90. };
  91. /*!
  92. * The type of an engine control event.
  93. */
  94. enum EngineControlEventType {
  95. /*!
  96. * Null event type.
  97. */
  98. kEngineControlEventTypeNull = 0,
  99. /*!
  100. * Parameter event type.\n
  101. * \note Value uses a range of 0.0<->1.0.
  102. */
  103. kEngineControlEventTypeParameter = 1,
  104. /*!
  105. * MIDI Bank event type.
  106. */
  107. kEngineControlEventTypeMidiBank = 2,
  108. /*!
  109. * MIDI Program change event type.
  110. */
  111. kEngineControlEventTypeMidiProgram = 3,
  112. /*!
  113. * All sound off event type.
  114. */
  115. kEngineControlEventTypeAllSoundOff = 4,
  116. /*!
  117. * All notes off event type.
  118. */
  119. kEngineControlEventTypeAllNotesOff = 5
  120. };
  121. /*!
  122. * Engine control event.
  123. */
  124. struct EngineControlEvent {
  125. EngineControlEventType type; //!< Control-Event type.
  126. uint16_t parameter; //!< Parameter ID, midi bank or midi program.
  127. double value; //!< Parameter value.
  128. EngineControlEvent()
  129. {
  130. clear();
  131. }
  132. void clear()
  133. {
  134. type = kEngineControlEventTypeNull;
  135. parameter = 0;
  136. value = 0.0;
  137. }
  138. };
  139. /*!
  140. * Engine MIDI event.
  141. */
  142. struct EngineMidiEvent {
  143. uint8_t port; //!< Port offset (usually 0)
  144. uint8_t data[3]; //!< MIDI data, without channel
  145. uint8_t size; //!< Number of bytes used
  146. EngineMidiEvent()
  147. {
  148. clear();
  149. }
  150. void clear()
  151. {
  152. port = 0;
  153. data[0] = data[1] = data[2] = 0;
  154. size = 0;
  155. }
  156. };
  157. /*!
  158. * Engine event.
  159. */
  160. struct EngineEvent {
  161. EngineEventType type; //!< Event Type; either Control or MIDI
  162. uint32_t time; //!< Time offset in frames
  163. uint8_t channel; //!< Channel, used for MIDI-related events
  164. union {
  165. EngineControlEvent ctrl;
  166. EngineMidiEvent midi;
  167. };
  168. EngineEvent()
  169. {
  170. clear();
  171. }
  172. void clear()
  173. {
  174. type = kEngineEventTypeNull;
  175. time = 0;
  176. channel = 0;
  177. }
  178. };
  179. // -----------------------------------------------------------------------
  180. /*!
  181. * Engine options.
  182. */
  183. struct EngineOptions {
  184. ProcessMode processMode;
  185. bool processHighPrecision;
  186. bool forceStereo;
  187. bool preferPluginBridges;
  188. bool preferUiBridges;
  189. #ifdef WANT_DSSI
  190. bool useDssiVstChunks;
  191. #endif
  192. uint maxParameters;
  193. uint oscUiTimeout;
  194. uint preferredBufferSize;
  195. uint preferredSampleRate;
  196. #ifndef BUILD_BRIDGE
  197. CarlaString bridge_native;
  198. CarlaString bridge_posix32;
  199. CarlaString bridge_posix64;
  200. CarlaString bridge_win32;
  201. CarlaString bridge_win64;
  202. #endif
  203. #ifdef WANT_LV2
  204. CarlaString bridge_lv2gtk2;
  205. CarlaString bridge_lv2gtk3;
  206. CarlaString bridge_lv2qt4;
  207. CarlaString bridge_lv2qt5;
  208. CarlaString bridge_lv2cocoa;
  209. CarlaString bridge_lv2win;
  210. CarlaString bridge_lv2x11;
  211. #endif
  212. #ifdef WANT_VST
  213. CarlaString bridge_vstcocoa;
  214. CarlaString bridge_vsthwnd;
  215. CarlaString bridge_vstx11;
  216. #endif
  217. EngineOptions()
  218. : processMode(PROCESS_MODE_CONTINUOUS_RACK),
  219. processHighPrecision(false),
  220. forceStereo(false),
  221. preferPluginBridges(false),
  222. preferUiBridges(true),
  223. #ifdef WANT_DSSI
  224. useDssiVstChunks(false),
  225. #endif
  226. maxParameters(MAX_DEFAULT_PARAMETERS),
  227. oscUiTimeout(4000),
  228. preferredBufferSize(512),
  229. preferredSampleRate(44100) {}
  230. };
  231. /*!
  232. * Engine BBT Time information.
  233. */
  234. struct EngineTimeInfoBBT {
  235. int32_t bar; //!< current bar
  236. int32_t beat; //!< current beat-within-bar
  237. int32_t tick; //!< current tick-within-beat
  238. double barStartTick;
  239. float beatsPerBar; //!< time signature "numerator"
  240. float beatType; //!< time signature "denominator"
  241. double ticksPerBeat;
  242. double beatsPerMinute;
  243. EngineTimeInfoBBT()
  244. : bar(0),
  245. beat(0),
  246. tick(0),
  247. barStartTick(0.0),
  248. beatsPerBar(0.0f),
  249. beatType(0.0f),
  250. ticksPerBeat(0.0),
  251. beatsPerMinute(0.0) {}
  252. };
  253. /*!
  254. * Engine Time information.
  255. */
  256. struct EngineTimeInfo {
  257. static const uint32_t ValidBBT = 0x1;
  258. bool playing;
  259. uint32_t frame;
  260. uint32_t time;
  261. uint32_t valid;
  262. EngineTimeInfoBBT bbt;
  263. EngineTimeInfo()
  264. : playing(false),
  265. frame(0),
  266. time(0),
  267. valid(0x0) {}
  268. };
  269. // -----------------------------------------------------------------------
  270. /*!
  271. * Carla Engine port (Abstract).\n
  272. * This is the base class for all Carla Engine ports.
  273. */
  274. class CarlaEnginePort
  275. {
  276. public:
  277. /*!
  278. * The contructor.\n
  279. * Param \a isInput defines wherever this is an input port or not (output otherwise).\n
  280. * Input/output state and process mode are constant for the lifetime of the port.
  281. */
  282. CarlaEnginePort(const bool isInput, const ProcessMode processMode);
  283. /*!
  284. * The decontructor.
  285. */
  286. virtual ~CarlaEnginePort();
  287. /*!
  288. * Get the type of the port, as provided by the respective subclasses.
  289. */
  290. virtual EnginePortType type() const = 0;
  291. /*!
  292. * Initialize the port's internal buffer for \a engine.
  293. */
  294. virtual void initBuffer(CarlaEngine* const engine) = 0;
  295. protected:
  296. const bool kIsInput;
  297. const ProcessMode kProcessMode;
  298. private:
  299. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort)
  300. };
  301. // -----------------------------------------------------------------------
  302. /*!
  303. * Carla Engine Audio port.
  304. */
  305. class CarlaEngineAudioPort : public CarlaEnginePort
  306. {
  307. public:
  308. /*!
  309. * The contructor.\n
  310. * All constructor parameters are constant and will never change in the lifetime of the port.
  311. */
  312. CarlaEngineAudioPort(const bool isInput, const ProcessMode processMode);
  313. /*!
  314. * The decontructor.
  315. */
  316. virtual ~CarlaEngineAudioPort();
  317. /*!
  318. * Get the type of the port, in this case CarlaEnginePortTypeAudio.
  319. */
  320. EnginePortType type() const
  321. {
  322. return kEnginePortTypeAudio;
  323. }
  324. /*!
  325. * Initialize the port's internal buffer for \a engine.
  326. */
  327. virtual void initBuffer(CarlaEngine* const engine);
  328. protected:
  329. float* fBuffer;
  330. private:
  331. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineAudioPort)
  332. };
  333. // -----------------------------------------------------------------------
  334. /*!
  335. * Carla Engine Event port.
  336. */
  337. class CarlaEngineEventPort : public CarlaEnginePort
  338. {
  339. public:
  340. /*!
  341. * The contructor.\n
  342. * All constructor parameters are constant and will never change in the lifetime of the port.
  343. */
  344. CarlaEngineEventPort(const bool isInput, const ProcessMode processMode);
  345. /*!
  346. * The decontructor.
  347. */
  348. virtual ~CarlaEngineEventPort();
  349. /*!
  350. * Get the type of the port, in this case CarlaEnginePortTypeControl.
  351. */
  352. EnginePortType type() const
  353. {
  354. return kEnginePortTypeEvent;
  355. }
  356. /*!
  357. * Initialize the port's internal buffer for \a engine.
  358. */
  359. virtual void initBuffer(CarlaEngine* const engine);
  360. /*!
  361. * Get the number of events present in the buffer.
  362. * \note You must only call this for input ports.
  363. */
  364. virtual uint32_t getEventCount();
  365. /*!
  366. * Get the event at \a index.
  367. ** \note You must only call this for input ports.
  368. */
  369. virtual const EngineEvent* getEvent(const uint32_t index);
  370. /*!
  371. * Write a control event into the buffer.\n
  372. * Arguments are the same as in the EngineControlEvent struct.
  373. ** \note You must only call this for output ports.
  374. */
  375. virtual void writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t parameter, const double value = 0.0);
  376. /*!
  377. * Write a MIDI event into the buffer.\n
  378. * Arguments are the same as in the EngineMidiEvent struct.
  379. ** \note You must only call this for output ports.
  380. */
  381. virtual void writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t* const data, const uint8_t size);
  382. private:
  383. const uint32_t kMaxEventCount;
  384. EngineEvent* fBuffer;
  385. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineEventPort)
  386. };
  387. // -----------------------------------------------------------------------
  388. /*!
  389. * Carla Engine client (Abstract).\n
  390. * Each plugin requires one client from the engine (created via CarlaEngine::addPort()).\n
  391. * \note This is a virtual class, each engine type provides its own funtionality.
  392. */
  393. class CarlaEngineClient
  394. {
  395. protected:
  396. /*!
  397. * The constructor, protected.\n
  398. * All constructor parameters are constant and will never change in the lifetime of the client.\n
  399. * Client starts in deactivated state.
  400. */
  401. CarlaEngineClient(const CarlaBackend::EngineType engineType, const CarlaBackend::ProcessMode processMode);
  402. public:
  403. /*!
  404. * The destructor.
  405. */
  406. virtual ~CarlaEngineClient();
  407. /*!
  408. * Activate this client.\n
  409. * Client must be deactivated before calling this function.
  410. */
  411. virtual void activate();
  412. /*!
  413. * Deactivate this client.\n
  414. * Client must be activated before calling this function.
  415. */
  416. virtual void deactivate();
  417. /*!
  418. * Check if the client is activated.
  419. */
  420. virtual bool isActive() const;
  421. /*!
  422. * Check if the client is ok.\n
  423. * Plugins will refuse to instantiate if this returns false.
  424. * \note This is always true in rack and patchbay processing modes.
  425. */
  426. virtual bool isOk() const;
  427. /*!
  428. * Get the current latency, in samples.
  429. */
  430. virtual uint32_t getLatency() const;
  431. /*!
  432. * Change the client's latency.
  433. */
  434. virtual void setLatency(const uint32_t samples);
  435. /*!
  436. * Add a new port of type \a portType.
  437. * \note This function does nothing in rack processing mode since ports are static there (2 audio + 1 event for both input and output).
  438. */
  439. virtual const CarlaEnginePort* addPort(const EnginePortType portType, const char* const name, const bool isInput) = 0;
  440. protected:
  441. const EngineType kEngineType;
  442. const ProcessMode kProcessMode;
  443. private:
  444. bool fActive;
  445. uint32_t fLatency;
  446. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineClient)
  447. };
  448. // -----------------------------------------------------------------------
  449. /*!
  450. * Private data used in CarlaEngine.
  451. * No other than CarlaEngine must have direct access to this.
  452. */
  453. struct CarlaEngineProtectedData;
  454. /*!
  455. * Carla Engine.
  456. * \note This is a virtual class for all available engine types available in Carla.
  457. */
  458. class CarlaEngine
  459. {
  460. protected:
  461. /*!
  462. * The constructor, protected.\n
  463. * \note This only initializes engine data, it doesn't initialize the engine itself.
  464. */
  465. CarlaEngine();
  466. public:
  467. /*!
  468. * The decontructor.
  469. * The engine must have been closed before this happens.
  470. */
  471. virtual ~CarlaEngine();
  472. // -------------------------------------------------------------------
  473. // Static values and calls
  474. /*!
  475. * Get the number of available engine drivers.
  476. */
  477. static unsigned int getDriverCount();
  478. /*!
  479. * Get the name of the engine driver at \a index.
  480. */
  481. static const char* getDriverName(unsigned int index);
  482. /*!
  483. * Create a new engine, using driver \a driverName.\n
  484. * Returned variable must be deleted when no longer needed.
  485. */
  486. static CarlaEngine* newDriverByName(const char* const driverName);
  487. // -------------------------------------------------------------------
  488. // Maximum values
  489. /*!
  490. * Maximum client name size.
  491. */
  492. virtual unsigned int maxClientNameSize() const;
  493. /*!
  494. * Maximum port name size.
  495. */
  496. virtual unsigned int maxPortNameSize() const;
  497. /*!
  498. * Current number of plugins loaded.
  499. */
  500. unsigned int currentPluginCount() const;
  501. /*!
  502. * Maximum number of loadable plugins allowed.
  503. * \note This function returns 0 if engine is not started.
  504. */
  505. unsigned int maxPluginNumber() const;
  506. // -------------------------------------------------------------------
  507. // Virtual, per-engine type calls
  508. /*!
  509. * Initialize engine, using \a clientName.
  510. */
  511. virtual bool init(const char* const clientName);
  512. /*!
  513. * Close engine.
  514. */
  515. virtual bool close();
  516. /*!
  517. * Check if engine is running.
  518. */
  519. virtual bool isRunning() const = 0;
  520. /*!
  521. * Check if engine is running offline (aka freewheel mode).
  522. */
  523. virtual bool isOffline() const = 0;
  524. /*!
  525. * Get engine type.
  526. */
  527. virtual EngineType type() const = 0;
  528. /*!
  529. * Add new engine client.
  530. * \note This must only be called within a plugin class.
  531. */
  532. virtual CarlaEngineClient* addClient(CarlaPlugin* const plugin) = 0;
  533. // -------------------------------------------------------------------
  534. // Plugin management
  535. #if 0
  536. /*!
  537. * Get next available plugin id.\n
  538. * Returns -1 if no more plugins can be loaded.
  539. */
  540. int getNewPluginId() const;
  541. #endif
  542. /*!
  543. * Get plugin with id \a id.
  544. */
  545. CarlaPlugin* getPlugin(const int id) const;
  546. /*!
  547. * Get plugin with id \a id, faster unchecked version.
  548. */
  549. CarlaPlugin* getPluginUnchecked(const int id) const;
  550. /*!
  551. * Get a unique plugin name within the engine.\n
  552. * Returned variable must be free'd when no longer needed.
  553. */
  554. const char* getNewUniquePluginName(const char* const name);
  555. /*!
  556. * Add new plugin.\n
  557. * Returns the id of the plugin, or -1 if the operation failed.
  558. */
  559. int addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr);
  560. /*!
  561. * Add new plugin, using native binary type.\n
  562. * Returns the id of the plugin, or -1 if the operation failed.
  563. */
  564. int addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, void* const extra = nullptr)
  565. {
  566. return addPlugin(BINARY_NATIVE, ptype, filename, name, label, extra);
  567. }
  568. /*!
  569. * Remove plugin with id \a id.
  570. */
  571. bool removePlugin(const unsigned int id);
  572. /*!
  573. * Remove all plugins.
  574. */
  575. void removeAllPlugins();
  576. /*!
  577. * Idle all plugins GUIs.
  578. */
  579. void idlePluginGuis();
  580. // bridge, internal use only
  581. // TODO - find a better way for this
  582. //void __bridgePluginRegister(const unsigned short id, CarlaPlugin* const plugin);
  583. //{
  584. // m_carlaPlugins[id] = plugin;
  585. //}
  586. // -------------------------------------------------------------------
  587. // Information (base)
  588. /*!
  589. * Get engine name.
  590. */
  591. const char* getName() const
  592. {
  593. return (const char*)fName;
  594. }
  595. /*!
  596. * Get current buffer size.
  597. */
  598. uint32_t getBufferSize() const
  599. {
  600. return fBufferSize;
  601. }
  602. /*!
  603. * Get current sample rate.
  604. */
  605. double getSampleRate() const
  606. {
  607. return fSampleRate;
  608. }
  609. /*!
  610. * Get the engine options (read-only).
  611. */
  612. const EngineOptions& getOptions() const
  613. {
  614. return fOptions;
  615. }
  616. /*!
  617. * Get current Time information (read-only).
  618. */
  619. const EngineTimeInfo& getTimeInfo() const
  620. {
  621. return fTimeInfo;
  622. }
  623. /*!
  624. * Tell the engine it's about to close.\n
  625. * This is used to prevent the engine thread(s) from reactivating.
  626. */
  627. void setAboutToClose();
  628. #if 0
  629. // -------------------------------------------------------------------
  630. // Information (audio peaks)
  631. double getInputPeak(const unsigned short pluginId, const unsigned short id) const;
  632. double getOutputPeak(const unsigned short pluginId, const unsigned short id) const;
  633. void setInputPeak(const unsigned short pluginId, const unsigned short id, double value);
  634. void setOutputPeak(const unsigned short pluginId, const unsigned short id, double value);
  635. #endif
  636. // -------------------------------------------------------------------
  637. // Callback
  638. /*!
  639. * TODO.
  640. */
  641. void callback(const CallbackType action, const unsigned short pluginId, const int value1, const int value2, const double value3, const char* const valueStr);
  642. /*!
  643. * TODO.
  644. */
  645. void setCallback(const CallbackFunc func, void* const ptr);
  646. // -------------------------------------------------------------------
  647. // Error handling
  648. /*!
  649. * Get last error.
  650. */
  651. const char* getLastError() const;
  652. /*!
  653. * Set last error.
  654. */
  655. void setLastError(const char* const error);
  656. // -------------------------------------------------------------------
  657. // Options
  658. #ifndef BUILD_BRIDGE
  659. /*!
  660. * Get the engine options as process environment.
  661. */
  662. const QProcessEnvironment& getOptionsAsProcessEnvironment() const;
  663. /*!
  664. * Set the engine option \a option.
  665. */
  666. void setOption(const OptionsType option, const int value, const char* const valueStr);
  667. #endif
  668. // -------------------------------------------------------------------
  669. // OSC Stuff
  670. #ifdef BUILD_BRIDGE
  671. /*!
  672. * Check if OSC bridge is registered.
  673. */
  674. bool isOscBridgeRegistered() const;
  675. #else
  676. /*!
  677. * Check if OSC controller is registered.
  678. */
  679. bool isOscControlRegistered() const;
  680. #endif
  681. /*!
  682. * Idle OSC.
  683. */
  684. void idleOsc();
  685. /*!
  686. * Get OSC TCP server path.
  687. */
  688. const char* getOscServerPathTCP() const;
  689. /*!
  690. * Get OSC UDP server path.
  691. */
  692. const char* getOscServerPathUDP() const;
  693. #ifdef BUILD_BRIDGE
  694. /*!
  695. * Set OSC bridge data.
  696. */
  697. void setOscBridgeData(const CarlaOscData* const oscData);
  698. #endif
  699. // -------------------------------------
  700. protected:
  701. CarlaString fName;
  702. uint32_t fBufferSize;
  703. double fSampleRate;
  704. EngineOptions fOptions;
  705. EngineTimeInfo fTimeInfo;
  706. ScopedPointer<CarlaEngineProtectedData> const fData;
  707. #ifndef BUILD_BRIDGE
  708. // Rack mode data
  709. EngineEvent* getRackEventBuffer(const bool isInput);
  710. //static const unsigned short MAX_EVENTS = 1024;
  711. //EngineEvent fRackEventsIn[MAX_EVENTS];
  712. //EngineEvent fRackEventsOut[MAX_EVENTS];
  713. /*!
  714. * Proccess audio buffer in rack mode.
  715. */
  716. void processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames);
  717. /*!
  718. * Proccess audio buffer in patchbay mode.
  719. * In \a bufCount, [0]=inBufCount and [1]=outBufCount
  720. */
  721. void processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames);
  722. #endif
  723. /*!
  724. * Report to all plugins about buffer size change.
  725. */
  726. void bufferSizeChanged(const uint32_t newBufferSize);
  727. /*!
  728. * Report to all plugins about sample rate change.\n
  729. * This is not supported on all plugin types, on which case they will be re-initiated.\n
  730. * TODO: Not implemented yet.
  731. */
  732. void sampleRateChanged(const double newSampleRate);
  733. private:
  734. #ifdef WANT_JACK
  735. static CarlaEngine* newJack();
  736. #endif
  737. #ifdef WANT_RTAUDIO
  738. enum RtAudioApi {
  739. RTAUDIO_DUMMY = 0,
  740. RTAUDIO_LINUX_ALSA = 1,
  741. RTAUDIO_LINUX_PULSE = 2,
  742. RTAUDIO_LINUX_OSS = 3,
  743. RTAUDIO_UNIX_JACK = 4,
  744. RTAUDIO_MACOSX_CORE = 5,
  745. RTAUDIO_WINDOWS_ASIO = 6,
  746. RTAUDIO_WINDOWS_DS = 7
  747. };
  748. static CarlaEngine* newRtAudio(const RtAudioApi api);
  749. static unsigned int getRtAudioApiCount();
  750. static const char* getRtAudioApiName(unsigned int index);
  751. #endif
  752. public:
  753. #ifdef BUILD_BRIDGE
  754. void osc_send_peaks(CarlaPlugin* const plugin);
  755. #else
  756. void osc_send_peaks(CarlaPlugin* const plugin, const unsigned short& id);
  757. #endif
  758. #ifdef BUILD_BRIDGE
  759. void osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);
  760. void osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total);
  761. void osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total);
  762. void osc_send_bridge_program_count(const int32_t count);
  763. void osc_send_bridge_midi_program_count(const int32_t count);
  764. void osc_send_bridge_plugin_info(const int32_t category, const int32_t hints, const char* const name, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
  765. void osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit);
  766. void osc_send_bridge_parameter_data(const int32_t index, const int32_t type, const int32_t rindex, const int32_t hints, const int32_t midiChannel, const int32_t midiCC);
  767. void osc_send_bridge_parameter_ranges(const int32_t index, const double def, const double min, const double max, const double step, const double stepSmall, const double stepLarge);
  768. void osc_send_bridge_program_info(const int32_t index, const char* const name);
  769. void osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label);
  770. void osc_send_bridge_configure(const char* const key, const char* const value);
  771. void osc_send_bridge_set_parameter_value(const int32_t index, const double value);
  772. void osc_send_bridge_set_default_value(const int32_t index, const double value);
  773. void osc_send_bridge_set_program(const int32_t index);
  774. void osc_send_bridge_set_midi_program(const int32_t index);
  775. void osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value);
  776. void osc_send_bridge_set_chunk_data(const char* const chunkFile);
  777. void osc_send_bridge_set_inpeak(const int32_t portId);
  778. void osc_send_bridge_set_outpeak(const int32_t portId);
  779. #else
  780. void osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName);
  781. void osc_send_control_add_plugin_end(const int32_t pluginId);
  782. void osc_send_control_remove_plugin(const int32_t pluginId);
  783. void osc_send_control_set_plugin_data(const int32_t pluginId, const int32_t type, const int32_t category, const int32_t hints, const char* const realName, const char* const label, const char* const maker, const char* const copyright, const int64_t uniqueId);
  784. void osc_send_control_set_plugin_ports(const int32_t pluginId, const int32_t audioIns, const int32_t audioOuts, const int32_t midiIns, const int32_t midiOuts, const int32_t cIns, const int32_t cOuts, const int32_t cTotals);
  785. void osc_send_control_set_parameter_data(const int32_t pluginId, const int32_t index, const int32_t type, const int32_t hints, const char* const name, const char* const label, const double current);
  786. void osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const double min, const double max, const double def, const double step, const double stepSmall, const double stepLarge);
  787. void osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
  788. void osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
  789. void osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const double value);
  790. void osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const double value);
  791. void osc_send_control_set_program(const int32_t pluginId, const int32_t index);
  792. void osc_send_control_set_program_count(const int32_t pluginId, const int32_t count);
  793. void osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
  794. void osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index);
  795. void osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count);
  796. void osc_send_control_set_midi_program_data(const int32_t pluginId, const int32_t index, const int32_t bank, const int32_t program, const char* const name);
  797. void osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
  798. void osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
  799. void osc_send_control_set_input_peak_value(const int32_t pluginId, const int32_t portId);
  800. void osc_send_control_set_output_peak_value(const int32_t pluginId, const int32_t portId);
  801. void osc_send_control_exit();
  802. #endif
  803. friend class CarlaEngineEventPort;
  804. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngine)
  805. };
  806. // -----------------------------------------------------------------------
  807. /**@}*/
  808. CARLA_BACKEND_END_NAMESPACE
  809. #endif // __CARLA_ENGINE_HPP__