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.

136 lines
3.2KB

  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. /** Must be unique. Used for patch files and the VCV store API.
  62. To guarantee uniqueness, it is a good idea to prefix the slug by your "company name" if available, e.g. "MyCompany-MyPlugin"
  63. */
  64. std::string slug;
  65. /** The version of your plugin (optional)
  66. Plugins should follow the versioning scheme described at https://github.com/VCVRack/Rack/issues/266
  67. Do not include the "v" in "v1.0" for example.
  68. */
  69. std::string version;
  70. /** URL for plugin homepage (optional) */
  71. std::string website;
  72. /** URL for plugin manual (optional) */
  73. std::string manual;
  74. virtual ~Plugin();
  75. void addModel(Model *model);
  76. };
  77. struct Model {
  78. Plugin *plugin = NULL;
  79. /** An identifier for the model, e.g. "VCO". Used for saving patches. The slug, manufacturerSlug pair must be unique. */
  80. std::string slug;
  81. /** Human readable name for your model, e.g. "Voltage Controlled Oscillator" */
  82. std::string name;
  83. /** The name of the manufacturer group of the module.
  84. This might be different than the plugin slug. For example, if you create multiple plugins but want them to be branded similarly, you may use the same manufacturer name in multiple plugins.
  85. You may even have multiple manufacturers in one plugin, although this would be unusual.
  86. */
  87. std::string manufacturer;
  88. /** List of tags representing the function(s) of the module (optional) */
  89. std::list<ModelTag> tags;
  90. virtual ~Model() {}
  91. virtual ModuleWidget *createModuleWidget() { return NULL; }
  92. };
  93. void pluginInit();
  94. void pluginDestroy();
  95. void pluginLogIn(std::string email, std::string password);
  96. void pluginLogOut();
  97. void pluginRefresh();
  98. void pluginCancelDownload();
  99. bool pluginIsLoggedIn();
  100. bool pluginIsDownloading();
  101. float pluginGetDownloadProgress();
  102. std::string pluginGetDownloadName();
  103. std::string pluginGetLoginStatus();
  104. extern std::list<Plugin*> gPlugins;
  105. extern std::string gToken;
  106. extern std::string gTagNames[NUM_TAGS];
  107. } // namespace rack
  108. ////////////////////
  109. // Implemented by plugin
  110. ////////////////////
  111. /** Called once to initialize and return the Plugin instance.
  112. You must implement this in your plugin
  113. */
  114. extern "C"
  115. void init(rack::Plugin *plugin);