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.

231 lines
7.2KB

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