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.

120 lines
4.5KB

  1. /*
  2. * Carla Plugin Host
  3. * Copyright (C) 2011-2014 Filipe Coelho <falktx@falktx.com>
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation; either version 2 of
  8. * the License, or any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * For a full copy of the GNU General Public License see the doc/GPL.txt file.
  16. */
  17. #ifndef CARLA_ENGINE_GRAPH_HPP_INCLUDED
  18. #define CARLA_ENGINE_GRAPH_HPP_INCLUDED
  19. #include "CarlaEngine.hpp"
  20. #include "CarlaMutex.hpp"
  21. #include "CarlaPatchbayUtils.hpp"
  22. CARLA_BACKEND_START_NAMESPACE
  23. // -----------------------------------------------------------------------
  24. // Rack Graph stuff
  25. enum RackGraphGroupIds {
  26. RACK_GRAPH_GROUP_CARLA = 0,
  27. RACK_GRAPH_GROUP_AUDIO_IN = 1,
  28. RACK_GRAPH_GROUP_AUDIO_OUT = 2,
  29. RACK_GRAPH_GROUP_MIDI_IN = 3,
  30. RACK_GRAPH_GROUP_MIDI_OUT = 4,
  31. RACK_GRAPH_GROUP_MAX = 5
  32. };
  33. enum RackGraphCarlaPortIds {
  34. RACK_GRAPH_CARLA_PORT_NULL = 0,
  35. RACK_GRAPH_CARLA_PORT_AUDIO_IN1 = 1,
  36. RACK_GRAPH_CARLA_PORT_AUDIO_IN2 = 2,
  37. RACK_GRAPH_CARLA_PORT_AUDIO_OUT1 = 3,
  38. RACK_GRAPH_CARLA_PORT_AUDIO_OUT2 = 4,
  39. RACK_GRAPH_CARLA_PORT_MIDI_IN = 5,
  40. RACK_GRAPH_CARLA_PORT_MIDI_OUT = 6,
  41. RACK_GRAPH_CARLA_PORT_MAX = 7
  42. };
  43. // -----------------------------------------------------------------------
  44. // InternalGraph
  45. struct InternalGraph {
  46. virtual ~InternalGraph() noexcept {}
  47. virtual void clear() noexcept = 0;
  48. virtual void setBufferSize(const uint32_t bufferSize) = 0;
  49. virtual void setSampleRate(const double sampleRate) = 0;
  50. virtual bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept = 0;
  51. virtual bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept = 0;
  52. virtual const char* const* getConnections() const = 0;
  53. virtual bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const = 0;
  54. };
  55. // -----------------------------------------------------------------------
  56. // RackGraph
  57. struct RackGraph : InternalGraph {
  58. PatchbayConnectionList connections;
  59. struct Audio {
  60. CarlaRecursiveMutex mutex;
  61. LinkedList<uint> connectedIn1;
  62. LinkedList<uint> connectedIn2;
  63. LinkedList<uint> connectedOut1;
  64. LinkedList<uint> connectedOut2;
  65. float* inBuf[2];
  66. float* outBuf[2];
  67. } audio;
  68. struct MIDI {
  69. LinkedList<PortNameToId> ins;
  70. LinkedList<PortNameToId> outs;
  71. const char* getName(const bool isInput, const uint portId) const noexcept;
  72. uint getPortId(const bool isInput, const char portName[]) const noexcept;
  73. } midi;
  74. RackGraph(const uint32_t bufferSize) noexcept;
  75. ~RackGraph() noexcept override;
  76. void clear() noexcept override;
  77. void setBufferSize(const uint32_t bufferSize) noexcept override;
  78. void setSampleRate(const double sampleRate) noexcept override;
  79. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept override;
  80. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept override;
  81. const char* const* getConnections() const override;
  82. bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const override;
  83. };
  84. // -----------------------------------------------------------------------
  85. // PatchbayGraph
  86. struct PatchbayGraph : InternalGraph {
  87. // TODO
  88. PatchbayGraph() noexcept;
  89. ~PatchbayGraph() noexcept override;
  90. void clear() noexcept override;
  91. void setBufferSize(const uint32_t bufferSize) noexcept override;
  92. void setSampleRate(const double sampleRate) noexcept override;
  93. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept override;
  94. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept override;
  95. const char* const* getConnections() const noexcept override;
  96. bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept override;
  97. };
  98. // -----------------------------------------------------------------------
  99. CARLA_BACKEND_END_NAMESPACE
  100. #endif // CARLA_ENGINE_GRAPH_HPP_INCLUDED