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.

115 lines
4.2KB

  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 bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept = 0;
  49. virtual bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept = 0;
  50. virtual const char* const* getConnections() const = 0;
  51. virtual bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const = 0;
  52. };
  53. // -----------------------------------------------------------------------
  54. // RackGraph
  55. struct RackGraph : InternalGraph {
  56. PatchbayConnectionList connections;
  57. struct Audio {
  58. CarlaRecursiveMutex mutex;
  59. LinkedList<uint> connectedIn1;
  60. LinkedList<uint> connectedIn2;
  61. LinkedList<uint> connectedOut1;
  62. LinkedList<uint> connectedOut2;
  63. float* inBuf[2];
  64. float* outBuf[2];
  65. } audio;
  66. struct MIDI {
  67. LinkedList<PortNameToId> ins;
  68. LinkedList<PortNameToId> outs;
  69. const char* getName(const bool isInput, const uint portId) const noexcept;
  70. uint getPortId(const bool isInput, const char portName[]) const noexcept;
  71. } midi;
  72. RackGraph(const uint32_t bufferSize) noexcept;
  73. ~RackGraph() noexcept override;
  74. void clear() noexcept override;
  75. void resize(const uint32_t bufferSize) noexcept;
  76. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept override;
  77. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept override;
  78. const char* const* getConnections() const override;
  79. bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const override;
  80. };
  81. // -----------------------------------------------------------------------
  82. // PatchbayGraph
  83. struct PatchbayGraph : InternalGraph {
  84. // TODO
  85. PatchbayGraph() noexcept;
  86. ~PatchbayGraph() noexcept override;
  87. void clear() noexcept override;
  88. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept override;
  89. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept override;
  90. const char* const* getConnections() const override;
  91. bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const override;
  92. };
  93. // -----------------------------------------------------------------------
  94. CARLA_BACKEND_END_NAMESPACE
  95. #endif // CARLA_ENGINE_GRAPH_HPP_INCLUDED