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.

104 lines
2.5KB

  1. //**************************************************************************************
  2. //BitCrusher Module for VCV Rack by Autodafe http://www.autodafe.net
  3. //
  4. //Based on code taken from the Fundamentals plugins by Andrew Belt http://www.vcvrack.com
  5. //And part of code on musicdsp.org: http://musicdsp.org/showArchiveComment.php?ArchiveID=78
  6. //**************************************************************************************
  7. #include "Autodafe.hpp"
  8. #include <stdlib.h>
  9. #include "stk/include/Chorus.h"
  10. using namespace stk;
  11. namespace rack_plugin_Autodafe {
  12. struct ChorusFx : Module{
  13. enum ParamIds {
  14. PARAM_RATE,
  15. PARAM_FEEDBACK,
  16. PARAM_DEPTH,
  17. NUM_PARAMS
  18. };
  19. enum InputIds {
  20. RATE_CV_IN,
  21. DEPTH_CV_IN,
  22. INPUT,
  23. NUM_INPUTS
  24. };
  25. enum OutputIds {
  26. OUT,
  27. NUM_OUTPUTS
  28. };
  29. ChorusFx();
  30. Chorus *cho = new Chorus(1000); // OK
  31. void step();
  32. };
  33. ChorusFx::ChorusFx() {
  34. params.resize(NUM_PARAMS);
  35. inputs.resize(NUM_INPUTS);
  36. outputs.resize(NUM_OUTPUTS);
  37. }
  38. void ChorusFx::step() {
  39. StkFloat rate = params[PARAM_RATE].value;
  40. StkFloat depth = params[PARAM_DEPTH].value;
  41. StkFloat input = inputs[INPUT].value / 5.0;
  42. cho->setModFrequency(rate);
  43. cho->setModDepth (depth);
  44. cho->tick(input,0);
  45. outputs[OUT].value= cho->lastOut(0) * 5;
  46. }
  47. struct ChorusFxWidget : ModuleWidget{
  48. ChorusFxWidget(ChorusFx *module);
  49. };
  50. ChorusFxWidget::ChorusFxWidget(ChorusFx *module) : ModuleWidget(module) {
  51. box.size = Vec(15 * 6, 380);
  52. {
  53. SVGPanel *panel = new SVGPanel();
  54. panel->box.size = box.size;
  55. panel->setBackground(SVG::load(assetPlugin(plugin, "res/Chorus.svg")));
  56. addChild(panel);
  57. }
  58. addChild(createScrew<ScrewSilver>(Vec(1, 0)));
  59. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 20, 0)));
  60. addChild(createScrew<ScrewSilver>(Vec(1, 365)));
  61. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 20, 365)));
  62. addParam(createParam<AutodafeKnobGreenBig>(Vec(20, 60), module, ChorusFx::PARAM_RATE, 0, 1, 0));
  63. addParam(createParam<AutodafeKnobGreen>(Vec(27, 140), module, ChorusFx::PARAM_DEPTH, 0, 1, 0));
  64. addInput(createInput<PJ301MPort>(Vec(10, 320), module, ChorusFx::INPUT));
  65. addOutput(createOutput<PJ301MPort>(Vec(48, 320), module, ChorusFx::OUT));
  66. }
  67. } // namespace rack_plugin_Autodafe
  68. using namespace rack_plugin_Autodafe;
  69. RACK_PLUGIN_MODEL_INIT(Autodafe, ChorusFx) {
  70. return Model::create<ChorusFx, ChorusFxWidget>("Autodafe", "Chorus", "Chorus", EFFECT_TAG);
  71. }