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.

255 lines
7.9KB

  1. /*
  2. * Carla Native Plugin API
  3. * Copyright (C) 2012-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_NATIVE_H__
  18. #define __CARLA_NATIVE_H__
  19. #ifdef __cplusplus
  20. # include <cstddef>
  21. # include <cstdint>
  22. extern "C" {
  23. #else
  24. # include <stdbool.h>
  25. # include <stddef.h>
  26. # include <stdint.h>
  27. #endif
  28. /*!
  29. * @defgroup CarlaNativeAPI Carla Native API
  30. *
  31. * The Carla Native API
  32. *
  33. * @{
  34. */
  35. typedef void* HostHandle;
  36. typedef void* PluginHandle;
  37. typedef enum _PluginCategory {
  38. PLUGIN_CATEGORY_NONE = 0, //!< Null plugin category.
  39. PLUGIN_CATEGORY_SYNTH = 1, //!< A synthesizer or generator.
  40. PLUGIN_CATEGORY_DELAY = 2, //!< A delay or reverberator.
  41. PLUGIN_CATEGORY_EQ = 3, //!< An equalizer.
  42. PLUGIN_CATEGORY_FILTER = 4, //!< A filter.
  43. PLUGIN_CATEGORY_DYNAMICS = 5, //!< A 'dynamic' plugin (amplifier, compressor, gate, etc).
  44. PLUGIN_CATEGORY_MODULATOR = 6, //!< A 'modulator' plugin (chorus, flanger, phaser, etc).
  45. PLUGIN_CATEGORY_UTILITY = 7, //!< An 'utility' plugin (analyzer, converter, mixer, etc).
  46. PLUGIN_CATEGORY_OTHER = 8 //!< Misc plugin (used to check if the plugin has a category).
  47. } PluginCategory;
  48. typedef enum _PluginHints {
  49. PLUGIN_IS_RTSAFE = 1 << 0,
  50. PLUGIN_IS_SYNTH = 1 << 1,
  51. PLUGIN_HAS_GUI = 1 << 2,
  52. PLUGIN_USES_SINGLE_THREAD = 1 << 3,
  53. PLUGIN_USES_STATE = 1 << 4
  54. } PluginHints;
  55. typedef enum _ParameterHints {
  56. PARAMETER_IS_OUTPUT = 1 << 0,
  57. PARAMETER_IS_ENABLED = 1 << 1,
  58. PARAMETER_IS_AUTOMABLE = 1 << 2,
  59. PARAMETER_IS_BOOLEAN = 1 << 3,
  60. PARAMETER_IS_INTEGER = 1 << 4,
  61. PARAMETER_IS_LOGARITHMIC = 1 << 5,
  62. PARAMETER_USES_SAMPLE_RATE = 1 << 6,
  63. PARAMETER_USES_SCALEPOINTS = 1 << 7,
  64. PARAMETER_USES_CUSTOM_TEXT = 1 << 8
  65. } ParameterHints;
  66. typedef struct _ParameterScalePoint {
  67. const char* label;
  68. float value;
  69. } ParameterScalePoint;
  70. typedef struct _ParameterRanges {
  71. float def;
  72. float min;
  73. float max;
  74. float step;
  75. float stepSmall;
  76. float stepLarge;
  77. } ParameterRanges;
  78. #define PARAMETER_RANGES_DEFAULT_STEP 0.01f
  79. #define PARAMETER_RANGES_DEFAULT_STEP_SMALL 0.0001f
  80. #define PARAMETER_RANGES_DEFAULT_STEP_LARGE 0.1f
  81. typedef struct _Parameter {
  82. ParameterHints hints;
  83. const char* name;
  84. const char* unit;
  85. ParameterRanges ranges;
  86. uint32_t scalePointCount;
  87. ParameterScalePoint* scalePoints;
  88. } Parameter;
  89. typedef struct _MidiEvent {
  90. uint8_t port;
  91. uint32_t time;
  92. uint8_t data[4];
  93. uint8_t size;
  94. } MidiEvent;
  95. typedef struct _MidiProgram {
  96. uint32_t bank;
  97. uint32_t program;
  98. const char* name;
  99. } MidiProgram;
  100. typedef struct _TimeInfoBBT {
  101. bool valid;
  102. int32_t bar; //!< current bar
  103. int32_t beat; //!< current beat-within-bar
  104. int32_t tick; //!< current tick-within-beat
  105. double barStartTick;
  106. float beatsPerBar; //!< time signature "numerator"
  107. float beatType; //!< time signature "denominator"
  108. double ticksPerBeat;
  109. double beatsPerMinute;
  110. } TimeInfoBBT;
  111. typedef struct _TimeInfo {
  112. bool playing;
  113. uint32_t frame;
  114. uint32_t usecs;
  115. TimeInfoBBT bbt;
  116. } TimeInfo;
  117. typedef struct _HostDescriptor {
  118. HostHandle handle;
  119. const char* ui_name;
  120. uint32_t (*get_buffer_size)(HostHandle handle);
  121. double (*get_sample_rate)(HostHandle handle);
  122. const TimeInfo* (*get_time_info)(HostHandle handle);
  123. bool (*write_midi_event)(HostHandle handle, const MidiEvent* event);
  124. void (*ui_parameter_changed)(HostHandle handle, uint32_t index, float value);
  125. void (*ui_midi_program_changed)(HostHandle handle, uint32_t bank, uint32_t program);
  126. void (*ui_custom_data_changed)(HostHandle handle, const char* key, const char* value);
  127. void (*ui_closed)(HostHandle handle);
  128. const char* (*ui_open_file)(HostHandle handle, bool isDir, const char* title, const char* filter);
  129. const char* (*ui_save_file)(HostHandle handle, bool isDir, const char* title, const char* filter);
  130. } HostDescriptor;
  131. typedef struct _PluginDescriptor {
  132. const PluginCategory category;
  133. const PluginHints hints;
  134. const uint32_t audioIns;
  135. const uint32_t audioOuts;
  136. const uint32_t midiIns;
  137. const uint32_t midiOuts;
  138. const uint32_t parameterIns;
  139. const uint32_t parameterOuts;
  140. const char* const name;
  141. const char* const label;
  142. const char* const maker;
  143. const char* const copyright;
  144. PluginHandle (*instantiate)(const struct _PluginDescriptor* _this_, HostDescriptor* host);
  145. void (*cleanup)(PluginHandle handle);
  146. uint32_t (*get_parameter_count)(PluginHandle handle);
  147. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  148. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  149. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index);
  150. uint32_t (*get_midi_program_count)(PluginHandle handle);
  151. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  152. void (*set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  153. void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  154. void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);
  155. void (*ui_show)(PluginHandle handle, bool show);
  156. void (*ui_idle)(PluginHandle handle);
  157. void (*ui_set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  158. void (*ui_set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  159. void (*ui_set_custom_data)(PluginHandle handle, const char* key, const char* value);
  160. void (*activate)(PluginHandle handle);
  161. void (*deactivate)(PluginHandle handle);
  162. void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
  163. char* (*get_state)(PluginHandle handle);
  164. void (*set_state)(PluginHandle handle, const char* data);
  165. intptr_t (*dispatcher)(PluginHandle handle, int32_t opcode, int32_t index, intptr_t value, void* ptr);
  166. } PluginDescriptor;
  167. // -----------------------------------------------------------------------
  168. // Register plugin
  169. void carla_register_native_plugin(const PluginDescriptor* desc);
  170. // Simple plugins
  171. void carla_register_native_plugin_bypass();
  172. void carla_register_native_plugin_lfo();
  173. void carla_register_native_plugin_midiSequencer();
  174. void carla_register_native_plugin_midiSplit();
  175. void carla_register_native_plugin_midiThrough();
  176. void carla_register_native_plugin_midiTranspose();
  177. void carla_register_native_plugin_nekofilter();
  178. void carla_register_native_plugin_sunvoxfile();
  179. // Carla
  180. void carla_register_native_plugin_carla();
  181. #ifdef WANT_AUDIOFILE
  182. // AudioFile
  183. void carla_register_native_plugin_audiofile();
  184. #endif
  185. #ifdef WANT_MIDIFILE
  186. // MidiFile
  187. void carla_register_native_plugin_midifile();
  188. #endif
  189. #ifdef WANT_OPENGL
  190. // DISTRHO plugins (OpenGL)
  191. void carla_register_native_plugin_3BandEQ();
  192. void carla_register_native_plugin_3BandSplitter();
  193. void carla_register_native_plugin_PingPongPan();
  194. #endif
  195. // DISTRHO plugins (Qt)
  196. void carla_register_native_plugin_Notes();
  197. #ifdef WANT_ZYNADDSUBFX
  198. // ZynAddSubFX
  199. void carla_register_native_plugin_zynaddsubfx();
  200. #endif
  201. // -----------------------------------------------------------------------
  202. /**@}*/
  203. #ifdef __cplusplus
  204. } // extern "C"
  205. #endif
  206. #endif // __CARLA_NATIVE_H__