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.

178 lines
7.8KB

  1. /*
  2. * Carla Bridge definitions
  3. * Copyright (C) 2013-2019 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_BRIDGE_DEFINES_HPP_INCLUDED
  18. #define CARLA_BRIDGE_DEFINES_HPP_INCLUDED
  19. #include "CarlaRingBuffer.hpp"
  20. #define CARLA_PLUGIN_BRIDGE_API_VERSION 6
  21. // -------------------------------------------------------------------------------------------------------------------
  22. // Server sends these to client during RT
  23. enum PluginBridgeRtClientOpcode {
  24. kPluginBridgeRtClientNull = 0,
  25. kPluginBridgeRtClientSetAudioPool, // ulong/ptr
  26. kPluginBridgeRtClientSetBufferSize, // uint
  27. kPluginBridgeRtClientSetSampleRate, // double
  28. kPluginBridgeRtClientSetOnline, // bool
  29. kPluginBridgeRtClientControlEventParameter, // uint/frame, byte/chan, ushort, float
  30. kPluginBridgeRtClientControlEventMidiBank, // uint/frame, byte/chan, ushort
  31. kPluginBridgeRtClientControlEventMidiProgram, // uint/frame, byte/chan, ushort
  32. kPluginBridgeRtClientControlEventAllSoundOff, // uint/frame, byte/chan
  33. kPluginBridgeRtClientControlEventAllNotesOff, // uint/frame, byte/chan
  34. kPluginBridgeRtClientMidiEvent, // uint/frame, byte/port, byte/size, byte[]/data
  35. kPluginBridgeRtClientProcess, // uint/frames
  36. kPluginBridgeRtClientQuit
  37. };
  38. // Server sends these to client during non-RT
  39. enum PluginBridgeNonRtClientOpcode {
  40. kPluginBridgeNonRtClientNull = 0,
  41. kPluginBridgeNonRtClientVersion, // uint
  42. kPluginBridgeNonRtClientPing,
  43. kPluginBridgeNonRtClientPingOnOff, // bool
  44. kPluginBridgeNonRtClientActivate,
  45. kPluginBridgeNonRtClientDeactivate,
  46. kPluginBridgeNonRtClientInitialSetup, // uint, double
  47. kPluginBridgeNonRtClientSetParameterValue, // uint, float
  48. kPluginBridgeNonRtClientSetParameterMidiChannel, // uint, byte
  49. kPluginBridgeNonRtClientSetParameterMidiCC, // uint, short
  50. kPluginBridgeNonRtClientSetProgram, // int
  51. kPluginBridgeNonRtClientSetMidiProgram, // int
  52. kPluginBridgeNonRtClientSetCustomData, // uint/size, str[], uint/size, str[], uint/size, str[]
  53. kPluginBridgeNonRtClientSetChunkDataFile, // uint/size, str[] (filename, base64 content)
  54. kPluginBridgeNonRtClientSetCtrlChannel, // short
  55. kPluginBridgeNonRtClientSetOption, // uint/option, bool
  56. kPluginBridgeNonRtClientGetParameterText, // uint
  57. kPluginBridgeNonRtClientPrepareForSave,
  58. kPluginBridgeNonRtClientRestoreLV2State,
  59. kPluginBridgeNonRtClientShowUI,
  60. kPluginBridgeNonRtClientHideUI,
  61. kPluginBridgeNonRtClientUiParameterChange, // uint, float
  62. kPluginBridgeNonRtClientUiProgramChange, // uint
  63. kPluginBridgeNonRtClientUiMidiProgramChange, // uint
  64. kPluginBridgeNonRtClientUiNoteOn, // byte, byte, byte
  65. kPluginBridgeNonRtClientUiNoteOff, // byte, byte
  66. kPluginBridgeNonRtClientQuit
  67. };
  68. // Client sends these to server during non-RT
  69. enum PluginBridgeNonRtServerOpcode {
  70. kPluginBridgeNonRtServerNull = 0,
  71. kPluginBridgeNonRtServerPong,
  72. kPluginBridgeNonRtServerPluginInfo1, // uint/category, uint/hints, uint/optionsAvailable, uint/optionsEnabled, long/uniqueId
  73. kPluginBridgeNonRtServerPluginInfo2, // uint/size, str[] (realName), uint/size, str[] (label), uint/size, str[] (maker), uint/size, str[] (copyright)
  74. kPluginBridgeNonRtServerAudioCount, // uint/ins, uint/outs
  75. kPluginBridgeNonRtServerMidiCount, // uint/ins, uint/outs
  76. kPluginBridgeNonRtServerCvCount, // uint/ins, uint/outs
  77. kPluginBridgeNonRtServerParameterCount, // uint/count
  78. kPluginBridgeNonRtServerProgramCount, // uint/count
  79. kPluginBridgeNonRtServerMidiProgramCount, // uint/count
  80. kPluginBridgeNonRtServerPortName, // byte/type, uint/index, uint/size, str[] (name)
  81. kPluginBridgeNonRtServerParameterData1, // uint/index, int/rindex, uint/type, uint/hints, short/cc
  82. kPluginBridgeNonRtServerParameterData2, // uint/index, uint/size, str[] (name), uint/size, str[] (symbol), uint/size, str[] (unit)
  83. kPluginBridgeNonRtServerParameterRanges, // uint/index, float/def, float/min, float/max, float/step, float/stepSmall, float/stepLarge
  84. kPluginBridgeNonRtServerParameterValue, // uint/index, float/value
  85. kPluginBridgeNonRtServerParameterValue2, // uint/index, float/value (used for init/output parameters only, don't resend values)
  86. kPluginBridgeNonRtServerParameterTouch, // uint/index, bool/touch
  87. kPluginBridgeNonRtServerDefaultValue, // uint/index, float/value
  88. kPluginBridgeNonRtServerCurrentProgram, // int/index
  89. kPluginBridgeNonRtServerCurrentMidiProgram, // int/index
  90. kPluginBridgeNonRtServerProgramName, // uint/index, uint/size, str[] (name)
  91. kPluginBridgeNonRtServerMidiProgramData, // uint/index, uint/bank, uint/program, uint/size, str[] (name)
  92. kPluginBridgeNonRtServerSetCustomData, // uint/size, str[], uint/size, str[], uint/size, str[]
  93. kPluginBridgeNonRtServerSetChunkDataFile, // uint/size, str[] (filename, base64 content)
  94. kPluginBridgeNonRtServerSetLatency, // uint
  95. kPluginBridgeNonRtServerSetParameterText, // uint/index, uint/size, str[] (name)
  96. kPluginBridgeNonRtServerReady,
  97. kPluginBridgeNonRtServerSaved,
  98. kPluginBridgeNonRtServerUiClosed,
  99. kPluginBridgeNonRtServerError // uint/size, str[]
  100. };
  101. // used for kPluginBridgeNonRtServerPortName
  102. enum PluginBridgePortType {
  103. kPluginBridgePortNull = 0,
  104. kPluginBridgePortAudioInput,
  105. kPluginBridgePortAudioOutput,
  106. kPluginBridgePortCvInput,
  107. kPluginBridgePortCvOutput,
  108. kPluginBridgePortMidiInput,
  109. kPluginBridgePortMidiOutput,
  110. kPluginBridgePortTypeCount
  111. };
  112. enum PluginBridgeTimeInfoFlags {
  113. kPluginBridgeTimeInfoValidBBT = 0x1
  114. };
  115. // -------------------------------------------------------------------------------------------------------------------
  116. struct BridgeSemaphore {
  117. union {
  118. void* server;
  119. char _padServer[64];
  120. };
  121. union {
  122. void* client;
  123. char _padClient[64];
  124. };
  125. };
  126. // NOTE: needs to be 64bit aligned
  127. struct BridgeTimeInfo {
  128. uint64_t playing;
  129. uint64_t frame;
  130. uint64_t usecs;
  131. uint32_t validFlags;
  132. uint32_t unused;
  133. // bbt
  134. int32_t bar, beat;
  135. float beatsPerBar, beatType;
  136. double tick, barStartTick, ticksPerBeat, beatsPerMinute;
  137. };
  138. // -------------------------------------------------------------------------------------------------------------------
  139. static const std::size_t kBridgeRtClientDataMidiOutSize = 511*4;
  140. static const std::size_t kBridgeBaseMidiOutHeaderSize = 6U /* time, port and size */;
  141. // Server => Client RT
  142. struct BridgeRtClientData {
  143. BridgeSemaphore sem;
  144. BridgeTimeInfo timeInfo;
  145. SmallStackBuffer ringBuffer;
  146. uint8_t midiOut[kBridgeRtClientDataMidiOutSize];
  147. uint32_t procFlags;
  148. };
  149. // Server => Client Non-RT
  150. struct BridgeNonRtClientData {
  151. BigStackBuffer ringBuffer;
  152. };
  153. // Client => Server Non-RT
  154. struct BridgeNonRtServerData {
  155. HugeStackBuffer ringBuffer;
  156. };
  157. // -------------------------------------------------------------------------------------------------------------------
  158. #endif // CARLA_BRIDGE_DEFINES_HPP_INCLUDED