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.

CarlaEngineGraph.hpp 5.3KB

10 years ago
10 years ago
10 years ago
10 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. #include "CarlaStringList.hpp"
  23. #if 0
  24. # include "juce_audio_processors.h"
  25. using juce::AudioProcessorGraph;
  26. using juce::AudioSampleBuffer;
  27. using juce::MidiBuffer;
  28. #else
  29. # include "juce_audio_basics.h"
  30. #endif
  31. CARLA_BACKEND_START_NAMESPACE
  32. // -----------------------------------------------------------------------
  33. // Rack Graph stuff
  34. enum RackGraphGroupIds {
  35. RACK_GRAPH_GROUP_CARLA = 0,
  36. RACK_GRAPH_GROUP_AUDIO_IN = 1,
  37. RACK_GRAPH_GROUP_AUDIO_OUT = 2,
  38. RACK_GRAPH_GROUP_MIDI_IN = 3,
  39. RACK_GRAPH_GROUP_MIDI_OUT = 4,
  40. RACK_GRAPH_GROUP_MAX = 5
  41. };
  42. enum RackGraphCarlaPortIds {
  43. RACK_GRAPH_CARLA_PORT_NULL = 0,
  44. RACK_GRAPH_CARLA_PORT_AUDIO_IN1 = 1,
  45. RACK_GRAPH_CARLA_PORT_AUDIO_IN2 = 2,
  46. RACK_GRAPH_CARLA_PORT_AUDIO_OUT1 = 3,
  47. RACK_GRAPH_CARLA_PORT_AUDIO_OUT2 = 4,
  48. RACK_GRAPH_CARLA_PORT_MIDI_IN = 5,
  49. RACK_GRAPH_CARLA_PORT_MIDI_OUT = 6,
  50. RACK_GRAPH_CARLA_PORT_MAX = 7
  51. };
  52. // -----------------------------------------------------------------------
  53. // RackGraph
  54. struct RackGraph {
  55. PatchbayConnectionList connections;
  56. const uint32_t inputs;
  57. const uint32_t outputs;
  58. bool isOffline;
  59. mutable CharStringListPtr retCon;
  60. struct Audio {
  61. CarlaRecursiveMutex mutex;
  62. LinkedList<uint> connectedIn1;
  63. LinkedList<uint> connectedIn2;
  64. LinkedList<uint> connectedOut1;
  65. LinkedList<uint> connectedOut2;
  66. float* inBuf[2];
  67. float* inBufTmp[2];
  68. float* outBuf[2];
  69. // c++ compat stuff
  70. Audio() noexcept;
  71. CARLA_PREVENT_HEAP_ALLOCATION
  72. CARLA_DECLARE_NON_COPY_CLASS(Audio)
  73. } audio;
  74. struct MIDI {
  75. LinkedList<PortNameToId> ins;
  76. LinkedList<PortNameToId> outs;
  77. const char* getName(const bool isInput, const uint portId) const noexcept;
  78. uint getPortId(const bool isInput, const char portName[], bool* const ok = nullptr) const noexcept;
  79. // c++ compat stuff
  80. MIDI() noexcept;
  81. CARLA_PREVENT_HEAP_ALLOCATION
  82. CARLA_DECLARE_NON_COPY_CLASS(MIDI)
  83. } midi;
  84. RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept;
  85. ~RackGraph() noexcept;
  86. void setBufferSize(const uint32_t bufferSize) noexcept;
  87. void setOffline(const bool offline) noexcept;
  88. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
  89. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept;
  90. void clearConnections() noexcept;
  91. const char* const* getConnections() const noexcept;
  92. bool getGroupAndPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
  93. // the base, where plugins run
  94. void process(CarlaEngine::ProtectedData* const data, const float* inBufReal[2], float* outBuf[2], const uint32_t frames);
  95. // extended, will call process() in the middle
  96. void processHelper(CarlaEngine::ProtectedData* const data, const float* const* const inBuf, float* const* const outBuf, const uint32_t frames);
  97. };
  98. #if 0
  99. // -----------------------------------------------------------------------
  100. // PatchbayGraph
  101. struct PatchbayGraph {
  102. AudioProcessorGraph graph;
  103. AudioSampleBuffer audioBuffer;
  104. MidiBuffer midiBuffer;
  105. const int inputs;
  106. const int outputs;
  107. //CharStringListPtr retCon;
  108. PatchbayGraph(const int bufferSize, const double sampleRate, const uint32_t inputs, const uint32_t outputs);
  109. ~PatchbayGraph();
  110. void setBufferSize(const int bufferSize);
  111. void setSampleRate(const double sampleRate);
  112. void setOffline(const bool offline);
  113. void addPlugin(CarlaPlugin* const plugin);
  114. void replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin);
  115. void removePlugin(CarlaPlugin* const plugin);
  116. void removeAllPlugins();
  117. //bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
  118. //bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept;
  119. //const char* const* getConnections() const noexcept;
  120. //bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
  121. void process(CarlaEngine::ProtectedData* const data, const float* const* const inBuf, float* const* const outBuf, const int frames);
  122. };
  123. #endif
  124. // -----------------------------------------------------------------------
  125. CARLA_BACKEND_END_NAMESPACE
  126. #endif // CARLA_ENGINE_GRAPH_HPP_INCLUDED