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.

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