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.

185 lines
7.4KB

  1. /*
  2. * Carla Bridge utils
  3. * Copyright (C) 2013-2014 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_UTILS_HPP_INCLUDED
  18. #define CARLA_BRIDGE_UTILS_HPP_INCLUDED
  19. #include "CarlaBackend.h"
  20. #include "CarlaRingBuffer.hpp"
  21. // -----------------------------------------------------------------------
  22. enum PluginBridgeInfoType {
  23. kPluginBridgePong = 0,
  24. kPluginBridgePluginInfo1, // uuh => category, hints, uniqueId
  25. kPluginBridgePluginInfo2, // ssss => realName, label, maker, copyright
  26. kPluginBridgeAudioCount, // uu => ins, outs
  27. kPluginBridgeMidiCount, // uu => ins, outs
  28. kPluginBridgeParameterCount, // uu => ins, outs
  29. kPluginBridgeProgramCount, // u => count
  30. kPluginBridgeMidiProgramCount, // u => count
  31. kPluginBridgeParameterData, // uiuuss => index, rindex, type, hints, name, unit
  32. kPluginBridgeParameterRanges1, // ufff => index, def, min, max
  33. kPluginBridgeParameterRanges2, // ufff => index, step, stepSmall, stepLarge
  34. kPluginBridgeParameterMidiCC, // ui => index, cc
  35. kPluginBridgeParameterMidiChannel, // uu => index, channel
  36. kPluginBridgeParameterValue, // uf => index, value
  37. kPluginBridgeDefaultValue, // uf => index, value
  38. kPluginBridgeCurrentProgram, // i => index
  39. kPluginBridgeCurrentMidiProgram, // i => index
  40. kPluginBridgeProgramName, // us => index, name
  41. kPluginBridgeMidiProgramData, // uuus => index, bank, program, name
  42. kPluginBridgeConfigure, // ss => key, value
  43. kPluginBridgeSetCustomData, // sss => type, key, value
  44. kPluginBridgeSetChunkData, // s => chunkFile
  45. kPluginBridgeUpdateNow, //
  46. kPluginBridgeError //
  47. };
  48. enum PluginBridgeOpcode {
  49. kPluginBridgeOpcodeNull = 0,
  50. kPluginBridgeOpcodeSetAudioPool = 1, // long
  51. kPluginBridgeOpcodeSetBufferSize = 2, // int
  52. kPluginBridgeOpcodeSetSampleRate = 3, // float
  53. kPluginBridgeOpcodeSetParameter = 4, // int, float
  54. kPluginBridgeOpcodeSetProgram = 5, // int
  55. kPluginBridgeOpcodeSetMidiProgram = 6, // int
  56. kPluginBridgeOpcodeMidiEvent = 7, // long, int, char[] (long = timeFrame, int = size max 4)
  57. kPluginBridgeOpcodeProcess = 8,
  58. kPluginBridgeOpcodeQuit = 9
  59. };
  60. const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
  61. const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved
  62. #if 0
  63. const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now
  64. const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value
  65. const char* const CARLA_BRIDGE_MSG_SET_CUSTOM = "CarlaBridgeSetCustom"; //!< Host -> Plugin call, tells plugin to set a custom data set using \a value ("type·key·rvalue").
  66. //If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file.
  67. #endif
  68. // -----------------------------------------------------------------------
  69. PRE_PACKED_STRUCTURE
  70. struct BridgeShmControl {
  71. union {
  72. void* runServer;
  73. char _padServer[32];
  74. };
  75. union {
  76. void* runClient;
  77. char _padClient[32];
  78. };
  79. StackRingBuffer ringBuffer;
  80. } POST_PACKED_STRUCTURE;
  81. // -----------------------------------------------------------------------
  82. static inline
  83. const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type) noexcept
  84. {
  85. switch (type)
  86. {
  87. case kPluginBridgePong:
  88. return "kPluginBridgePong";
  89. case kPluginBridgePluginInfo1:
  90. return "kPluginBridgePluginInfo1";
  91. case kPluginBridgePluginInfo2:
  92. return "kPluginBridgePluginInfo2";
  93. case kPluginBridgeAudioCount:
  94. return "kPluginBridgeAudioCount";
  95. case kPluginBridgeMidiCount:
  96. return "kPluginBridgeMidiCount";
  97. case kPluginBridgeParameterCount:
  98. return "kPluginBridgeParameterCount";
  99. case kPluginBridgeProgramCount:
  100. return "kPluginBridgeProgramCount";
  101. case kPluginBridgeMidiProgramCount:
  102. return "kPluginBridgeMidiProgramCount";
  103. case kPluginBridgeParameterData:
  104. return "kPluginBridgeParameterData";
  105. case kPluginBridgeParameterRanges1:
  106. return "kPluginBridgeParameterRanges1";
  107. case kPluginBridgeParameterRanges2:
  108. return "kPluginBridgeParameterRanges2";
  109. case kPluginBridgeParameterMidiCC:
  110. return "kPluginBridgeParameterMidiCC";
  111. case kPluginBridgeParameterMidiChannel:
  112. return "kPluginBridgeParameterMidiChannel";
  113. case kPluginBridgeParameterValue:
  114. return "kPluginBridgeParameterValue";
  115. case kPluginBridgeDefaultValue:
  116. return "kPluginBridgeDefaultValue";
  117. case kPluginBridgeCurrentProgram:
  118. return "kPluginBridgeCurrentProgram";
  119. case kPluginBridgeCurrentMidiProgram:
  120. return "kPluginBridgeCurrentMidiProgram";
  121. case kPluginBridgeProgramName:
  122. return "kPluginBridgeProgramName";
  123. case kPluginBridgeMidiProgramData:
  124. return "kPluginBridgeMidiProgramData";
  125. case kPluginBridgeConfigure:
  126. return "kPluginBridgeConfigure";
  127. case kPluginBridgeSetCustomData:
  128. return "kPluginBridgeSetCustomData";
  129. case kPluginBridgeSetChunkData:
  130. return "kPluginBridgeSetChunkData";
  131. case kPluginBridgeUpdateNow:
  132. return "kPluginBridgeUpdateNow";
  133. case kPluginBridgeError:
  134. return "kPluginBridgeError";
  135. }
  136. carla_stderr("CarlaBackend::PluginBridgeInfoType2str(%i) - invalid type", type);
  137. return nullptr;
  138. }
  139. static inline
  140. const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode) noexcept
  141. {
  142. switch (opcode)
  143. {
  144. case kPluginBridgeOpcodeNull:
  145. return "kPluginBridgeOpcodeNull";
  146. case kPluginBridgeOpcodeSetAudioPool:
  147. return "kPluginBridgeOpcodeSetAudioPool";
  148. case kPluginBridgeOpcodeSetBufferSize:
  149. return "kPluginBridgeOpcodeSetBufferSize";
  150. case kPluginBridgeOpcodeSetSampleRate:
  151. return "kPluginBridgeOpcodeSetSampleRate";
  152. case kPluginBridgeOpcodeSetParameter:
  153. return "kPluginBridgeOpcodeSetParameter";
  154. case kPluginBridgeOpcodeSetProgram:
  155. return "kPluginBridgeOpcodeSetProgram";
  156. case kPluginBridgeOpcodeSetMidiProgram:
  157. return "kPluginBridgeOpcodeSetMidiProgram";
  158. case kPluginBridgeOpcodeMidiEvent:
  159. return "kPluginBridgeOpcodeMidiEvent";
  160. case kPluginBridgeOpcodeProcess:
  161. return "kPluginBridgeOpcodeProcess";
  162. case kPluginBridgeOpcodeQuit:
  163. return "kPluginBridgeOpcodeQuit";
  164. }
  165. carla_stderr("CarlaBackend::PluginBridgeOpcode2str(%i) - invalid opcode", opcode);
  166. return nullptr;
  167. }
  168. // -----------------------------------------------------------------------
  169. #endif // CARLA_BRIDGE_UTILS_HPP_INCLUDED