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.

298 lines
11KB

  1. /*
  2. * Carla Standalone API
  3. * Copyright (C) 2011-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 GPL.txt file
  16. */
  17. #ifndef __CARLA_STANDALONE_HPP__
  18. #define __CARLA_STANDALONE_HPP__
  19. #include "CarlaBackend.hpp"
  20. /*!
  21. * @defgroup CarlaStandaloneAPI Carla Standalone API
  22. *
  23. * The Carla Standalone API
  24. *
  25. * @{
  26. */
  27. typedef CarlaBackend::BinaryType CarlaBinaryType;
  28. typedef CarlaBackend::PluginType CarlaPluginType;
  29. typedef CarlaBackend::PluginCategory CarlaPluginCategory;
  30. typedef CarlaBackend::OptionsType CarlaOptionsType;
  31. typedef CarlaBackend::CallbackFunc CarlaCallbackFunc;
  32. struct CarlaPluginInfo {
  33. CarlaPluginType type;
  34. CarlaPluginCategory category;
  35. unsigned int hints;
  36. unsigned int optionsAvailable;
  37. unsigned int optionsEnabled;
  38. const char* binary;
  39. const char* name;
  40. const char* label;
  41. const char* maker;
  42. const char* copyright;
  43. long uniqueId;
  44. uint32_t latency;
  45. CarlaPluginInfo()
  46. : type(CarlaBackend::PLUGIN_NONE),
  47. category(CarlaBackend::PLUGIN_CATEGORY_NONE),
  48. hints(0x0),
  49. optionsAvailable(0x0),
  50. optionsEnabled(0x0),
  51. binary(nullptr),
  52. name(nullptr),
  53. label(nullptr),
  54. maker(nullptr),
  55. copyright(nullptr),
  56. uniqueId(0),
  57. latency(0) {}
  58. ~CarlaPluginInfo()
  59. {
  60. if (label != nullptr)
  61. delete[] label;
  62. if (maker != nullptr)
  63. delete[] maker;
  64. if (copyright != nullptr)
  65. delete[] copyright;
  66. }
  67. CarlaPluginInfo(CarlaPluginInfo&) = delete;
  68. CarlaPluginInfo(const CarlaPluginInfo&) = delete;
  69. };
  70. struct CarlaNativePluginInfo {
  71. CarlaPluginCategory category;
  72. unsigned int hints;
  73. uint32_t audioIns;
  74. uint32_t audioOuts;
  75. uint32_t midiIns;
  76. uint32_t midiOuts;
  77. uint32_t parameterIns;
  78. uint32_t parameterOuts;
  79. const char* name;
  80. const char* label;
  81. const char* maker;
  82. const char* copyright;
  83. CarlaNativePluginInfo()
  84. : category(CarlaBackend::PLUGIN_CATEGORY_NONE),
  85. hints(0x0),
  86. audioIns(0),
  87. audioOuts(0),
  88. midiIns(0),
  89. midiOuts(0),
  90. parameterIns(0),
  91. parameterOuts(0),
  92. name(nullptr),
  93. label(nullptr),
  94. maker(nullptr),
  95. copyright(nullptr) {}
  96. CarlaNativePluginInfo(CarlaNativePluginInfo&) = delete;
  97. CarlaNativePluginInfo(const CarlaNativePluginInfo&) = delete;
  98. };
  99. struct CarlaPortCountInfo {
  100. uint32_t ins;
  101. uint32_t outs;
  102. uint32_t total;
  103. CarlaPortCountInfo()
  104. : ins(0),
  105. outs(0),
  106. total(0) {}
  107. CarlaPortCountInfo(CarlaPortCountInfo&) = delete;
  108. CarlaPortCountInfo(const CarlaPortCountInfo&) = delete;
  109. };
  110. struct CarlaParameterInfo {
  111. const char* name;
  112. const char* symbol;
  113. const char* unit;
  114. uint32_t scalePointCount;
  115. CarlaParameterInfo()
  116. : name(nullptr),
  117. symbol(nullptr),
  118. unit(nullptr),
  119. scalePointCount(0) {}
  120. ~CarlaParameterInfo()
  121. {
  122. if (name != nullptr)
  123. delete[] name;
  124. if (symbol != nullptr)
  125. delete[] symbol;
  126. if (unit != nullptr)
  127. delete[] unit;
  128. }
  129. CarlaParameterInfo(CarlaParameterInfo&) = delete;
  130. CarlaParameterInfo(const CarlaParameterInfo&) = delete;
  131. };
  132. struct CarlaScalePointInfo {
  133. float value;
  134. const char* label;
  135. CarlaScalePointInfo()
  136. : value(0.0f),
  137. label(nullptr) {}
  138. ~CarlaScalePointInfo()
  139. {
  140. if (label != nullptr)
  141. delete[] label;
  142. }
  143. CarlaScalePointInfo(CarlaScalePointInfo&) = delete;
  144. CarlaScalePointInfo(const CarlaScalePointInfo&) = delete;
  145. };
  146. struct CarlaTransportInfo {
  147. bool playing;
  148. uint32_t frame;
  149. int32_t bar;
  150. int32_t beat;
  151. int32_t tick;
  152. double bpm;
  153. CarlaTransportInfo()
  154. : playing(false),
  155. frame(0),
  156. bar(0),
  157. beat(0),
  158. bpm(0.0) {}
  159. CarlaTransportInfo(CarlaTransportInfo&) = delete;
  160. CarlaTransportInfo(const CarlaTransportInfo&) = delete;
  161. };
  162. CARLA_EXPORT const char* carla_get_extended_license_text();
  163. CARLA_EXPORT const char* carla_get_supported_file_types();
  164. CARLA_EXPORT unsigned int carla_get_engine_driver_count();
  165. CARLA_EXPORT const char* carla_get_engine_driver_name(unsigned int index);
  166. CARLA_EXPORT unsigned int carla_get_internal_plugin_count();
  167. CARLA_EXPORT const CarlaNativePluginInfo* carla_get_internal_plugin_info(unsigned int internalPluginId);
  168. CARLA_EXPORT bool carla_engine_init(const char* driverName, const char* clientName);
  169. CARLA_EXPORT bool carla_engine_close();
  170. CARLA_EXPORT void carla_engine_idle();
  171. CARLA_EXPORT bool carla_is_engine_running();
  172. CARLA_EXPORT void carla_set_engine_about_to_close();
  173. CARLA_EXPORT void carla_set_engine_callback(CarlaCallbackFunc func, void* ptr);
  174. CARLA_EXPORT void carla_set_engine_option(CarlaOptionsType option, int value, const char* valueStr);
  175. CARLA_EXPORT bool carla_load_project(const char* filename);
  176. CARLA_EXPORT bool carla_save_project(const char* filename);
  177. CARLA_EXPORT void carla_patchbay_connect(int portA, int portB);
  178. CARLA_EXPORT void carla_patchbay_disconnect(int connectionId);
  179. CARLA_EXPORT void carla_patchbay_refresh();
  180. CARLA_EXPORT void carla_transport_play();
  181. CARLA_EXPORT void carla_transport_pause();
  182. CARLA_EXPORT void carla_transport_relocate(uint32_t frames);
  183. CARLA_EXPORT uint32_t carla_get_current_transport_frame();
  184. CARLA_EXPORT const CarlaTransportInfo* carla_get_transport_info();
  185. CARLA_EXPORT bool carla_add_plugin(CarlaBinaryType btype, CarlaPluginType ptype, const char* filename, const char* name, const char* label, const void* extraPtr);
  186. CARLA_EXPORT bool carla_remove_plugin(unsigned int pluginId);
  187. CARLA_EXPORT void carla_remove_all_plugins();
  188. CARLA_EXPORT bool carla_load_plugin_state(unsigned int pluginId, const char* filename);
  189. CARLA_EXPORT bool carla_save_plugin_state(unsigned int pluginId, const char* filename);
  190. CARLA_EXPORT const CarlaPluginInfo* carla_get_plugin_info(unsigned int pluginId);
  191. CARLA_EXPORT const CarlaPortCountInfo* carla_get_audio_port_count_info(unsigned int pluginId);
  192. CARLA_EXPORT const CarlaPortCountInfo* carla_get_midi_port_count_info(unsigned int pluginId);
  193. CARLA_EXPORT const CarlaPortCountInfo* carla_get_parameter_count_info(unsigned int pluginId);
  194. CARLA_EXPORT const CarlaParameterInfo* carla_get_parameter_info(unsigned int pluginId, uint32_t parameterId);
  195. CARLA_EXPORT const CarlaScalePointInfo* carla_get_parameter_scalepoint_info(unsigned int pluginId, uint32_t parameterId, uint32_t scalePointId);
  196. CARLA_EXPORT const CarlaBackend::ParameterData* carla_get_parameter_data(unsigned int pluginId, uint32_t parameterId);
  197. CARLA_EXPORT const CarlaBackend::ParameterRanges* carla_get_parameter_ranges(unsigned int pluginId, uint32_t parameterId);
  198. CARLA_EXPORT const CarlaBackend::MidiProgramData* carla_get_midi_program_data(unsigned int pluginId, uint32_t midiProgramId);
  199. CARLA_EXPORT const CarlaBackend::CustomData* carla_get_custom_data(unsigned int pluginId, uint32_t customDataId);
  200. CARLA_EXPORT const char* carla_get_chunk_data(unsigned int pluginId);
  201. CARLA_EXPORT uint32_t carla_get_parameter_count(unsigned int pluginId);
  202. CARLA_EXPORT uint32_t carla_get_program_count(unsigned int pluginId);
  203. CARLA_EXPORT uint32_t carla_get_midi_program_count(unsigned int pluginId);
  204. CARLA_EXPORT uint32_t carla_get_custom_data_count(unsigned int pluginId);
  205. CARLA_EXPORT const char* carla_get_parameter_text(unsigned int pluginId, uint32_t parameterId);
  206. CARLA_EXPORT const char* carla_get_program_name(unsigned int pluginId, uint32_t programId);
  207. CARLA_EXPORT const char* carla_get_midi_program_name(unsigned int pluginId, uint32_t midiProgramId);
  208. CARLA_EXPORT const char* carla_get_real_plugin_name(unsigned int pluginId);
  209. CARLA_EXPORT int32_t carla_get_current_program_index(unsigned int pluginId);
  210. CARLA_EXPORT int32_t carla_get_current_midi_program_index(unsigned int pluginId);
  211. CARLA_EXPORT float carla_get_default_parameter_value(unsigned int pluginId, uint32_t parameterId);
  212. CARLA_EXPORT float carla_get_current_parameter_value(unsigned int pluginId, uint32_t parameterId);
  213. CARLA_EXPORT float carla_get_input_peak_value(unsigned int pluginId, unsigned short portId);
  214. CARLA_EXPORT float carla_get_output_peak_value(unsigned int pluginId, unsigned short portId);
  215. CARLA_EXPORT void carla_set_option(unsigned int pluginId, unsigned int option, bool yesNo);
  216. CARLA_EXPORT void carla_set_active(unsigned int pluginId, bool onOff);
  217. CARLA_EXPORT void carla_set_drywet(unsigned int pluginId, float value);
  218. CARLA_EXPORT void carla_set_volume(unsigned int pluginId, float value);
  219. CARLA_EXPORT void carla_set_balance_left(unsigned int pluginId, float value);
  220. CARLA_EXPORT void carla_set_balance_right(unsigned int pluginId, float value);
  221. CARLA_EXPORT void carla_set_panning(unsigned int pluginId, float value);
  222. CARLA_EXPORT void carla_set_ctrl_channel(unsigned int pluginId, int8_t channel);
  223. CARLA_EXPORT void carla_set_parameter_value(unsigned int pluginId, uint32_t parameterId, float value);
  224. CARLA_EXPORT void carla_set_parameter_midi_channel(unsigned int pluginId, uint32_t parameterId, uint8_t channel);
  225. CARLA_EXPORT void carla_set_parameter_midi_cc(unsigned int pluginId, uint32_t parameterId, int16_t cc);
  226. CARLA_EXPORT void carla_set_program(unsigned int pluginId, uint32_t programId);
  227. CARLA_EXPORT void carla_set_midi_program(unsigned int pluginId, uint32_t midiProgramId);
  228. CARLA_EXPORT void carla_set_custom_data(unsigned int pluginId, const char* type, const char* key, const char* value);
  229. CARLA_EXPORT void carla_set_chunk_data(unsigned int pluginId, const char* chunkData);
  230. CARLA_EXPORT void carla_prepare_for_save(unsigned int pluginId);
  231. CARLA_EXPORT void carla_send_midi_note(unsigned int pluginId, uint8_t channel, uint8_t note, uint8_t velocity);
  232. CARLA_EXPORT void carla_show_gui(unsigned int pluginId, bool yesNo);
  233. CARLA_EXPORT uint32_t carla_get_buffer_size();
  234. CARLA_EXPORT double carla_get_sample_rate();
  235. CARLA_EXPORT const char* carla_get_last_error();
  236. CARLA_EXPORT const char* carla_get_host_osc_url();
  237. CARLA_EXPORT void carla_nsm_announce(const char* url, int pid);
  238. CARLA_EXPORT void carla_nsm_reply_open();
  239. CARLA_EXPORT void carla_nsm_reply_save();
  240. #ifdef BUILD_BRIDGE
  241. CARLA_EXPORT bool carla_engine_init_bridge(const char* audioBaseName, const char* controlBaseName, const char* clientName);
  242. CARLA_EXPORT CarlaBackend::CarlaEngine* carla_get_standalone_engine();
  243. #endif
  244. /**@}*/
  245. #endif // __CARLA_STANDALONE_HPP__