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.

CarlaBridgeDefines.hpp 7.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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. enum PluginBridgeTimeInfoFlags {
  109. kPluginBridgeTimeInfoValidBBT = 0x1
  110. };
  111. // -------------------------------------------------------------------------------------------------------------------
  112. struct BridgeSemaphore {
  113. union {
  114. void* server;
  115. char _padServer[64];
  116. };
  117. union {
  118. void* client;
  119. char _padClient[64];
  120. };
  121. };
  122. // needs to be 64bit aligned
  123. struct BridgeTimeInfo {
  124. uint64_t playing;
  125. uint64_t frame;
  126. uint64_t usecs;
  127. uint32_t validFlags;
  128. // bbt
  129. int32_t bar, beat, tick;
  130. float beatsPerBar, beatType;
  131. double barStartTick, ticksPerBeat, beatsPerMinute;
  132. };
  133. // -------------------------------------------------------------------------------------------------------------------
  134. static const std::size_t kBridgeRtClientDataMidiOutSize = 511*4;
  135. static const std::size_t kBridgeBaseMidiOutHeaderSize = 6U /* time, port and size */;
  136. // Server => Client RT
  137. struct BridgeRtClientData {
  138. BridgeSemaphore sem;
  139. BridgeTimeInfo timeInfo;
  140. SmallStackBuffer ringBuffer;
  141. uint8_t midiOut[kBridgeRtClientDataMidiOutSize];
  142. uint32_t procFlags;
  143. };
  144. // Server => Client Non-RT
  145. struct BridgeNonRtClientData {
  146. BigStackBuffer ringBuffer;
  147. };
  148. // Client => Server Non-RT
  149. struct BridgeNonRtServerData {
  150. HugeStackBuffer ringBuffer;
  151. };
  152. // -------------------------------------------------------------------------------------------------------------------
  153. #endif // CARLA_BRIDGE_DEFINES_HPP_INCLUDED