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.

92 lines
1.5KB

  1. #include "ML_modules.hpp"
  2. namespace rack_plugin_ML_modules {
  3. struct Sum8 : Module {
  4. enum ParamIds {
  5. NUM_PARAMS
  6. };
  7. enum InputIds {
  8. IN1_INPUT,
  9. IN2_INPUT,
  10. IN3_INPUT,
  11. IN4_INPUT,
  12. IN5_INPUT,
  13. IN6_INPUT,
  14. IN7_INPUT,
  15. IN8_INPUT,
  16. NUM_INPUTS
  17. };
  18. enum OutputIds {
  19. OUT_OUTPUT,
  20. NUM_OUTPUTS
  21. };
  22. enum LightIds {
  23. NUM_LIGHTS
  24. };
  25. Sum8() : Module( NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS ) {};
  26. void step() override;
  27. };
  28. void Sum8::step() {
  29. float out=0.0;
  30. for(int i=0; i<8; i++) out += inputs[IN1_INPUT+i].normalize(0.0);
  31. outputs[OUT_OUTPUT].value = out;
  32. };
  33. struct Sum8Widget : ModuleWidget {
  34. Sum8Widget(Sum8 *module);
  35. };
  36. Sum8Widget::Sum8Widget(Sum8 *module) : ModuleWidget(module) {
  37. box.size = Vec(15*3, 380);
  38. {
  39. SVGPanel *panel = new SVGPanel();
  40. panel->box.size = box.size;
  41. panel->setBackground(SVG::load(assetPlugin(plugin,"res/Sum8.svg")));
  42. addChild(panel);
  43. }
  44. addChild(Widget::create<MLScrew>(Vec(15, 0)));
  45. addChild(Widget::create<MLScrew>(Vec(15, 365)));
  46. const float offset_y = 70, delta_y = 26.5, offset_x=9.5;
  47. for( int i=0; i<8; i++) addInput(Port::create<MLPort>(Vec(offset_x, offset_y + i*delta_y ), Port::INPUT, module, Sum8::IN1_INPUT+i));
  48. addOutput(Port::create<MLPort>(Vec(offset_x, 320), Port::OUTPUT, module, Sum8::OUT_OUTPUT));
  49. }
  50. } // namespace rack_plugin_ML_modules
  51. using namespace rack_plugin_ML_modules;
  52. RACK_PLUGIN_MODEL_INIT(ML_modules, Sum8) {
  53. Model *modelSum8 = Model::create<Sum8, Sum8Widget>("ML modules", "Sum8", "Sum8", UTILITY_TAG, MIXER_TAG);
  54. return modelSum8;
  55. }