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.

55 lines
1.7KB

  1. #include "common.hpp"
  2. #include "attenuator.hpp"
  3. namespace rack_plugin_TheXOR {
  4. void Attenuator::step()
  5. {
  6. for(int k = 0; k < NUM_ATTENUATORS; k++)
  7. {
  8. if(outputs[OUT_1 + k].active)
  9. outputs[OUT_1 + k].value = inputs[IN_1 + k].value * params[ATT_1 + k].value;
  10. }
  11. }
  12. AttenuatorWidget::AttenuatorWidget(Attenuator *module) : ModuleWidget(module)
  13. {
  14. box.size = Vec(8 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  15. {
  16. SVGPanel *panel = new SVGPanel();
  17. panel->box.size = box.size;
  18. panel->setBackground(SVG::load(assetPlugin(plugin, "res/modules/attenuator.svg")));
  19. addChild(panel);
  20. }
  21. addChild(Widget::create<ScrewBlack>(Vec(RACK_GRID_WIDTH, 0)));
  22. addChild(Widget::create<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
  23. addChild(Widget::create<ScrewBlack>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  24. addChild(Widget::create<ScrewBlack>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  25. float in_x = mm2px(2.490);
  26. float pot_x = mm2px(16.320);
  27. float out_x = mm2px(29.894);
  28. float y = yncscape(107.460, 8.255);
  29. float ypot = yncscape(107.588, 8.0);
  30. float delta_y = mm2px(19.0);
  31. for(int k = 0; k < NUM_ATTENUATORS; k++)
  32. {
  33. addInput(Port::create<PJ301GRPort>(Vec(in_x, y), Port::INPUT, module, Attenuator::IN_1 + k));
  34. addParam(ParamWidget::create<Davies1900hFixWhiteKnobSmall>(Vec(pot_x, ypot), module, Attenuator::ATT_1+k, 0.0, 1.0, 1.0));
  35. addOutput(Port::create<PJ301GPort>(Vec(out_x, y), Port::OUTPUT, module, Attenuator::OUT_1+k));
  36. y += delta_y;
  37. ypot += delta_y;
  38. }
  39. }
  40. } // namespace rack_plugin_TheXOR
  41. using namespace rack_plugin_TheXOR;
  42. RACK_PLUGIN_MODEL_INIT(TheXOR, Attenuator) {
  43. return Model::create<Attenuator, AttenuatorWidget>("TheXOR", "Attenuator", "Attenuator", ATTENUATOR_TAG);
  44. }