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.

193 lines
5.7KB

  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. int32_t bar;
  93. int32_t beat;
  94. int32_t tick;
  95. double bar_start_tick;
  96. float beats_per_bar;
  97. float beat_type;
  98. double ticks_per_beat;
  99. double beats_per_minute;
  100. } TimeInfoBBT;
  101. typedef struct _TimeInfo {
  102. bool playing;
  103. uint32_t frame;
  104. uint32_t time;
  105. uint32_t valid;
  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. } HostDescriptor;
  115. typedef struct _PluginDescriptor {
  116. PluginCategory category;
  117. uint32_t hints;
  118. uint32_t audioIns;
  119. uint32_t audioOuts;
  120. uint32_t midiIns;
  121. uint32_t midiOuts;
  122. uint32_t parameterIns;
  123. uint32_t parameterOuts;
  124. const char* name;
  125. const char* label;
  126. const char* maker;
  127. const char* copyright;
  128. PluginHandle (*instantiate)(struct _PluginDescriptor* _this_, HostDescriptor* host);
  129. uint32_t (*get_parameter_count)(PluginHandle handle);
  130. const Parameter* (*get_parameter_info)(PluginHandle handle, uint32_t index);
  131. float (*get_parameter_value)(PluginHandle handle, uint32_t index);
  132. const char* (*get_parameter_text)(PluginHandle handle, uint32_t index);
  133. uint32_t (*get_midi_program_count)(PluginHandle handle);
  134. const MidiProgram* (*get_midi_program_info)(PluginHandle handle, uint32_t index);
  135. void (*set_parameter_value)(PluginHandle handle, uint32_t index, float value);
  136. void (*set_midi_program)(PluginHandle handle, uint32_t bank, uint32_t program);
  137. void (*set_custom_data)(PluginHandle handle, const char* key, const char* value);
  138. void (*show_gui)(PluginHandle handle, bool show);
  139. void (*idle_gui)(PluginHandle handle);
  140. void (*activate)(PluginHandle handle);
  141. void (*deactivate)(PluginHandle handle);
  142. void (*cleanup)(PluginHandle handle);
  143. void (*process)(PluginHandle handle, float** inBuffer, float** outBuffer, uint32_t frames, uint32_t midiEventCount, MidiEvent* midiEvents);
  144. } PluginDescriptor;
  145. // -----------------------------------------------------------------------
  146. // Register plugin
  147. void carla_register_native_plugin(const PluginDescriptor* desc);
  148. // Available plugins
  149. void carla_register_native_plugin_bypass();
  150. void carla_register_native_plugin_midiSplit();
  151. #ifdef WANT_ZYNADDSUBFX
  152. void carla_register_native_plugin_zynaddsubfx();
  153. #endif
  154. // -----------------------------------------------------------------------
  155. /**@}*/
  156. #ifdef __cplusplus
  157. } /* extern "C" */
  158. #endif
  159. #endif // CARLA_NATIVE_H