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.

CarlaBridgeUtils.hpp 6.1KB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * Carla Bridge utils
  3. * Copyright (C) 2013 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 "CarlaRingBuffer.hpp"
  20. // -----------------------------------------------------------------------
  21. enum PluginBridgeInfoType {
  22. kPluginBridgeAudioCount = 0,
  23. kPluginBridgeMidiCount,
  24. kPluginBridgeParameterCount,
  25. kPluginBridgeProgramCount,
  26. kPluginBridgeMidiProgramCount,
  27. kPluginBridgePluginInfo,
  28. kPluginBridgeParameterInfo,
  29. kPluginBridgeParameterData,
  30. kPluginBridgeParameterRanges,
  31. kPluginBridgeProgramInfo,
  32. kPluginBridgeMidiProgramInfo,
  33. kPluginBridgeConfigure,
  34. kPluginBridgeSetParameterValue,
  35. kPluginBridgeSetDefaultValue,
  36. kPluginBridgeSetProgram,
  37. kPluginBridgeSetMidiProgram,
  38. kPluginBridgeSetCustomData,
  39. kPluginBridgeSetChunkData,
  40. kPluginBridgeUpdateNow,
  41. kPluginBridgeError
  42. };
  43. enum PluginBridgeOpcode {
  44. kPluginBridgeOpcodeNull = 0,
  45. kPluginBridgeOpcodeSetAudioPool = 1, // long
  46. kPluginBridgeOpcodeSetBufferSize = 2, // int
  47. kPluginBridgeOpcodeSetSampleRate = 3, // float
  48. kPluginBridgeOpcodeSetParameter = 4, // int, float
  49. kPluginBridgeOpcodeSetProgram = 5, // int
  50. kPluginBridgeOpcodeSetMidiProgram = 6, // int
  51. kPluginBridgeOpcodeMidiEvent = 7, // long, int, char[] (long = timeFrame, int = size max 4)
  52. kPluginBridgeOpcodeProcess = 8,
  53. kPluginBridgeOpcodeQuit = 9
  54. };
  55. const char* const CARLA_BRIDGE_MSG_HIDE_GUI = "CarlaBridgeHideGUI"; //!< Plugin -> Host call, tells host GUI is now hidden
  56. const char* const CARLA_BRIDGE_MSG_SAVED = "CarlaBridgeSaved"; //!< Plugin -> Host call, tells host state is saved
  57. #if 0
  58. const char* const CARLA_BRIDGE_MSG_SAVE_NOW = "CarlaBridgeSaveNow"; //!< Host -> Plugin call, tells plugin to save state now
  59. const char* const CARLA_BRIDGE_MSG_SET_CHUNK = "CarlaBridgeSetChunk"; //!< Host -> Plugin call, tells plugin to set chunk in file \a value
  60. 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").
  61. //If \a type is 'chunk' or 'binary' \a rvalue refers to chunk file.
  62. #endif
  63. // -----------------------------------------------------------------------
  64. PRE_PACKED_STRUCTURE
  65. struct BridgeShmControl {
  66. union {
  67. void* runServer;
  68. char _padServer[32];
  69. };
  70. union {
  71. void* runClient;
  72. char _padClient[32];
  73. };
  74. RingBuffer ringBuffer;
  75. } POST_PACKED_STRUCTURE;
  76. // -----------------------------------------------------------------------
  77. static inline
  78. const char* PluginBridgeInfoType2str(const PluginBridgeInfoType type)
  79. {
  80. switch (type)
  81. {
  82. case kPluginBridgeAudioCount:
  83. return "kPluginBridgeAudioCount";
  84. case kPluginBridgeMidiCount:
  85. return "kPluginBridgeMidiCount";
  86. case kPluginBridgeParameterCount:
  87. return "kPluginBridgeParameterCount";
  88. case kPluginBridgeProgramCount:
  89. return "kPluginBridgeProgramCount";
  90. case kPluginBridgeMidiProgramCount:
  91. return "kPluginBridgeMidiProgramCount";
  92. case kPluginBridgePluginInfo:
  93. return "kPluginBridgePluginInfo";
  94. case kPluginBridgeParameterInfo:
  95. return "kPluginBridgeParameterInfo";
  96. case kPluginBridgeParameterData:
  97. return "kPluginBridgeParameterData";
  98. case kPluginBridgeParameterRanges:
  99. return "kPluginBridgeParameterRanges";
  100. case kPluginBridgeProgramInfo:
  101. return "kPluginBridgeProgramInfo";
  102. case kPluginBridgeMidiProgramInfo:
  103. return "kPluginBridgeMidiProgramInfo";
  104. case kPluginBridgeConfigure:
  105. return "kPluginBridgeConfigure";
  106. case kPluginBridgeSetParameterValue:
  107. return "kPluginBridgeSetParameterValue";
  108. case kPluginBridgeSetDefaultValue:
  109. return "kPluginBridgeSetDefaultValue";
  110. case kPluginBridgeSetProgram:
  111. return "kPluginBridgeSetProgram";
  112. case kPluginBridgeSetMidiProgram:
  113. return "kPluginBridgeSetMidiProgram";
  114. case kPluginBridgeSetCustomData:
  115. return "kPluginBridgeSetCustomData";
  116. case kPluginBridgeSetChunkData:
  117. return "kPluginBridgeSetChunkData";
  118. case kPluginBridgeUpdateNow:
  119. return "kPluginBridgeUpdateNow";
  120. case kPluginBridgeError:
  121. return "kPluginBridgeError";
  122. }
  123. carla_stderr("CarlaBackend::PluginBridgeInfoType2str(%i) - invalid type", type);
  124. return nullptr;
  125. }
  126. static inline
  127. const char* PluginBridgeOpcode2str(const PluginBridgeOpcode opcode)
  128. {
  129. switch (opcode)
  130. {
  131. case kPluginBridgeOpcodeNull:
  132. return "kPluginBridgeOpcodeNull";
  133. case kPluginBridgeOpcodeSetAudioPool:
  134. return "kPluginBridgeOpcodeSetAudioPool";
  135. case kPluginBridgeOpcodeSetBufferSize:
  136. return "kPluginBridgeOpcodeSetBufferSize";
  137. case kPluginBridgeOpcodeSetSampleRate:
  138. return "kPluginBridgeOpcodeSetSampleRate";
  139. case kPluginBridgeOpcodeSetParameter:
  140. return "kPluginBridgeOpcodeSetParameter";
  141. case kPluginBridgeOpcodeSetProgram:
  142. return "kPluginBridgeOpcodeSetProgram";
  143. case kPluginBridgeOpcodeSetMidiProgram:
  144. return "kPluginBridgeOpcodeSetMidiProgram";
  145. case kPluginBridgeOpcodeMidiEvent:
  146. return "kPluginBridgeOpcodeMidiEvent";
  147. case kPluginBridgeOpcodeProcess:
  148. return "kPluginBridgeOpcodeProcess";
  149. case kPluginBridgeOpcodeQuit:
  150. return "kPluginBridgeOpcodeQuit";
  151. }
  152. carla_stderr("CarlaBackend::PluginBridgeOpcode2str(%i) - invalid opcode", opcode);
  153. return nullptr;
  154. }
  155. // -----------------------------------------------------------------------
  156. #endif // CARLA_BRIDGE_UTILS_HPP_INCLUDED