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.

166 lines
7.3KB

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