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.

124 lines
3.6KB

  1. #include "dsp/digital.hpp"
  2. #include "ui.hpp"
  3. #include "alikins.hpp"
  4. namespace rack_plugin_Alikins {
  5. struct Reference : Module {
  6. enum ParamIds {
  7. NUM_PARAMS
  8. };
  9. enum InputIds {
  10. NUM_INPUTS
  11. };
  12. enum OutputIds {
  13. MINUS_TEN_OUTPUT,
  14. MINUS_FIVE_OUTPUT,
  15. MINUS_ONE_OUTPUT,
  16. ZERO_OUTPUT,
  17. PLUS_ONE_OUTPUT,
  18. PLUS_FIVE_OUTPUT,
  19. PLUS_TEN_OUTPUT,
  20. NUM_OUTPUTS
  21. };
  22. enum LightIds {
  23. NUM_LIGHTS
  24. };
  25. Reference() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
  26. void step() override;
  27. void onReset() override {
  28. }
  29. };
  30. void Reference::step() {
  31. outputs[MINUS_TEN_OUTPUT].value = -10.0f;
  32. outputs[MINUS_FIVE_OUTPUT].value = -5.0f;
  33. outputs[MINUS_ONE_OUTPUT].value = -1.0f;
  34. outputs[ZERO_OUTPUT].value = 0.0f;
  35. outputs[PLUS_ONE_OUTPUT].value = 1.0f;
  36. outputs[PLUS_FIVE_OUTPUT].value = 5.0f;
  37. outputs[PLUS_TEN_OUTPUT].value = 10.0f;
  38. }
  39. struct ReferenceWidget : ModuleWidget {
  40. ReferenceWidget(Reference *module);
  41. };
  42. ReferenceWidget::ReferenceWidget(Reference *module) : ModuleWidget(module) {
  43. // box.size = Vec(4 * RACK_GRID_WIDTH, RACK_GRID_HEIGHT);
  44. setPanel(SVG::load(assetPlugin(plugin, "res/Reference.svg")));
  45. float y_pos = 18.0f;
  46. float x_pos = 2.0f;
  47. float y_offset = 50.0f;
  48. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  49. Port::OUTPUT,
  50. module,
  51. Reference::PLUS_TEN_OUTPUT));
  52. y_pos += y_offset;
  53. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  54. Port::OUTPUT,
  55. module,
  56. Reference::PLUS_FIVE_OUTPUT));
  57. y_pos += y_offset;
  58. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  59. Port::OUTPUT,
  60. module,
  61. Reference::PLUS_ONE_OUTPUT));
  62. y_pos += y_offset;
  63. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  64. Port::OUTPUT,
  65. module,
  66. Reference::ZERO_OUTPUT));
  67. y_pos += y_offset;
  68. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  69. Port::OUTPUT,
  70. module,
  71. Reference::MINUS_ONE_OUTPUT));
  72. y_pos += y_offset;
  73. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  74. Port::OUTPUT,
  75. module,
  76. Reference::MINUS_FIVE_OUTPUT));
  77. y_pos += y_offset;
  78. addOutput(Port::create<PJ301MPort>(Vec(x_pos, y_pos),
  79. Port::OUTPUT,
  80. module,
  81. Reference::MINUS_TEN_OUTPUT));
  82. addChild(Widget::create<ScrewSilver>(Vec(0.0f, 0.0f)));
  83. addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15.0f, 0.0f)));
  84. addChild(Widget::create<ScrewSilver>(Vec(0.0f, 365.0f)));
  85. addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15.0f, 365.0f)));
  86. }
  87. } // namespace rack_plugin_Alikins
  88. using namespace rack_plugin_Alikins;
  89. RACK_PLUGIN_MODEL_INIT(Alikins, Reference) {
  90. Model *modelReference = Model::create<Reference, ReferenceWidget>(
  91. "Alikins", "Reference", "Reference Voltages", UTILITY_TAG);
  92. return modelReference;
  93. }