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.

109 lines
2.2KB

  1. #include "ML_modules.hpp"
  2. namespace rack_plugin_ML_modules {
  3. struct Constants : Module {
  4. enum ParamIds {
  5. NUM_PARAMS
  6. };
  7. enum InputIds {
  8. NUM_INPUTS
  9. };
  10. enum OutputIds {
  11. P_1_OUTPUT,
  12. P_2_OUTPUT,
  13. P_3_OUTPUT,
  14. P_4_OUTPUT,
  15. P_5_OUTPUT,
  16. P_7_OUTPUT,
  17. P_12_OUTPUT,
  18. M_1_OUTPUT,
  19. M_2_OUTPUT,
  20. M_3_OUTPUT,
  21. M_4_OUTPUT,
  22. M_5_OUTPUT,
  23. M_7_OUTPUT,
  24. M_12_OUTPUT,
  25. NUM_OUTPUTS
  26. };
  27. enum LightIds {
  28. NUM_LIGHTS
  29. };
  30. Constants() : Module( NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS ) {};
  31. void step() override;
  32. };
  33. void Constants::step() {
  34. double semi = 1.0/12.0;
  35. outputs[P_1_OUTPUT].value = semi;
  36. outputs[P_2_OUTPUT].value = 2*semi;
  37. outputs[P_3_OUTPUT].value = 3*semi;
  38. outputs[P_4_OUTPUT].value = 4*semi;
  39. outputs[P_5_OUTPUT].value = 5*semi;
  40. outputs[P_7_OUTPUT].value = 7*semi;
  41. outputs[P_12_OUTPUT].value = 1.0;
  42. outputs[M_1_OUTPUT].value = - semi;
  43. outputs[M_2_OUTPUT].value = - 2*semi;
  44. outputs[M_3_OUTPUT].value = - 3*semi;
  45. outputs[M_4_OUTPUT].value = - 4*semi;
  46. outputs[M_5_OUTPUT].value = - 5*semi;
  47. outputs[M_7_OUTPUT].value = - 7*semi;
  48. outputs[M_12_OUTPUT].value = - 1.0;
  49. };
  50. struct ConstantsWidget : ModuleWidget {
  51. ConstantsWidget(Constants *module);
  52. };
  53. ConstantsWidget::ConstantsWidget(Constants *module) : ModuleWidget(module) {
  54. box.size = Vec(15*6, 380);
  55. {
  56. SVGPanel *panel = new SVGPanel();
  57. panel->box.size = box.size;
  58. panel->setBackground(SVG::load(assetPlugin(plugin,"res/Constants.svg")));
  59. addChild(panel);
  60. }
  61. addChild(Widget::create<MLScrew>(Vec(15, 0)));
  62. addChild(Widget::create<MLScrew>(Vec(15, 365)));
  63. const float offset_y = 63, delta_y = 40, offset_xL=10, offset_xR=55;
  64. for(int i=0; i<7; i++) {
  65. addOutput(Port::create<MLPort>(Vec(offset_xR, offset_y + i*delta_y), Port::OUTPUT, module, Constants::P_1_OUTPUT + i));
  66. addOutput(Port::create<MLPort>(Vec(offset_xL, offset_y + i*delta_y), Port::OUTPUT, module, Constants::M_1_OUTPUT + i));
  67. };
  68. }
  69. } // namespace rack_plugin_ML_modules
  70. using namespace rack_plugin_ML_modules;
  71. RACK_PLUGIN_MODEL_INIT(ML_modules, Constants) {
  72. Model *modelConstants = Model::create<Constants, ConstantsWidget>("ML modules", "Constants", "Constants", UTILITY_TAG);
  73. return modelConstants;
  74. }