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.

175 lines
7.6KB

  1. /*
  2. * Carla Bridge definitions
  3. * Copyright (C) 2013-2017 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 2
  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. kPluginBridgeNonRtClientShowUI,
  59. kPluginBridgeNonRtClientHideUI,
  60. kPluginBridgeNonRtClientUiParameterChange, // uint, float
  61. kPluginBridgeNonRtClientUiProgramChange, // uint
  62. kPluginBridgeNonRtClientUiMidiProgramChange, // uint
  63. kPluginBridgeNonRtClientUiNoteOn, // byte, byte, byte
  64. kPluginBridgeNonRtClientUiNoteOff, // byte, byte
  65. kPluginBridgeNonRtClientQuit
  66. };
  67. // Client sends these to server during non-RT
  68. enum PluginBridgeNonRtServerOpcode {
  69. kPluginBridgeNonRtServerNull = 0,
  70. kPluginBridgeNonRtServerPong,
  71. kPluginBridgeNonRtServerPluginInfo1, // uint/category, uint/hints, uint/optionsAvailable, uint/optionsEnabled, long/uniqueId
  72. kPluginBridgeNonRtServerPluginInfo2, // uint/size, str[] (realName), uint/size, str[] (label), uint/size, str[] (maker), uint/size, str[] (copyright)
  73. kPluginBridgeNonRtServerAudioCount, // uint/ins, uint/outs
  74. kPluginBridgeNonRtServerMidiCount, // uint/ins, uint/outs
  75. kPluginBridgeNonRtServerCvCount, // uint/ins, uint/outs
  76. kPluginBridgeNonRtServerParameterCount, // uint/count
  77. kPluginBridgeNonRtServerProgramCount, // uint/count
  78. kPluginBridgeNonRtServerMidiProgramCount, // uint/count
  79. kPluginBridgeNonRtServerPortName, // byte/type, uint/index, uint/size, str[] (name)
  80. kPluginBridgeNonRtServerParameterData1, // uint/index, int/rindex, uint/type, uint/hints, short/cc
  81. kPluginBridgeNonRtServerParameterData2, // uint/index, uint/size, str[] (name), uint/size, str[] (symbol), uint/size, str[] (unit)
  82. kPluginBridgeNonRtServerParameterRanges, // uint/index, float/def, float/min, float/max, float/step, float/stepSmall, float/stepLarge
  83. kPluginBridgeNonRtServerParameterValue, // uint/index, float/value
  84. kPluginBridgeNonRtServerParameterValue2, // uint/index, float/value (used for init/output parameters only, don't resend values)
  85. kPluginBridgeNonRtServerDefaultValue, // uint/index, float/value
  86. kPluginBridgeNonRtServerCurrentProgram, // int/index
  87. kPluginBridgeNonRtServerCurrentMidiProgram, // int/index
  88. kPluginBridgeNonRtServerProgramName, // uint/index, uint/size, str[] (name)
  89. kPluginBridgeNonRtServerMidiProgramData, // uint/index, uint/bank, uint/program, uint/size, str[] (name)
  90. kPluginBridgeNonRtServerSetCustomData, // uint/size, str[], uint/size, str[], uint/size, str[]
  91. kPluginBridgeNonRtServerSetChunkDataFile, // uint/size, str[] (filename, base64 content)
  92. kPluginBridgeNonRtServerSetLatency, // uint
  93. kPluginBridgeNonRtServerSetParameterText, // uint/index, uint/size, str[] (name)
  94. kPluginBridgeNonRtServerReady,
  95. kPluginBridgeNonRtServerSaved,
  96. kPluginBridgeNonRtServerUiClosed,
  97. kPluginBridgeNonRtServerError // uint/size, str[]
  98. };
  99. // used for kPluginBridgeNonRtServerPortName
  100. enum PluginBridgePortType {
  101. kPluginBridgePortNull = 0,
  102. kPluginBridgePortAudioInput,
  103. kPluginBridgePortAudioOutput,
  104. kPluginBridgePortCvInput,
  105. kPluginBridgePortCvOutput,
  106. kPluginBridgePortMidiInput,
  107. kPluginBridgePortMidiOutput,
  108. kPluginBridgePortTypeCount
  109. };
  110. enum PluginBridgeTimeInfoFlags {
  111. kPluginBridgeTimeInfoValidBBT = 0x1
  112. };
  113. // -------------------------------------------------------------------------------------------------------------------
  114. struct BridgeSemaphore {
  115. union {
  116. void* server;
  117. char _padServer[64];
  118. };
  119. union {
  120. void* client;
  121. char _padClient[64];
  122. };
  123. };
  124. // needs to be 64bit aligned
  125. struct BridgeTimeInfo {
  126. uint64_t playing;
  127. uint64_t frame;
  128. uint64_t usecs;
  129. uint32_t validFlags;
  130. // bbt
  131. int32_t bar, beat, tick;
  132. float beatsPerBar, beatType;
  133. double barStartTick, ticksPerBeat, beatsPerMinute;
  134. };
  135. // -------------------------------------------------------------------------------------------------------------------
  136. static const std::size_t kBridgeRtClientDataMidiOutSize = 511*4;
  137. static const std::size_t kBridgeBaseMidiOutHeaderSize = 6U /* time, port and size */;
  138. // Server => Client RT
  139. struct BridgeRtClientData {
  140. BridgeSemaphore sem;
  141. BridgeTimeInfo timeInfo;
  142. SmallStackBuffer ringBuffer;
  143. uint8_t midiOut[kBridgeRtClientDataMidiOutSize];
  144. uint32_t procFlags;
  145. };
  146. // Server => Client Non-RT
  147. struct BridgeNonRtClientData {
  148. BigStackBuffer ringBuffer;
  149. };
  150. // Client => Server Non-RT
  151. struct BridgeNonRtServerData {
  152. HugeStackBuffer ringBuffer;
  153. };
  154. // -------------------------------------------------------------------------------------------------------------------
  155. #endif // CARLA_BRIDGE_DEFINES_HPP_INCLUDED