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.

220 lines
6.8KB

  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. uint32_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. } HostDescriptor;
  125. typedef struct _PluginDescriptor {
  126. const PluginCategory category;
  127. const PluginHints hints;
  128. const uint32_t audioIns;
  129. const uint32_t audioOuts;
  130. const uint32_t midiIns;
  131. const uint32_t midiOuts;
  132. const uint32_t parameterIns;
  133. const uint32_t parameterOuts;
  134. const char* const name;
  135. const char* const label;
  136. const char* const maker;
  137. const char* const copyright;
  138. PluginHandle (*instantiate)(const struct _PluginDescriptor* _this_, HostDescriptor* host);
  139. void (*cleanup)(PluginHandle handle);
  140. uint32_t (*get_parameter_count)(PluginHandle handle);
  141. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  142. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  143. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index);
  144. uint32_t (*get_midi_program_count)(PluginHandle handle);
  145. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  146. void (*set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  147. void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  148. void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);
  149. void (*ui_show)(PluginHandle handle, bool show);
  150. void (*ui_idle)(PluginHandle handle);
  151. void (*ui_set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  152. void (*ui_set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  153. void (*ui_set_custom_data)(PluginHandle handle, const char* key, const char* value);
  154. void (*activate)(PluginHandle handle);
  155. void (*deactivate)(PluginHandle handle);
  156. void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
  157. } PluginDescriptor;
  158. // -----------------------------------------------------------------------
  159. // Register plugin
  160. void carla_register_native_plugin(const PluginDescriptor* desc);
  161. // Simple plugins
  162. void carla_register_native_plugin_bypass();
  163. void carla_register_native_plugin_midiSplit();
  164. void carla_register_native_plugin_midiThrough();
  165. // DISTRHO plugins
  166. void carla_register_native_plugin_3BandEQ();
  167. void carla_register_native_plugin_3BandSplitter();
  168. void carla_register_native_plugin_PingPongPan();
  169. #ifdef WANT_ZYNADDSUBFX
  170. // ZynAddSubFX
  171. void carla_register_native_plugin_zynaddsubfx();
  172. #endif
  173. // -----------------------------------------------------------------------
  174. /**@}*/
  175. #ifdef __cplusplus
  176. } // extern "C"
  177. #endif
  178. #endif // __CARLA_NATIVE_H__