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.

94 lines
2.4KB

  1. /*
  2. Vamps
  3. a 2 RackUnit stereo mod of Andrew Belt's Fundamental VCA
  4. MAYBE TODO:
  5. - third channel
  6. */////////////////////////////////////////////////////////////////////////////
  7. #include "pvc.hpp"
  8. namespace rack_plugin_PvC {
  9. struct Vamps : Module {
  10. enum ParamIds {
  11. LEVEL,
  12. NUM_PARAMS
  13. };
  14. enum InputIds {
  15. EXP_CV,
  16. LIN_CV,
  17. IN_L,
  18. IN_R,
  19. NUM_INPUTS
  20. };
  21. enum OutputIds {
  22. OUT_L,
  23. OUT_R,
  24. NUM_OUTPUTS
  25. };
  26. Vamps() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS) {}
  27. void step() override;
  28. };
  29. void Vamps::step() {
  30. float left = inputs[IN_L].value * params[LEVEL].value;
  31. float right = inputs[IN_R].normalize(inputs[IN_L].value) * params[LEVEL].value;
  32. const float expBase = 50.0f;
  33. if (inputs[LIN_CV].active) {
  34. float linCV = clamp(inputs[LIN_CV].value * 0.1f, 0.0f, 1.0f);
  35. left *= linCV;
  36. right *= linCV;
  37. }
  38. if (inputs[EXP_CV].active) {
  39. float expCV = rescale(powf(expBase, clamp(inputs[EXP_CV].value / 10.0f, 0.0f, 1.0f)), 1.0, expBase, 0.0f, 1.0f);
  40. left *= expCV;
  41. right *= expCV;
  42. }
  43. outputs[OUT_L].value = left;
  44. outputs[OUT_R].value = right;
  45. }
  46. struct VampsWidget : ModuleWidget { VampsWidget(Vamps *module); };
  47. VampsWidget::VampsWidget(Vamps *module) : ModuleWidget(module) {
  48. setPanel(SVG::load(assetPlugin(plugin, "res/panels/Vamps.svg")));
  49. // screws
  50. addChild(Widget::create<ScrewHead1>(Vec(0, 0)));
  51. //addChild(Widget::create<ScrewHead2>(Vec(box.size.x - 15, 0)));
  52. //addChild(Widget::create<ScrewHead3>(Vec(0, 365)));
  53. addChild(Widget::create<ScrewHead4>(Vec(box.size.x - 15, 365)));
  54. addInput(Port::create<InPortAud>(Vec(4, 22), Port::INPUT, module, Vamps::IN_L));
  55. addInput(Port::create<InPortAud>(Vec(4, 64), Port::INPUT, module, Vamps::IN_R));
  56. addParam(ParamWidget::create<PvCKnob>(Vec(4, 120), module, Vamps::LEVEL, 0.0f, 1.0f, 0.5f));
  57. addInput(Port::create<InPortCtrl>(Vec(4, 164), Port::INPUT, module, Vamps::EXP_CV));
  58. addInput(Port::create<InPortCtrl>(Vec(4, 208), Port::INPUT, module, Vamps::LIN_CV));
  59. addOutput(Port::create<OutPortVal>(Vec(4, 296), Port::OUTPUT, module, Vamps::OUT_L));
  60. addOutput(Port::create<OutPortVal>(Vec(4, 336), Port::OUTPUT, module, Vamps::OUT_R));
  61. }
  62. } // namespace rack_plugin_PvC
  63. using namespace rack_plugin_PvC;
  64. RACK_PLUGIN_MODEL_INIT(PvC, Vamps) {
  65. Model *modelVamps = Model::create<Vamps, VampsWidget>(
  66. "PvC", "Vamps", "Vamps", AMPLIFIER_TAG, ATTENUATOR_TAG, DUAL_TAG);
  67. return modelVamps;
  68. }