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.

105 lines
3.2KB

  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 Piconoise : Module
  20. {
  21. enum ParamIds
  22. {
  23. NUM_PARAMS
  24. };
  25. enum InputIds
  26. {
  27. NUM_INPUTS
  28. };
  29. enum OutputIds
  30. {
  31. A1_OUTPUT,
  32. A2_OUTPUT,
  33. A3_OUTPUT,
  34. A4_OUTPUT,
  35. A5_OUTPUT,
  36. A6_OUTPUT,
  37. NUM_OUTPUTS
  38. };
  39. enum LightIds
  40. {
  41. NUM_LIGHTS
  42. };
  43. Piconoise() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
  44. {
  45. srand(time(0));
  46. }
  47. void step() override;
  48. };
  49. void Piconoise::step()
  50. {
  51. float out = (2.0 * (rand() / (float)RAND_MAX)) - 1.0;
  52. outputs[A1_OUTPUT].value = 5.0 * out;
  53. outputs[A2_OUTPUT].value = 5.0 * out;
  54. outputs[A3_OUTPUT].value = 5.0 * out;
  55. outputs[A4_OUTPUT].value = 5.0 * out;
  56. outputs[A5_OUTPUT].value = 5.0 * out;
  57. outputs[A6_OUTPUT].value = 5.0 * out;
  58. }
  59. struct PiconoiseWidget : ModuleWidget
  60. {
  61. PiconoiseWidget(Piconoise *module);
  62. };
  63. PiconoiseWidget::PiconoiseWidget(Piconoise *module) : ModuleWidget(module)
  64. {
  65. box.size = Vec(15 * 4, 380);
  66. {
  67. SVGPanel *panel = new SVGPanel();
  68. panel->box.size = box.size;
  69. panel->setBackground(SVG::load(assetPlugin(plugin, "res/piconoise.svg")));
  70. addChild(panel);
  71. }
  72. addChild(Widget::create<SonusScrew>(Vec(0, 0)));
  73. addChild(Widget::create<SonusScrew>(Vec(box.size.x - 15, 0)));
  74. addChild(Widget::create<SonusScrew>(Vec(0, 365)));
  75. addChild(Widget::create<SonusScrew>(Vec(box.size.x - 15, 365)));
  76. addOutput(Port::create<PJ301MPort>(Vec(18, 67), Port::OUTPUT, module, Piconoise::A1_OUTPUT));
  77. addOutput(Port::create<PJ301MPort>(Vec(18, 112), Port::OUTPUT, module, Piconoise::A2_OUTPUT));
  78. addOutput(Port::create<PJ301MPort>(Vec(18, 157), Port::OUTPUT, module, Piconoise::A3_OUTPUT));
  79. addOutput(Port::create<PJ301MPort>(Vec(18, 202), Port::OUTPUT, module, Piconoise::A4_OUTPUT));
  80. addOutput(Port::create<PJ301MPort>(Vec(18, 247), Port::OUTPUT, module, Piconoise::A5_OUTPUT));
  81. addOutput(Port::create<PJ301MPort>(Vec(18, 292), Port::OUTPUT, module, Piconoise::A6_OUTPUT));
  82. }
  83. } // namespace rack_plugin_SonusModular
  84. using namespace rack_plugin_SonusModular;
  85. RACK_PLUGIN_MODEL_INIT(SonusModular, Piconoise) {
  86. Model *modelPiconoise = Model::create<Piconoise, PiconoiseWidget>("Sonus Modular", "Piconoise", "Piconoise | Noise Generator", NOISE_TAG);
  87. return modelPiconoise;
  88. }