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
953B

  1. #include "common.hpp"
  2. ////////////////////
  3. // module widgets
  4. ////////////////////
  5. using namespace rack;
  6. #define plugin "TheXOR"
  7. namespace rack_plugin_TheXOR {
  8. #define NUM_SWITCHES (5)
  9. struct Switch;
  10. struct SwitchWidget : ModuleWidget
  11. {
  12. SwitchWidget(Switch * module);
  13. private:
  14. float yncscape(float y, float height)
  15. {
  16. return RACK_GRID_HEIGHT - mm2px(y + height);
  17. }
  18. };
  19. struct Switch : Module
  20. {
  21. enum ParamIds
  22. {
  23. SW_1,
  24. NUM_PARAMS = SW_1 + NUM_SWITCHES
  25. };
  26. enum InputIds
  27. {
  28. IN_1,
  29. MOD_1= IN_1 + NUM_SWITCHES,
  30. NUM_INPUTS = MOD_1 + NUM_SWITCHES
  31. };
  32. enum OutputIds
  33. {
  34. OUT_1,
  35. NUM_OUTPUTS = OUT_1 + NUM_SWITCHES
  36. };
  37. enum LightIds
  38. {
  39. LED_1,
  40. NUM_LIGHTS = LED_1 + NUM_SWITCHES
  41. };
  42. Switch() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS)
  43. {
  44. }
  45. void step() override;
  46. private:
  47. bool getSwitch(int n)
  48. {
  49. return (inputs[MOD_1 + n].normalize(0.0) + params[SW_1 + n].value) > 0.5;
  50. }
  51. };
  52. } // namespace rack_plugin_TheXOR