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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. kPluginBridgeRtClientControlEventParameter, // uint/frame, byte/chan, ushort, float
  26. kPluginBridgeRtClientControlEventMidiBank, // uint/frame, byte/chan, ushort
  27. kPluginBridgeRtClientControlEventMidiProgram, // uint/frame, byte/chan, ushort
  28. kPluginBridgeRtClientControlEventAllSoundOff, // uint/frame, byte/chan
  29. kPluginBridgeRtClientControlEventAllNotesOff, // uint/frame, byte/chan
  30. kPluginBridgeRtClientMidiEvent, // uint/frame, byte/port, byte/size, byte[]/data
  31. kPluginBridgeRtClientProcess,
  32. kPluginBridgeRtClientQuit
  33. };
  34. // Server sends these to client during non-RT
  35. enum PluginBridgeNonRtClientOpcode {
  36. kPluginBridgeNonRtClientNull = 0,
  37. kPluginBridgeNonRtClientPing,
  38. kPluginBridgeNonRtClientPingOnOff, // bool
  39. kPluginBridgeNonRtClientActivate,
  40. kPluginBridgeNonRtClientDeactivate,
  41. kPluginBridgeNonRtClientSetBufferSize, // uint
  42. kPluginBridgeNonRtClientSetSampleRate, // double
  43. kPluginBridgeNonRtClientSetOffline,
  44. kPluginBridgeNonRtClientSetOnline,
  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 = 512*4;
  130. // Server => Client RT
  131. struct BridgeRtClientData {
  132. BridgeSemaphore sem;
  133. BridgeTimeInfo timeInfo;
  134. SmallStackBuffer ringBuffer;
  135. uint8_t midiOut[kBridgeRtClientDataMidiOutSize];
  136. };
  137. // Server => Client Non-RT
  138. struct BridgeNonRtClientData {
  139. BigStackBuffer ringBuffer;
  140. };
  141. // Client => Server Non-RT
  142. struct BridgeNonRtServerData {
  143. HugeStackBuffer ringBuffer;
  144. };
  145. // -------------------------------------------------------------------------------------------------------------------
  146. #endif // CARLA_BRIDGE_DEFINES_HPP_INCLUDED