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.

56 lines
2.0KB

  1. #include "Bool.hpp"
  2. void Bool::step() {
  3. bool a = inputs[A_INPUT].value > 1.0f;
  4. bool b = inputs[B_INPUT].value > 1.0f;
  5. outputs[AND_OUTPUT].value = a && b ? 5.0f : 0.0f;
  6. outputs[OR_OUTPUT].value = a || b ? 5.0f : 0.0f;
  7. outputs[XOR_OUTPUT].value = a ^ b ? 5.0f : 0.0f;
  8. outputs[NOT_OUTPUT].value = (inputs[NOT_INPUT].active && inputs[NOT_INPUT].value > 1.0f) ? 0.0f : 5.0f;
  9. }
  10. struct BoolWidget : ModuleWidget {
  11. static constexpr int hp = 3;
  12. BoolWidget(Bool* module) : ModuleWidget(module) {
  13. box.size = Vec(RACK_GRID_WIDTH * hp, RACK_GRID_HEIGHT);
  14. {
  15. SVGPanel *panel = new SVGPanel();
  16. panel->box.size = box.size;
  17. panel->setBackground(SVG::load(assetPlugin(plugin, "res/Bool.svg")));
  18. addChild(panel);
  19. }
  20. addChild(Widget::create<ScrewSilver>(Vec(0, 0)));
  21. addChild(Widget::create<ScrewSilver>(Vec(box.size.x - 15, 365)));
  22. // generated by svg_widgets.rb
  23. auto aInputPosition = Vec(10.5, 23.0);
  24. auto bInputPosition = Vec(10.5, 53.0);
  25. auto notInputPosition = Vec(10.5, 221.0);
  26. auto andOutputPosition = Vec(10.5, 86.0);
  27. auto orOutputPosition = Vec(10.5, 126.0);
  28. auto xorOutputPosition = Vec(10.5, 166.0);
  29. auto notOutputPosition = Vec(10.5, 254.0);
  30. // end generated by svg_widgets.rb
  31. addInput(Port::create<Port24>(aInputPosition, Port::INPUT, module, Bool::A_INPUT));
  32. addInput(Port::create<Port24>(bInputPosition, Port::INPUT, module, Bool::B_INPUT));
  33. addInput(Port::create<Port24>(notInputPosition, Port::INPUT, module, Bool::NOT_INPUT));
  34. addOutput(Port::create<Port24>(andOutputPosition, Port::OUTPUT, module, Bool::AND_OUTPUT));
  35. addOutput(Port::create<Port24>(orOutputPosition, Port::OUTPUT, module, Bool::OR_OUTPUT));
  36. addOutput(Port::create<Port24>(xorOutputPosition, Port::OUTPUT, module, Bool::XOR_OUTPUT));
  37. addOutput(Port::create<Port24>(notOutputPosition, Port::OUTPUT, module, Bool::NOT_OUTPUT));
  38. }
  39. };
  40. RACK_PLUGIN_MODEL_INIT(Bogaudio, Bool) {
  41. Model *modelBool = createModel<Bool, BoolWidget>("Bogaudio-Bool", "Bool", "boolean logic", LOGIC_TAG);
  42. return modelBool;
  43. }