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.

128 lines
2.7KB

  1. #pragma once
  2. #include <string>
  3. #include <list>
  4. namespace rack {
  5. enum ModelTag {
  6. AMPLIFIER_TAG,
  7. ATTENUATOR_TAG,
  8. BLANK_TAG,
  9. CLOCK_TAG,
  10. CONTROLLER_TAG,
  11. DELAY_TAG,
  12. DIGITAL_TAG,
  13. DISTORTION_TAG,
  14. DRUM_TAG,
  15. DUAL_TAG,
  16. DYNAMICS_TAG,
  17. EFFECT_TAG,
  18. ENVELOPE_FOLLOWER_TAG,
  19. ENVELOPE_GENERATOR_TAG,
  20. EQUALIZER_TAG,
  21. EXTERNAL_TAG,
  22. FILTER_TAG,
  23. FUNCTION_GENERATOR_TAG,
  24. GRANULAR_TAG,
  25. LFO_TAG,
  26. LOGIC_TAG,
  27. LOW_PASS_GATE_TAG,
  28. MIDI_TAG,
  29. MIXER_TAG,
  30. MULTIPLE_TAG,
  31. NOISE_TAG,
  32. OSCILLATOR_TAG,
  33. PANNING_TAG,
  34. QUAD_TAG,
  35. QUANTIZER_TAG,
  36. RANDOM_TAG,
  37. REVERB_TAG,
  38. RING_MODULATOR_TAG,
  39. SAMPLE_AND_HOLD_TAG,
  40. SAMPLER_TAG,
  41. SEQUENCER_TAG,
  42. SLEW_LIMITER_TAG,
  43. SWITCH_TAG,
  44. SYNTH_VOICE_TAG,
  45. TUNER_TAG,
  46. UTILITY_TAG,
  47. VISUAL_TAG,
  48. WAVESHAPER_TAG,
  49. NUM_TAGS
  50. };
  51. struct ModuleWidget;
  52. struct Model;
  53. // Subclass this and return a pointer to a new one when init() is called
  54. struct Plugin {
  55. /** A list of the models available by this plugin, add with addModel() */
  56. std::list<Model*> models;
  57. /** The file path of the plugin's directory */
  58. std::string path;
  59. /** OS-dependent library handle */
  60. void *handle = NULL;
  61. /** Used when syncing plugins with the API */
  62. std::string slug;
  63. /** The version of your plugin
  64. Plugins should follow the versioning scheme described at https://github.com/VCVRack/Rack/issues/266
  65. Do not include the "v" in "v1.0" for example.
  66. */
  67. std::string version;
  68. virtual ~Plugin();
  69. void addModel(Model *model);
  70. };
  71. struct Model {
  72. Plugin *plugin = NULL;
  73. /** An identifier for the model, e.g. "VCO". Used for saving patches. The slug, manufacturerSlug pair must be unique. */
  74. std::string slug;
  75. /** Human readable name for your model, e.g. "Voltage Controlled Oscillator" */
  76. std::string name;
  77. /** An identifier for the manufacturer, e.g. "foo". Used for saving patches. */
  78. std::string manufacturerSlug;
  79. /** Human readable name for the manufacturer, e.g. "Foo Modular" */
  80. std::string manufacturerName;
  81. /** List of tags representing the function(s) of the module */
  82. std::list<ModelTag> tags;
  83. virtual ~Model() {}
  84. virtual ModuleWidget *createModuleWidget() { return NULL; }
  85. };
  86. void pluginInit();
  87. void pluginDestroy();
  88. void pluginLogIn(std::string email, std::string password);
  89. void pluginLogOut();
  90. void pluginRefresh();
  91. void pluginCancelDownload();
  92. bool pluginIsLoggedIn();
  93. bool pluginIsDownloading();
  94. float pluginGetDownloadProgress();
  95. std::string pluginGetDownloadName();
  96. std::string pluginGetLoginStatus();
  97. extern std::list<Plugin*> gPlugins;
  98. extern std::string gToken;
  99. extern std::string gTagNames[NUM_TAGS];
  100. } // namespace rack
  101. ////////////////////
  102. // Implemented by plugin
  103. ////////////////////
  104. /** Called once to initialize and return the Plugin instance.
  105. You must implement this in your plugin
  106. */
  107. extern "C"
  108. void init(rack::Plugin *plugin);