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.

169 lines
7.4KB

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