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.

63 lines
2.2KB

  1. #include "plugin.hpp"
  2. struct Mult : Module {
  3. enum ParamId {
  4. PARAMS_LEN
  5. };
  6. enum InputId {
  7. MULT_INPUT,
  8. INPUTS_LEN
  9. };
  10. enum OutputId {
  11. ENUMS(MULT_OUTPUTS, 8),
  12. OUTPUTS_LEN
  13. };
  14. enum LightId {
  15. LIGHTS_LEN
  16. };
  17. Mult() {
  18. config(PARAMS_LEN, INPUTS_LEN, OUTPUTS_LEN, LIGHTS_LEN);
  19. configInput(MULT_INPUT, "Mult");
  20. for (int i = 0; i < 8; i++)
  21. configOutput(MULT_OUTPUTS + i, string::f("Mult %d", i + 1));
  22. }
  23. void process(const ProcessArgs& args) override {
  24. int channels = std::max(1, inputs[MULT_INPUT].getChannels());
  25. // Copy input to outputs
  26. for (int i = 0; i < 8; i++) {
  27. outputs[MULT_OUTPUTS + i].setChannels(channels);
  28. outputs[MULT_OUTPUTS + i].writeVoltages(inputs[MULT_INPUT].getVoltages());
  29. }
  30. }
  31. };
  32. struct MultWidget : ModuleWidget {
  33. MultWidget(Mult* module) {
  34. setModule(module);
  35. setPanel(createPanel(asset::plugin(pluginInstance, "res/Mult.svg")));
  36. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, 0)));
  37. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, 0)));
  38. addChild(createWidget<ScrewSilver>(Vec(RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  39. addChild(createWidget<ScrewSilver>(Vec(box.size.x - 2 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT - RACK_GRID_WIDTH)));
  40. addInput(createInputCentered<PJ301MPort>(mm2px(Vec(7.62, 22.001)), module, Mult::MULT_INPUT));
  41. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 42.017)), module, Mult::MULT_OUTPUTS + 0));
  42. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 52.155)), module, Mult::MULT_OUTPUTS + 1));
  43. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 62.315)), module, Mult::MULT_OUTPUTS + 2));
  44. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 72.475)), module, Mult::MULT_OUTPUTS + 3));
  45. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 82.635)), module, Mult::MULT_OUTPUTS + 4));
  46. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 92.795)), module, Mult::MULT_OUTPUTS + 5));
  47. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 102.955)), module, Mult::MULT_OUTPUTS + 6));
  48. addOutput(createOutputCentered<PJ301MPort>(mm2px(Vec(7.62, 113.115)), module, Mult::MULT_OUTPUTS + 7));
  49. }
  50. };
  51. Model* modelMult = createModel<Mult, MultWidget>("Mult");