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.

176 lines
7.6KB

  1. /*
  2. * Carla Bridge definitions
  3. * Copyright (C) 2013-2018 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 4
  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,
  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. kPluginBridgeNonRtServerDefaultValue, // uint/index, float/value
  87. kPluginBridgeNonRtServerCurrentProgram, // int/index
  88. kPluginBridgeNonRtServerCurrentMidiProgram, // int/index
  89. kPluginBridgeNonRtServerProgramName, // uint/index, uint/size, str[] (name)
  90. kPluginBridgeNonRtServerMidiProgramData, // uint/index, uint/bank, uint/program, uint/size, str[] (name)
  91. kPluginBridgeNonRtServerSetCustomData, // uint/size, str[], uint/size, str[], uint/size, str[]
  92. kPluginBridgeNonRtServerSetChunkDataFile, // uint/size, str[] (filename, base64 content)
  93. kPluginBridgeNonRtServerSetLatency, // uint
  94. kPluginBridgeNonRtServerSetParameterText, // uint/index, uint/size, str[] (name)
  95. kPluginBridgeNonRtServerReady,
  96. kPluginBridgeNonRtServerSaved,
  97. kPluginBridgeNonRtServerUiClosed,
  98. kPluginBridgeNonRtServerError // uint/size, str[]
  99. };
  100. // used for kPluginBridgeNonRtServerPortName
  101. enum PluginBridgePortType {
  102. kPluginBridgePortNull = 0,
  103. kPluginBridgePortAudioInput,
  104. kPluginBridgePortAudioOutput,
  105. kPluginBridgePortCvInput,
  106. kPluginBridgePortCvOutput,
  107. kPluginBridgePortMidiInput,
  108. kPluginBridgePortMidiOutput,
  109. kPluginBridgePortTypeCount
  110. };
  111. enum PluginBridgeTimeInfoFlags {
  112. kPluginBridgeTimeInfoValidBBT = 0x1
  113. };
  114. // -------------------------------------------------------------------------------------------------------------------
  115. struct BridgeSemaphore {
  116. union {
  117. void* server;
  118. char _padServer[64];
  119. };
  120. union {
  121. void* client;
  122. char _padClient[64];
  123. };
  124. };
  125. // needs to be 64bit aligned
  126. struct BridgeTimeInfo {
  127. uint64_t playing;
  128. uint64_t frame;
  129. uint64_t usecs;
  130. uint32_t validFlags;
  131. // bbt
  132. int32_t bar, beat;
  133. float beatsPerBar, beatType;
  134. double tick, barStartTick, ticksPerBeat, beatsPerMinute;
  135. };
  136. // -------------------------------------------------------------------------------------------------------------------
  137. static const std::size_t kBridgeRtClientDataMidiOutSize = 511*4;
  138. static const std::size_t kBridgeBaseMidiOutHeaderSize = 6U /* time, port and size */;
  139. // Server => Client RT
  140. struct BridgeRtClientData {
  141. BridgeSemaphore sem;
  142. BridgeTimeInfo timeInfo;
  143. SmallStackBuffer ringBuffer;
  144. uint8_t midiOut[kBridgeRtClientDataMidiOutSize];
  145. uint32_t procFlags;
  146. };
  147. // Server => Client Non-RT
  148. struct BridgeNonRtClientData {
  149. BigStackBuffer ringBuffer;
  150. };
  151. // Client => Server Non-RT
  152. struct BridgeNonRtServerData {
  153. HugeStackBuffer ringBuffer;
  154. };
  155. // -------------------------------------------------------------------------------------------------------------------
  156. #endif // CARLA_BRIDGE_DEFINES_HPP_INCLUDED