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.

147 lines
5.0KB

  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. } audio;
  70. struct MIDI {
  71. LinkedList<PortNameToId> ins;
  72. LinkedList<PortNameToId> outs;
  73. const char* getName(const bool isInput, const uint portId) const noexcept;
  74. uint getPortId(const bool isInput, const char portName[], bool* const ok = nullptr) const noexcept;
  75. } midi;
  76. RackGraph(const uint32_t bufferSize, const uint32_t inputs, const uint32_t outputs) noexcept;
  77. ~RackGraph() noexcept;
  78. void setBufferSize(const uint32_t bufferSize) noexcept;
  79. void setOffline(const bool offline) noexcept;
  80. bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
  81. bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept;
  82. void clearConnections() noexcept;
  83. const char* const* getConnections() const noexcept;
  84. bool getGroupAndPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
  85. // the base, where plugins run
  86. void process(CarlaEngine::ProtectedData* const data, const float* inBufReal[2], float* outBuf[2], const uint32_t frames);
  87. // extended, will call process() in the middle
  88. void processHelper(CarlaEngine::ProtectedData* const data, const float* const* const inBuf, float* const* const outBuf, const uint32_t frames);
  89. };
  90. #if 0
  91. // -----------------------------------------------------------------------
  92. // PatchbayGraph
  93. struct PatchbayGraph {
  94. AudioProcessorGraph graph;
  95. AudioSampleBuffer audioBuffer;
  96. MidiBuffer midiBuffer;
  97. const int inputs;
  98. const int outputs;
  99. //CharStringListPtr retCon;
  100. PatchbayGraph(const int bufferSize, const double sampleRate, const uint32_t inputs, const uint32_t outputs);
  101. ~PatchbayGraph();
  102. void setBufferSize(const int bufferSize);
  103. void setSampleRate(const double sampleRate);
  104. void setOffline(const bool offline);
  105. void addPlugin(CarlaPlugin* const plugin);
  106. void replacePlugin(CarlaPlugin* const oldPlugin, CarlaPlugin* const newPlugin);
  107. void removePlugin(CarlaPlugin* const plugin);
  108. void removeAllPlugins();
  109. //bool connect(CarlaEngine* const engine, const uint groupA, const uint portA, const uint groupB, const uint portB) noexcept;
  110. //bool disconnect(CarlaEngine* const engine, const uint connectionId) noexcept;
  111. //const char* const* getConnections() const noexcept;
  112. //bool getPortIdFromFullName(const char* const fullPortName, uint& groupId, uint& portId) const noexcept;
  113. void process(CarlaEngine::ProtectedData* const data, const float* const* const inBuf, float* const* const outBuf, const int frames);
  114. };
  115. #endif
  116. // -----------------------------------------------------------------------
  117. CARLA_BACKEND_END_NAMESPACE
  118. #endif // CARLA_ENGINE_GRAPH_HPP_INCLUDED