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.

85 lines
3.6KB

  1. #include "Fundamental.hpp"
  2. struct _8VERT : Module {
  3. enum ParamIds {
  4. NUM_PARAMS = 8
  5. };
  6. enum InputIds {
  7. NUM_INPUTS = 8
  8. };
  9. enum OutputIds {
  10. NUM_OUTPUTS = 8
  11. };
  12. enum LightIds {
  13. NUM_LIGHTS = 16
  14. };
  15. _8VERT() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
  16. void step() override;
  17. };
  18. void _8VERT::step() {
  19. float lastIn = 10.0;
  20. for (int i = 0; i < 8; i++) {
  21. lastIn = inputs[i].normalize(lastIn);
  22. float out = lastIn * params[i].value;
  23. outputs[i].value = out;
  24. lights[2*i + 0].setBrightnessSmooth(fmaxf(0.0, out / 5.0));
  25. lights[2*i + 1].setBrightnessSmooth(fmaxf(0.0, -out / 5.0));
  26. }
  27. }
  28. _8VERTWidget::_8VERTWidget() {
  29. _8VERT *module = new _8VERT();
  30. setModule(module);
  31. box.size = Vec(8 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  32. SVGPanel *panel = new SVGPanel();
  33. panel->box.size = box.size;
  34. panel->setBackground(SVG::load(assetPlugin(plugin, "res/8VERT.svg")));
  35. addChild(panel);
  36. addChild(createScrew<ScrewSilver>(Vec(15, 0)));
  37. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 30, 0)));
  38. addChild(createScrew<ScrewSilver>(Vec(15, 365)));
  39. addChild(createScrew<ScrewSilver>(Vec(box.size.x - 30, 365)));
  40. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 47.753), module, 0, -1.0, 1.0, 0.0));
  41. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 86.198), module, 1, -1.0, 1.0, 0.0));
  42. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 124.639), module, 2, -1.0, 1.0, 0.0));
  43. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 163.084), module, 3, -1.0, 1.0, 0.0));
  44. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 201.529), module, 4, -1.0, 1.0, 0.0));
  45. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 239.974), module, 5, -1.0, 1.0, 0.0));
  46. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 278.415), module, 6, -1.0, 1.0, 0.0));
  47. addParam(createParam<RoundSmallBlackKnob>(Vec(45.308, 316.86), module, 7, -1.0, 1.0, 0.0));
  48. addInput(createInput<PJ301MPort>(Vec(9.507, 50.397), module, 0));
  49. addInput(createInput<PJ301MPort>(Vec(9.507, 88.842), module, 1));
  50. addInput(createInput<PJ301MPort>(Vec(9.507, 127.283), module, 2));
  51. addInput(createInput<PJ301MPort>(Vec(9.507, 165.728), module, 3));
  52. addInput(createInput<PJ301MPort>(Vec(9.507, 204.173), module, 4));
  53. addInput(createInput<PJ301MPort>(Vec(9.507, 242.614), module, 5));
  54. addInput(createInput<PJ301MPort>(Vec(9.507, 281.059), module, 6));
  55. addInput(createInput<PJ301MPort>(Vec(9.507, 319.504), module, 7));
  56. addOutput(createOutput<PJ301MPort>(Vec(86.393, 50.397), module, 0));
  57. addOutput(createOutput<PJ301MPort>(Vec(86.393, 88.842), module, 1));
  58. addOutput(createOutput<PJ301MPort>(Vec(86.393, 127.283), module, 2));
  59. addOutput(createOutput<PJ301MPort>(Vec(86.393, 165.728), module, 3));
  60. addOutput(createOutput<PJ301MPort>(Vec(86.393, 204.173), module, 4));
  61. addOutput(createOutput<PJ301MPort>(Vec(86.393, 242.614), module, 5));
  62. addOutput(createOutput<PJ301MPort>(Vec(86.393, 281.059), module, 6));
  63. addOutput(createOutput<PJ301MPort>(Vec(86.393, 319.504), module, 7));
  64. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 50.414), module, 0));
  65. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 88.859), module, 2));
  66. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 127.304), module, 4));
  67. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 165.745), module, 6));
  68. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 204.19), module, 8));
  69. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 242.635), module, 10));
  70. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 281.076), module, 12));
  71. addChild(createLight<TinyLight<GreenRedLight>>(Vec(107.702, 319.521), module, 14));
  72. }