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.

61 lines
1.6KB

  1. #include "dsp/digital.hpp"
  2. #include "qwelk.hpp"
  3. #define CHANNELS 8
  4. namespace rack_plugin_Qwelk {
  5. struct ModuleNot : Module {
  6. enum ParamIds {
  7. NUM_PARAMS
  8. };
  9. enum InputIds {
  10. INPUT_SIG,
  11. NUM_INPUTS = INPUT_SIG + CHANNELS
  12. };
  13. enum OutputIds {
  14. OUTPUT_NOT,
  15. NUM_OUTPUTS = OUTPUT_NOT + CHANNELS
  16. };
  17. enum LightIds {
  18. NUM_LIGHTS
  19. };
  20. ModuleNot() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {}
  21. void step() override;
  22. };
  23. void ModuleNot::step() {
  24. for (int i = 0; i < CHANNELS; ++i) {
  25. outputs[OUTPUT_NOT + i].value = inputs[INPUT_SIG + i].value != 0.0 ? 0.0 : 10.0;
  26. }
  27. }
  28. struct WidgetNot : ModuleWidget {
  29. WidgetNot(ModuleNot *module);
  30. };
  31. WidgetNot::WidgetNot(ModuleNot *module) : ModuleWidget(module) {
  32. setPanel(SVG::load(assetPlugin(plugin, "res/Not.svg")));
  33. addChild(Widget::create<ScrewSilver>(Vec(15, 0)));
  34. addChild(Widget::create<ScrewSilver>(Vec(15, 365)));
  35. float x = box.size.x / 2.0 - 25, ytop = 45, ystep = 39;
  36. for (int i = 0; i < CHANNELS; ++i) {
  37. addInput(Port::create<PJ301MPort>( Vec(x , ytop + ystep * i), Port::INPUT, module, ModuleNot::INPUT_SIG + i));
  38. addOutput(Port::create<PJ301MPort>( Vec(x + 26 , ytop + ystep * i), Port::OUTPUT, module, ModuleNot::OUTPUT_NOT + i));
  39. }
  40. }
  41. } // namespace rack_plugin_Qwelk
  42. using namespace rack_plugin_Qwelk;
  43. RACK_PLUGIN_MODEL_INIT(Qwelk, Not) {
  44. Model *modelNot = Model::create<ModuleNot, WidgetNot>(
  45. TOSTRING(SLUG), "NOT", "NOT", UTILITY_TAG, LOGIC_TAG);
  46. return modelNot;
  47. }