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.

248 lines
7.7KB

  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_CHUNKS = 1 << 3,
  53. PLUGIN_USES_SINGLE_THREAD = 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 time;
  115. TimeInfoBBT bbt;
  116. } TimeInfo;
  117. typedef struct _HostDescriptor {
  118. HostHandle handle;
  119. uint32_t (*get_buffer_size)(HostHandle handle);
  120. double (*get_sample_rate)(HostHandle handle);
  121. const TimeInfo* (*get_time_info)(HostHandle handle);
  122. bool (*write_midi_event)(HostHandle handle, const MidiEvent* event);
  123. void (*ui_parameter_changed)(HostHandle handle, uint32_t index, float value);
  124. void (*ui_midi_program_changed)(HostHandle handle, uint32_t bank, uint32_t program);
  125. void (*ui_custom_data_changed)(HostHandle handle, const char* key, const char* value);
  126. void (*ui_closed)(HostHandle handle);
  127. const char* (*ui_open_file)(HostHandle handle, bool isDir, const char* title, const char* filter);
  128. const char* (*ui_save_file)(HostHandle handle, bool isDir, const char* title, const char* filter);
  129. } HostDescriptor;
  130. typedef struct _PluginDescriptor {
  131. const PluginCategory category;
  132. const PluginHints hints;
  133. const uint32_t audioIns;
  134. const uint32_t audioOuts;
  135. const uint32_t midiIns;
  136. const uint32_t midiOuts;
  137. const uint32_t parameterIns;
  138. const uint32_t parameterOuts;
  139. const char* const name;
  140. const char* const label;
  141. const char* const maker;
  142. const char* const copyright;
  143. PluginHandle (*instantiate)(const struct _PluginDescriptor* _this_, HostDescriptor* host);
  144. void (*cleanup)(PluginHandle handle);
  145. uint32_t (*get_parameter_count)(PluginHandle handle);
  146. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  147. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  148. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index);
  149. uint32_t (*get_midi_program_count)(PluginHandle handle);
  150. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  151. void (*set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  152. void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  153. void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);
  154. void (*ui_show)(PluginHandle handle, bool show);
  155. void (*ui_idle)(PluginHandle handle);
  156. void (*ui_set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  157. void (*ui_set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  158. void (*ui_set_custom_data)(PluginHandle handle, const char* key, const char* value);
  159. void (*activate)(PluginHandle handle);
  160. void (*deactivate)(PluginHandle handle);
  161. void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
  162. size_t (*get_chunk)(PluginHandle handle, void** data);
  163. void (*set_chunk)(PluginHandle handle, void* data, size_t size);
  164. } PluginDescriptor;
  165. // -----------------------------------------------------------------------
  166. // Register plugin
  167. void carla_register_native_plugin(const PluginDescriptor* desc);
  168. // Simple plugins
  169. void carla_register_native_plugin_bypass();
  170. void carla_register_native_plugin_lfo();
  171. void carla_register_native_plugin_midiSequencer();
  172. void carla_register_native_plugin_midiSplit();
  173. void carla_register_native_plugin_midiThrough();
  174. void carla_register_native_plugin_midiTranspose();
  175. void carla_register_native_plugin_nekofilter();
  176. #ifdef WANT_AUDIOFILE
  177. // AudioFile
  178. void carla_register_native_plugin_audiofile();
  179. #endif
  180. #ifdef WANT_MIDIFILE
  181. // MidiFile
  182. void carla_register_native_plugin_midiFile();
  183. #endif
  184. #ifdef WANT_OPENGL
  185. // DISTRHO plugins (OpenGL)
  186. void carla_register_native_plugin_3BandEQ();
  187. void carla_register_native_plugin_3BandSplitter();
  188. void carla_register_native_plugin_PingPongPan();
  189. #endif
  190. // DISTRHO plugins (Qt)
  191. void carla_register_native_plugin_Notes();
  192. #ifdef WANT_ZYNADDSUBFX
  193. // ZynAddSubFX
  194. void carla_register_native_plugin_zynaddsubfx();
  195. #endif
  196. // -----------------------------------------------------------------------
  197. /**@}*/
  198. #ifdef __cplusplus
  199. } // extern "C"
  200. #endif
  201. #endif // __CARLA_NATIVE_H__