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.

100 lines
3.0KB

  1. /******************************************************************************
  2. * Copyright 2017-2018 Valerio Orlandini / Sonus Dept. <sonusdept@gmail.com>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *****************************************************************************/
  17. #include "sonusmodular.hpp"
  18. namespace rack_plugin_SonusModular {
  19. struct Twoff : Module
  20. {
  21. enum ParamIds
  22. {
  23. OFF_A,
  24. OFF_B,
  25. NUM_PARAMS
  26. };
  27. enum InputIds
  28. {
  29. IN_A,
  30. IN_B,
  31. NUM_INPUTS
  32. };
  33. enum OutputIds
  34. {
  35. OUT_A,
  36. OUT_B,
  37. NUM_OUTPUTS
  38. };
  39. enum LightIds
  40. {
  41. NUM_LIGHTS
  42. };
  43. Twoff() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
  44. void step() override;
  45. };
  46. void Twoff::step()
  47. {
  48. float in_a = inputs[IN_A].value;
  49. float in_b = inputs[IN_B].value;
  50. outputs[OUT_A].value = in_a + params[OFF_A].value;
  51. outputs[OUT_B].value = in_b + params[OFF_B].value;
  52. }
  53. struct TwoffWidget : ModuleWidget
  54. {
  55. TwoffWidget(Twoff *module);
  56. };
  57. TwoffWidget::TwoffWidget(Twoff *module) : ModuleWidget(module)
  58. {
  59. box.size = Vec(15 * 4, 380);
  60. {
  61. SVGPanel *panel = new SVGPanel();
  62. panel->box.size = box.size;
  63. panel->setBackground(SVG::load(assetPlugin(plugin, "res/twoff.svg")));
  64. addChild(panel);
  65. }
  66. addChild(Widget::create<SonusScrew>(Vec(0, 0)));
  67. addChild(Widget::create<SonusScrew>(Vec(box.size.x - 15, 0)));
  68. addChild(Widget::create<SonusScrew>(Vec(0, 365)));
  69. addChild(Widget::create<SonusScrew>(Vec(box.size.x - 15, 365)));
  70. addInput(Port::create<PJ301MPort>(Vec(18, 67), Port::INPUT, module, Twoff::IN_A));
  71. addInput(Port::create<PJ301MPort>(Vec(18, 202), Port::INPUT, module, Twoff::IN_B));
  72. addOutput(Port::create<PJ301MPort>(Vec(18, 157), Port::OUTPUT, module, Twoff::OUT_A));
  73. addOutput(Port::create<PJ301MPort>(Vec(18, 292), Port::OUTPUT, module, Twoff::OUT_B));
  74. addParam(ParamWidget::create<SonusKnob>(Vec(12, 99), module, Twoff::OFF_A, -5.0, 5.0, 0.0));
  75. addParam(ParamWidget::create<SonusKnob>(Vec(12, 235), module, Twoff::OFF_B, -5.0, 5.0, 0.0));
  76. }
  77. } // namespace rack_plugin_SonusModular
  78. using namespace rack_plugin_SonusModular;
  79. RACK_PLUGIN_MODEL_INIT(SonusModular, Twoff) {
  80. Model *modelTwoff = Model::create<Twoff, TwoffWidget>("Sonus Modular", "Twoff", "Twoff | CV Offset", UTILITY_TAG);
  81. return modelTwoff;
  82. }