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.

1059 lines
28KB

  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 "CarlaBackend.hpp"
  20. #include "CarlaString.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.
  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 param; //!< Parameter ID, midi bank or midi program.
  127. double value; //!< Parameter value, normalized to 0.0<->1.0.
  128. #ifndef CARLA_PROPER_CPP11_SUPPORT
  129. EngineControlEvent()
  130. {
  131. clear();
  132. }
  133. #endif
  134. void clear()
  135. {
  136. type = kEngineControlEventTypeNull;
  137. param = 0;
  138. value = 0.0;
  139. }
  140. };
  141. /*!
  142. * Engine MIDI event.
  143. */
  144. struct EngineMidiEvent {
  145. uint8_t port; //!< Port offset (usually 0)
  146. uint8_t data[3]; //!< MIDI data, without channel bit
  147. uint8_t size; //!< Number of bytes used
  148. #ifndef CARLA_PROPER_CPP11_SUPPORT
  149. EngineMidiEvent()
  150. {
  151. clear();
  152. }
  153. #endif
  154. void clear()
  155. {
  156. port = 0;
  157. data[0] = 0;
  158. data[1] = 0;
  159. data[2] = 0;
  160. size = 0;
  161. }
  162. };
  163. /*!
  164. * Engine event.
  165. */
  166. struct EngineEvent {
  167. EngineEventType type; //!< Event Type; either Control or MIDI
  168. uint32_t time; //!< Time offset in frames
  169. uint8_t channel; //!< Channel, used for MIDI-related events
  170. union {
  171. EngineControlEvent ctrl;
  172. EngineMidiEvent midi;
  173. };
  174. EngineEvent()
  175. {
  176. clear();
  177. }
  178. void clear()
  179. {
  180. type = kEngineEventTypeNull;
  181. time = 0;
  182. channel = 0;
  183. }
  184. };
  185. // -----------------------------------------------------------------------
  186. /*!
  187. * Engine devices
  188. */
  189. struct EngineDevices {
  190. struct Audio {
  191. uint32_t count;
  192. int32_t current;
  193. const char** names;
  194. } audio;
  195. struct Midi {
  196. uint32_t count;
  197. const char** names;
  198. bool* selected;
  199. } midi;
  200. struct Info {
  201. unsigned int* bufferSizes; // valid until 0 value reached
  202. unsigned int* sampleRates; // valid until 0 value reached
  203. } info;
  204. EngineDevices()
  205. {
  206. audio.count = 0;
  207. audio.current = -1;
  208. audio.names = nullptr;
  209. midi.count = 0;
  210. midi.names = nullptr;
  211. midi.selected = nullptr;
  212. info.bufferSizes = nullptr;
  213. info.sampleRates = nullptr;
  214. }
  215. };
  216. /*!
  217. * Engine options.
  218. */
  219. struct EngineOptions {
  220. ProcessMode processMode;
  221. bool forceStereo;
  222. bool preferPluginBridges;
  223. bool preferUiBridges;
  224. #ifdef WANT_DSSI
  225. bool useDssiVstChunks;
  226. #endif
  227. unsigned int maxParameters;
  228. unsigned int oscUiTimeout;
  229. unsigned int preferredBufferSize;
  230. unsigned int preferredSampleRate;
  231. #ifndef BUILD_BRIDGE
  232. CarlaString bridge_native;
  233. CarlaString bridge_posix32;
  234. CarlaString bridge_posix64;
  235. CarlaString bridge_win32;
  236. CarlaString bridge_win64;
  237. #endif
  238. #ifdef WANT_LV2
  239. CarlaString bridge_lv2gtk2;
  240. CarlaString bridge_lv2gtk3;
  241. CarlaString bridge_lv2qt4;
  242. CarlaString bridge_lv2qt5;
  243. CarlaString bridge_lv2cocoa;
  244. CarlaString bridge_lv2win;
  245. CarlaString bridge_lv2x11;
  246. #endif
  247. #ifdef WANT_VST
  248. CarlaString bridge_vstcocoa;
  249. CarlaString bridge_vsthwnd;
  250. CarlaString bridge_vstx11;
  251. #endif
  252. EngineOptions()
  253. : processMode(PROCESS_MODE_CONTINUOUS_RACK),
  254. forceStereo(false),
  255. preferPluginBridges(false),
  256. preferUiBridges(true),
  257. #ifdef WANT_DSSI
  258. useDssiVstChunks(false),
  259. #endif
  260. maxParameters(MAX_DEFAULT_PARAMETERS),
  261. oscUiTimeout(4000),
  262. preferredBufferSize(512),
  263. preferredSampleRate(44100) {}
  264. };
  265. /*!
  266. * Engine BBT Time information.
  267. */
  268. struct EngineTimeInfoBBT {
  269. int32_t bar; //!< current bar
  270. int32_t beat; //!< current beat-within-bar
  271. int32_t tick; //!< current tick-within-beat
  272. double barStartTick;
  273. float beatsPerBar; //!< time signature "numerator"
  274. float beatType; //!< time signature "denominator"
  275. double ticksPerBeat;
  276. double beatsPerMinute;
  277. EngineTimeInfoBBT()
  278. : bar(0),
  279. beat(0),
  280. tick(0),
  281. barStartTick(0.0),
  282. beatsPerBar(0.0f),
  283. beatType(0.0f),
  284. ticksPerBeat(0.0),
  285. beatsPerMinute(0.0) {}
  286. };
  287. /*!
  288. * Engine Time information.
  289. */
  290. struct EngineTimeInfo {
  291. static const uint32_t ValidBBT = 0x1;
  292. bool playing;
  293. uint32_t frame;
  294. uint64_t time;
  295. uint32_t valid;
  296. EngineTimeInfoBBT bbt;
  297. EngineTimeInfo()
  298. {
  299. clear();
  300. }
  301. void clear()
  302. {
  303. playing = false;
  304. frame = 0;
  305. time = 0;
  306. valid = 0x0;
  307. }
  308. };
  309. // -----------------------------------------------------------------------
  310. /*!
  311. * Carla Engine port (Abstract).\n
  312. * This is the base class for all Carla Engine ports.
  313. */
  314. class CarlaEnginePort
  315. {
  316. public:
  317. /*!
  318. * The contructor.\n
  319. * Param \a isInput defines wherever this is an input port or not (output otherwise).\n
  320. * Input/output state and process mode are constant for the lifetime of the port.
  321. */
  322. CarlaEnginePort(const bool isInput, const ProcessMode processMode);
  323. /*!
  324. * The destructor.
  325. */
  326. virtual ~CarlaEnginePort();
  327. /*!
  328. * Get the type of the port, as provided by the respective subclasses.
  329. */
  330. virtual EnginePortType type() const = 0;
  331. /*!
  332. * Initialize the port's internal buffer for \a engine.
  333. */
  334. virtual void initBuffer(CarlaEngine* const engine) = 0;
  335. protected:
  336. const bool kIsInput;
  337. const ProcessMode kProcessMode;
  338. private:
  339. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEnginePort)
  340. };
  341. // -----------------------------------------------------------------------
  342. /*!
  343. * Carla Engine Audio port.
  344. */
  345. class CarlaEngineAudioPort : public CarlaEnginePort
  346. {
  347. public:
  348. /*!
  349. * The contructor.\n
  350. * All constructor parameters are constant and will never change in the lifetime of the port.
  351. */
  352. CarlaEngineAudioPort(const bool isInput, const ProcessMode processMode);
  353. /*!
  354. * The destructor.
  355. */
  356. virtual ~CarlaEngineAudioPort();
  357. /*!
  358. * Get the type of the port, in this case CarlaEnginePortTypeAudio.
  359. */
  360. EnginePortType type() const
  361. {
  362. return kEnginePortTypeAudio;
  363. }
  364. /*!
  365. * Initialize the port's internal buffer for \a engine.
  366. */
  367. virtual void initBuffer(CarlaEngine* const engine);
  368. /*!
  369. * Direct access to the port's audio buffer.
  370. */
  371. float* getBuffer() const
  372. {
  373. return fBuffer;
  374. }
  375. protected:
  376. float* fBuffer;
  377. private:
  378. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineAudioPort)
  379. };
  380. // -----------------------------------------------------------------------
  381. /*!
  382. * Carla Engine Event port.
  383. */
  384. class CarlaEngineEventPort : public CarlaEnginePort
  385. {
  386. public:
  387. /*!
  388. * The contructor.\n
  389. * All constructor parameters are constant and will never change in the lifetime of the port.
  390. */
  391. CarlaEngineEventPort(const bool isInput, const ProcessMode processMode);
  392. /*!
  393. * The destructor.
  394. */
  395. virtual ~CarlaEngineEventPort();
  396. /*!
  397. * Get the type of the port, in this case CarlaEnginePortTypeControl.
  398. */
  399. EnginePortType type() const
  400. {
  401. return kEnginePortTypeEvent;
  402. }
  403. /*!
  404. * Initialize the port's internal buffer for \a engine.
  405. */
  406. virtual void initBuffer(CarlaEngine* const engine);
  407. /*!
  408. * Get the number of events present in the buffer.
  409. * \note You must only call this for input ports.
  410. */
  411. virtual uint32_t getEventCount();
  412. /*!
  413. * Get the event at \a index.
  414. * \note You must only call this for input ports.
  415. */
  416. virtual const EngineEvent& getEvent(const uint32_t index);
  417. /*!
  418. * Write a control event into the buffer.\n
  419. * Arguments are the same as in the EngineControlEvent struct.
  420. * \note You must only call this for output ports.
  421. */
  422. virtual void writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEventType type, const uint16_t param, const double value = 0.0);
  423. /*!
  424. * Write a control event into the buffer, overloaded call.
  425. */
  426. void writeControlEvent(const uint32_t time, const uint8_t channel, const EngineControlEvent& ctrl)
  427. {
  428. writeControlEvent(time, channel, ctrl.type, ctrl.param, ctrl.value);
  429. }
  430. /*!
  431. * Write a MIDI event into the buffer.\n
  432. * Arguments are the same as in the EngineMidiEvent struct.
  433. ** \note You must only call this for output ports.
  434. */
  435. virtual void writeMidiEvent(const uint32_t time, const uint8_t channel, const uint8_t port, const uint8_t* const data, const uint8_t size);
  436. /*!
  437. * Write a MIDI event into the buffer, overloaded call.
  438. */
  439. void writeMidiEvent(const uint32_t time, const uint8_t channel, const EngineMidiEvent& midi)
  440. {
  441. writeMidiEvent(time, channel, midi.port, midi.data, midi.size);
  442. }
  443. private:
  444. const uint32_t kMaxEventCount;
  445. EngineEvent* fBuffer;
  446. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineEventPort)
  447. };
  448. // -----------------------------------------------------------------------
  449. /*!
  450. * Carla Engine client.\n
  451. * Each plugin requires one client from the engine (created via CarlaEngine::addPort()).\n
  452. * \note This is a virtual class, each engine type provides its own funtionality.
  453. */
  454. class CarlaEngineClient
  455. {
  456. public:
  457. /*!
  458. * The constructor, protected.\n
  459. * All constructor parameters are constant and will never change in the lifetime of the client.\n
  460. * Client starts in deactivated state.
  461. */
  462. CarlaEngineClient(const CarlaBackend::EngineType engineType, const CarlaBackend::ProcessMode processMode);
  463. /*!
  464. * The destructor.
  465. */
  466. virtual ~CarlaEngineClient();
  467. /*!
  468. * Activate this client.\n
  469. * Client must be deactivated before calling this function.
  470. */
  471. virtual void activate();
  472. /*!
  473. * Deactivate this client.\n
  474. * Client must be activated before calling this function.
  475. */
  476. virtual void deactivate();
  477. /*!
  478. * Check if the client is activated.
  479. */
  480. virtual bool isActive() const;
  481. /*!
  482. * Check if the client is ok.\n
  483. * Plugins will refuse to instantiate if this returns false.
  484. * \note This is always true in rack and patchbay processing modes.
  485. */
  486. virtual bool isOk() const;
  487. /*!
  488. * Get the current latency, in samples.
  489. */
  490. virtual uint32_t getLatency() const;
  491. /*!
  492. * Change the client's latency.
  493. */
  494. virtual void setLatency(const uint32_t samples);
  495. /*!
  496. * Add a new port of type \a portType.
  497. * \note This function does nothing in rack processing mode since ports are static there (2 audio + 1 event for both input and output).
  498. */
  499. virtual const CarlaEnginePort* addPort(const EnginePortType portType, const char* const name, const bool isInput);
  500. protected:
  501. const EngineType kEngineType;
  502. const ProcessMode kProcessMode;
  503. bool fActive;
  504. uint32_t fLatency;
  505. private:
  506. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngineClient)
  507. };
  508. // -----------------------------------------------------------------------
  509. /*!
  510. * Protected data used in CarlaEngine.
  511. * Non-engine code MUST NEVER have direct access to this.
  512. */
  513. struct CarlaEngineProtectedData;
  514. /*!
  515. * Carla Engine.
  516. * \note This is a virtual class for all available engine types available in Carla.
  517. */
  518. class CarlaEngine
  519. {
  520. protected:
  521. /*!
  522. * The constructor, protected.\n
  523. * \note This only initializes engine data, it doesn't initialize the engine itself.
  524. */
  525. CarlaEngine();
  526. public:
  527. /*!
  528. * The decontructor.
  529. * The engine must have been closed before this happens.
  530. */
  531. virtual ~CarlaEngine();
  532. // -------------------------------------------------------------------
  533. // Static values and calls
  534. /*!
  535. * TODO.
  536. */
  537. static const unsigned short MAX_PEAKS = 2;
  538. /*!
  539. * Get the number of available engine drivers.
  540. */
  541. static unsigned int getDriverCount();
  542. /*!
  543. * Get the name of the engine driver at \a index.
  544. */
  545. static const char* getDriverName(unsigned int index);
  546. /*!
  547. * Create a new engine, using driver \a driverName.\n
  548. * Returned variable must be deleted when no longer needed.
  549. */
  550. static CarlaEngine* newDriverByName(const char* const driverName);
  551. // -------------------------------------------------------------------
  552. // Constant values
  553. /*!
  554. * Maximum client name size.
  555. */
  556. virtual unsigned int maxClientNameSize() const;
  557. /*!
  558. * Maximum port name size.
  559. */
  560. virtual unsigned int maxPortNameSize() const;
  561. /*!
  562. * Current number of plugins loaded.
  563. */
  564. unsigned int currentPluginCount() const;
  565. /*!
  566. * Maximum number of loadable plugins allowed.
  567. * \note This function returns 0 if engine is not started.
  568. */
  569. unsigned int maxPluginNumber() const;
  570. // -------------------------------------------------------------------
  571. // Virtual, per-engine type calls
  572. /*!
  573. * Initialize engine, using \a clientName.
  574. */
  575. virtual bool init(const char* const clientName);
  576. /*!
  577. * Close engine.
  578. */
  579. virtual bool close();
  580. /*!
  581. * Idle engine.
  582. */
  583. virtual void idle();
  584. /*!
  585. * Check if engine is running.
  586. */
  587. virtual bool isRunning() const = 0;
  588. /*!
  589. * Check if engine is running offline (aka freewheel mode).
  590. */
  591. virtual bool isOffline() const = 0;
  592. /*!
  593. * Get engine type.
  594. */
  595. virtual EngineType type() const = 0;
  596. /*!
  597. * Add new engine client.
  598. * \note This must only be called within a plugin class.
  599. */
  600. virtual CarlaEngineClient* addClient(CarlaPlugin* const plugin);
  601. // -------------------------------------------------------------------
  602. // Plugin management
  603. /*!
  604. * Add new plugin.
  605. */
  606. bool addPlugin(const BinaryType btype, const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra = nullptr);
  607. /*!
  608. * Add new plugin, using native binary type.
  609. */
  610. bool addPlugin(const PluginType ptype, const char* const filename, const char* const name, const char* const label, const void* const extra = nullptr)
  611. {
  612. return addPlugin(BINARY_NATIVE, ptype, filename, name, label, extra);
  613. }
  614. /*!
  615. * Remove plugin with id \a id.
  616. */
  617. bool removePlugin(const unsigned int id);
  618. /*!
  619. * Remove all plugins.
  620. */
  621. void removeAllPlugins();
  622. /*!
  623. * Get plugin with id \a id.
  624. */
  625. CarlaPlugin* getPlugin(const unsigned int id) const;
  626. /*!
  627. * Get plugin with id \a id, faster unchecked version.
  628. */
  629. CarlaPlugin* getPluginUnchecked(const unsigned int id) const;
  630. /*!
  631. * Get a unique plugin name within the engine.\n
  632. * Returned variable must NOT be free'd.
  633. */
  634. const char* getNewUniquePluginName(const char* const name);
  635. // -------------------------------------------------------------------
  636. // Project management
  637. /*!
  638. * Load \a filename session.
  639. * \note Already loaded plugins are not removed; call removeAllPlugins() first if needed.
  640. */
  641. bool loadProject(const char* const filename);
  642. /*!
  643. * Save current session to \a filename.
  644. */
  645. bool saveProject(const char* const filename);
  646. // -------------------------------------------------------------------
  647. // Information (base)
  648. /*!
  649. * Get current buffer size.
  650. */
  651. uint32_t getBufferSize() const
  652. {
  653. return fBufferSize;
  654. }
  655. /*!
  656. * Get current sample rate.
  657. */
  658. double getSampleRate() const
  659. {
  660. return fSampleRate;
  661. }
  662. /*!
  663. * Get engine name.
  664. */
  665. const char* getName() const
  666. {
  667. return (const char*)fName;
  668. }
  669. /*!
  670. * Get the engine options (read-only).
  671. */
  672. const EngineOptions& getOptions() const
  673. {
  674. return fOptions;
  675. }
  676. /*!
  677. * TODO.
  678. */
  679. ProcessMode getProccessMode() const
  680. {
  681. return fOptions.processMode;
  682. }
  683. /*!
  684. * Get current Time information (read-only).
  685. */
  686. const EngineTimeInfo& getTimeInfo() const
  687. {
  688. return fTimeInfo;
  689. }
  690. // -------------------------------------------------------------------
  691. // Information (peaks)
  692. /*!
  693. * TODO.
  694. * \a id must be either 1 or 2.
  695. */
  696. float getInputPeak(const unsigned int pluginId, const unsigned short id) const;
  697. /*!
  698. * TODO.
  699. * \a id must be either 1 or 2.
  700. */
  701. float getOutputPeak(const unsigned int pluginId, const unsigned short id) const;
  702. // FIXME - remove once IPC audio is implemented
  703. void setPeaks(const unsigned int pluginId, float const inPeaks[MAX_PEAKS], float const outPeaks[MAX_PEAKS]);
  704. // -------------------------------------------------------------------
  705. // Callback
  706. /*!
  707. * TODO.
  708. */
  709. void callback(const CallbackType action, const unsigned int pluginId, const int value1, const int value2, const float value3, const char* const valueStr);
  710. /*!
  711. * TODO.
  712. */
  713. void setCallback(const CallbackFunc func, void* const ptr);
  714. // -------------------------------------------------------------------
  715. // Error handling
  716. /*!
  717. * Get last error.
  718. */
  719. const char* getLastError() const;
  720. /*!
  721. * Set last error.
  722. */
  723. void setLastError(const char* const error);
  724. // -------------------------------------------------------------------
  725. // Misc
  726. /*!
  727. * Tell the engine it's about to close.\n
  728. * This is used to prevent the engine thread(s) from reactivating.
  729. */
  730. void setAboutToClose();
  731. /*!
  732. * Safely block-wait until the current proccessing callback ends.
  733. */
  734. void waitForProccessEnd();
  735. #ifndef BUILD_BRIDGE
  736. // -------------------------------------------------------------------
  737. // Options
  738. /*!
  739. * Get the engine options as process environment.
  740. */
  741. const QProcessEnvironment& getOptionsAsProcessEnvironment() const;
  742. /*!
  743. * Set the engine option \a option.
  744. */
  745. void setOption(const OptionsType option, const int value, const char* const valueStr);
  746. #endif
  747. // -------------------------------------------------------------------
  748. // OSC Stuff
  749. #ifdef BUILD_BRIDGE
  750. /*!
  751. * Check if OSC bridge is registered.
  752. */
  753. bool isOscBridgeRegistered() const;
  754. #else
  755. /*!
  756. * Check if OSC controller is registered.
  757. */
  758. bool isOscControlRegistered() const;
  759. #endif
  760. /*!
  761. * Idle OSC.
  762. */
  763. void idleOsc();
  764. /*!
  765. * Get OSC TCP server path.
  766. */
  767. const char* getOscServerPathTCP() const;
  768. /*!
  769. * Get OSC UDP server path.
  770. */
  771. const char* getOscServerPathUDP() const;
  772. #ifdef BUILD_BRIDGE
  773. /*!
  774. * Set OSC bridge data.
  775. */
  776. void setOscBridgeData(const CarlaOscData* const oscData);
  777. #endif
  778. // -------------------------------------
  779. protected:
  780. uint32_t fBufferSize;
  781. double fSampleRate;
  782. CarlaString fName;
  783. EngineOptions fOptions;
  784. EngineTimeInfo fTimeInfo;
  785. CarlaEngineProtectedData* const kData;
  786. /*!
  787. * Report to all plugins about buffer size change.
  788. */
  789. void bufferSizeChanged(const uint32_t newBufferSize);
  790. /*!
  791. * Report to all plugins about sample rate change.\n
  792. * This is not supported on all plugin types, on which case they will be re-initiated.\n
  793. * TODO: Not implemented yet.
  794. */
  795. void sampleRateChanged(const double newSampleRate);
  796. /*!
  797. * TODO.
  798. */
  799. void proccessPendingEvents();
  800. #ifndef BUILD_BRIDGE
  801. // Rack mode data
  802. EngineEvent* getRackEventBuffer(const bool isInput);
  803. /*!
  804. * Proccess audio buffer in rack mode.
  805. */
  806. void processRack(float* inBuf[2], float* outBuf[2], const uint32_t frames);
  807. /*!
  808. * Proccess audio buffer in patchbay mode.
  809. * In \a bufCount, [0]=inBufCount and [1]=outBufCount
  810. */
  811. void processPatchbay(float** inBuf, float** outBuf, const uint32_t bufCount[2], const uint32_t frames);
  812. #endif
  813. private:
  814. #ifdef WANT_JACK
  815. static CarlaEngine* newJack();
  816. #endif
  817. #ifdef WANT_RTAUDIO
  818. enum RtAudioApi {
  819. RTAUDIO_DUMMY = 0,
  820. RTAUDIO_LINUX_ALSA = 1,
  821. RTAUDIO_LINUX_PULSE = 2,
  822. RTAUDIO_LINUX_OSS = 3,
  823. RTAUDIO_UNIX_JACK = 4,
  824. RTAUDIO_MACOSX_CORE = 5,
  825. RTAUDIO_WINDOWS_ASIO = 6,
  826. RTAUDIO_WINDOWS_DS = 7
  827. };
  828. static CarlaEngine* newRtAudio(const RtAudioApi api);
  829. static size_t getRtAudioApiCount();
  830. static const char* getRtAudioApiName(const unsigned int index);
  831. #endif
  832. public:
  833. #ifdef BUILD_BRIDGE
  834. void osc_send_bridge_audio_count(const int32_t ins, const int32_t outs, const int32_t total);
  835. void osc_send_bridge_midi_count(const int32_t ins, const int32_t outs, const int32_t total);
  836. void osc_send_bridge_parameter_count(const int32_t ins, const int32_t outs, const int32_t total);
  837. void osc_send_bridge_program_count(const int32_t count);
  838. void osc_send_bridge_midi_program_count(const int32_t count);
  839. 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);
  840. void osc_send_bridge_parameter_info(const int32_t index, const char* const name, const char* const unit);
  841. 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);
  842. void osc_send_bridge_parameter_ranges(const int32_t index, const float def, const float min, const float max, const float step, const float stepSmall, const float stepLarge);
  843. void osc_send_bridge_program_info(const int32_t index, const char* const name);
  844. void osc_send_bridge_midi_program_info(const int32_t index, const int32_t bank, const int32_t program, const char* const label);
  845. void osc_send_bridge_configure(const char* const key, const char* const value);
  846. void osc_send_bridge_set_parameter_value(const int32_t index, const float value);
  847. void osc_send_bridge_set_default_value(const int32_t index, const float value);
  848. void osc_send_bridge_set_program(const int32_t index);
  849. void osc_send_bridge_set_midi_program(const int32_t index);
  850. void osc_send_bridge_set_custom_data(const char* const type, const char* const key, const char* const value);
  851. void osc_send_bridge_set_chunk_data(const char* const chunkFile);
  852. void osc_send_bridge_set_peaks();
  853. #else
  854. void osc_send_control_add_plugin_start(const int32_t pluginId, const char* const pluginName);
  855. void osc_send_control_add_plugin_end(const int32_t pluginId);
  856. void osc_send_control_remove_plugin(const int32_t pluginId);
  857. 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);
  858. 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);
  859. 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 float current);
  860. void osc_send_control_set_parameter_ranges(const int32_t pluginId, const int32_t index, const float min, const float max, const float def, const float step, const float stepSmall, const float stepLarge);
  861. void osc_send_control_set_parameter_midi_cc(const int32_t pluginId, const int32_t index, const int32_t cc);
  862. void osc_send_control_set_parameter_midi_channel(const int32_t pluginId, const int32_t index, const int32_t channel);
  863. void osc_send_control_set_parameter_value(const int32_t pluginId, const int32_t index, const float value);
  864. void osc_send_control_set_default_value(const int32_t pluginId, const int32_t index, const float value);
  865. void osc_send_control_set_program(const int32_t pluginId, const int32_t index);
  866. void osc_send_control_set_program_count(const int32_t pluginId, const int32_t count);
  867. void osc_send_control_set_program_name(const int32_t pluginId, const int32_t index, const char* const name);
  868. void osc_send_control_set_midi_program(const int32_t pluginId, const int32_t index);
  869. void osc_send_control_set_midi_program_count(const int32_t pluginId, const int32_t count);
  870. 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);
  871. void osc_send_control_note_on(const int32_t pluginId, const int32_t channel, const int32_t note, const int32_t velo);
  872. void osc_send_control_note_off(const int32_t pluginId, const int32_t channel, const int32_t note);
  873. void osc_send_control_set_peaks(const int32_t pluginId);
  874. void osc_send_control_exit();
  875. #endif
  876. private:
  877. friend class CarlaEngineEventPort;
  878. CARLA_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(CarlaEngine)
  879. };
  880. // -----------------------------------------------------------------------
  881. /**@}*/
  882. CARLA_BACKEND_END_NAMESPACE
  883. #endif // __CARLA_ENGINE_HPP__