Collection of tools useful for audio production
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.

209 lines
6.5KB

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