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.

100 lines
2.6KB

  1. //**************************************************************************************
  2. //Reverb 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/NRev.h"
  10. using namespace stk;
  11. namespace rack_plugin_Autodafe {
  12. struct ReverbFx : Module{
  13. enum ParamIds {
  14. PARAM_TIME,
  15. PARAM_DRY_WET,
  16. NUM_PARAMS
  17. };
  18. enum InputIds {
  19. INPUT,
  20. NUM_INPUTS
  21. };
  22. enum OutputIds {
  23. OUT,
  24. NUM_OUTPUTS
  25. };
  26. ReverbFx();
  27. NRev *reverb;
  28. void step();
  29. };
  30. ReverbFx::ReverbFx() {
  31. params.resize(NUM_PARAMS);
  32. inputs.resize(NUM_INPUTS);
  33. outputs.resize(NUM_OUTPUTS);
  34. reverb = new NRev(); // OK
  35. }
  36. void ReverbFx::step() {
  37. StkFloat time = params[PARAM_TIME].value;
  38. StkFloat input = inputs[INPUT].value / 5.0f;
  39. reverb->setT60(time);
  40. reverb->tick(input, 0);
  41. //reverb->tick(input, 1);
  42. outputs[OUT].value= (input + reverb->lastOut(0)*params[PARAM_DRY_WET].value)* 5.0f;
  43. //outputs[OUTR].value= (input +reverb->lastOut(1) *params[PARAM_DRY_WET].value)* 5;
  44. }
  45. struct ReverbFxWidget : ModuleWidget{
  46. ReverbFxWidget(ReverbFx *module);
  47. };
  48. ReverbFxWidget::ReverbFxWidget(ReverbFx *module) : ModuleWidget(module) {
  49. box.size = Vec(15 * 6, 380);
  50. {
  51. SVGPanel *panel = new SVGPanel();
  52. panel->box.size = box.size;
  53. panel->setBackground(SVG::load(assetPlugin(plugin, "res/Reverb.svg")));
  54. addChild(panel);
  55. }
  56. addChild(createScrew<ScrewSilver>(Vec(1, 0)));
  57. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 20.f, 0.f)));
  58. addChild(createScrew<ScrewSilver>(Vec(1, 365)));
  59. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 20.f, 365.f)));
  60. addParam(createParam<AutodafeKnobGreenBig>(Vec(20, 60), module, ReverbFx::PARAM_TIME, 0.01f, 10.0f, 0.01f));
  61. addParam(createParam<AutodafeKnobGreen>(Vec(27, 140), module, ReverbFx::PARAM_DRY_WET, 0, 1, 0));
  62. addInput(createInput<PJ301MPort>(Vec(10, 320), module, ReverbFx::INPUT));
  63. addOutput(createOutput<PJ301MPort>(Vec(48, 320), module, ReverbFx::OUT));
  64. //addOutput(createOutput<PJ301MPort>(Vec(78, 320), module, ReverbFx::OUTR));
  65. }
  66. } // namespace rack_plugin_Autodafe
  67. using namespace rack_plugin_Autodafe;
  68. RACK_PLUGIN_MODEL_INIT(Autodafe, ReverbFx) {
  69. return Model::create<ReverbFx, ReverbFxWidget>("Autodafe", "Reverb", "Reverb", EFFECT_TAG, REVERB_TAG);
  70. }