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.

221 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 <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. } PluginHints;
  54. typedef enum _ParameterHints {
  55. PARAMETER_IS_OUTPUT = 1 << 0,
  56. PARAMETER_IS_ENABLED = 1 << 1,
  57. PARAMETER_IS_AUTOMABLE = 1 << 2,
  58. PARAMETER_IS_BOOLEAN = 1 << 3,
  59. PARAMETER_IS_INTEGER = 1 << 4,
  60. PARAMETER_IS_LOGARITHMIC = 1 << 5,
  61. PARAMETER_USES_SAMPLE_RATE = 1 << 6,
  62. PARAMETER_USES_SCALEPOINTS = 1 << 7,
  63. PARAMETER_USES_CUSTOM_TEXT = 1 << 8
  64. } ParameterHints;
  65. typedef struct _ParameterScalePoint {
  66. const char* label;
  67. float value;
  68. } ParameterScalePoint;
  69. typedef struct _ParameterRanges {
  70. float def;
  71. float min;
  72. float max;
  73. float step;
  74. float stepSmall;
  75. float stepLarge;
  76. } ParameterRanges;
  77. #define PARAMETER_RANGES_DEFAULT_STEP 0.01f
  78. #define PARAMETER_RANGES_DEFAULT_STEP_SMALL 0.0001f
  79. #define PARAMETER_RANGES_DEFAULT_STEP_LARGE 0.1f
  80. typedef struct _Parameter {
  81. ParameterHints hints;
  82. const char* name;
  83. const char* unit;
  84. ParameterRanges ranges;
  85. uint32_t scalePointCount;
  86. ParameterScalePoint* scalePoints;
  87. } Parameter;
  88. typedef struct _MidiEvent {
  89. uint32_t port;
  90. uint32_t time;
  91. uint8_t data[3];
  92. } MidiEvent;
  93. typedef struct _MidiProgram {
  94. uint32_t bank;
  95. uint32_t program;
  96. const char* name;
  97. } MidiProgram;
  98. typedef struct _TimeInfoBBT {
  99. bool valid;
  100. int32_t bar; //!< current bar
  101. int32_t beat; //!< current beat-within-bar
  102. int32_t tick; //!< current tick-within-beat
  103. double barStartTick;
  104. float beatsPerBar; //!< time signature "numerator"
  105. float beatType; //!< time signature "denominator"
  106. double ticksPerBeat;
  107. double beatsPerMinute;
  108. } TimeInfoBBT;
  109. typedef struct _TimeInfo {
  110. bool playing;
  111. uint32_t frame;
  112. uint32_t time;
  113. TimeInfoBBT bbt;
  114. } TimeInfo;
  115. typedef struct _HostDescriptor {
  116. HostHandle handle;
  117. uint32_t (*get_buffer_size)(HostHandle handle);
  118. double (*get_sample_rate)(HostHandle handle);
  119. const TimeInfo* (*get_time_info)(HostHandle handle);
  120. bool (*write_midi_event)(HostHandle handle, const MidiEvent* event);
  121. void (*ui_parameter_changed)(HostHandle handle, uint32_t index, float value);
  122. void (*ui_midi_program_changed)(HostHandle handle, uint32_t bank, uint32_t program);
  123. void (*ui_custom_data_changed)(HostHandle handle, const char* key, const char* value);
  124. void (*ui_closed)(HostHandle handle);
  125. } HostDescriptor;
  126. typedef struct _PluginDescriptor {
  127. const PluginCategory category;
  128. const PluginHints hints;
  129. const uint32_t audioIns;
  130. const uint32_t audioOuts;
  131. const uint32_t midiIns;
  132. const uint32_t midiOuts;
  133. const uint32_t parameterIns;
  134. const uint32_t parameterOuts;
  135. const char* const name;
  136. const char* const label;
  137. const char* const maker;
  138. const char* const copyright;
  139. PluginHandle (*instantiate)(const struct _PluginDescriptor* _this_, HostDescriptor* host);
  140. void (*cleanup)(PluginHandle handle);
  141. uint32_t (*get_parameter_count)(PluginHandle handle);
  142. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  143. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  144. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index);
  145. uint32_t (*get_midi_program_count)(PluginHandle handle);
  146. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  147. void (*set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  148. void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  149. void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);
  150. void (*ui_show)(PluginHandle handle, bool show);
  151. void (*ui_idle)(PluginHandle handle);
  152. void (*ui_set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  153. void (*ui_set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  154. void (*ui_set_custom_data)(PluginHandle handle, const char* key, const char* value);
  155. void (*activate)(PluginHandle handle);
  156. void (*deactivate)(PluginHandle handle);
  157. void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, const MidiEvent* midiEvents);
  158. } PluginDescriptor;
  159. // -----------------------------------------------------------------------
  160. // Register plugin
  161. void carla_register_native_plugin(const PluginDescriptor* desc);
  162. // Simple plugins
  163. void carla_register_native_plugin_bypass();
  164. void carla_register_native_plugin_midiSplit();
  165. void carla_register_native_plugin_midiThrough();
  166. // DISTRHO plugins
  167. void carla_register_native_plugin_3BandEQ();
  168. void carla_register_native_plugin_3BandSplitter();
  169. void carla_register_native_plugin_PingPongPan();
  170. #ifdef WANT_ZYNADDSUBFX
  171. // ZynAddSubFX
  172. void carla_register_native_plugin_zynaddsubfx();
  173. #endif
  174. // -----------------------------------------------------------------------
  175. /**@}*/
  176. #ifdef __cplusplus
  177. } // extern "C"
  178. #endif
  179. #endif // __CARLA_NATIVE_H__