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.

71 lines
932B

  1. #pragma once
  2. #include "bogaudio.hpp"
  3. extern Model* modelCmp;
  4. namespace bogaudio {
  5. struct Cmp : Module {
  6. enum ParamsIds {
  7. A_PARAM,
  8. B_PARAM,
  9. WINDOW_PARAM,
  10. LAG_PARAM,
  11. OUTPUT_PARAM,
  12. NUM_PARAMS
  13. };
  14. enum InputsIds {
  15. A_INPUT,
  16. B_INPUT,
  17. WINDOW_INPUT,
  18. LAG_INPUT,
  19. NUM_INPUTS
  20. };
  21. enum OutputsIds {
  22. GREATER_OUTPUT,
  23. LESS_OUTPUT,
  24. EQUAL_OUTPUT,
  25. NOT_EQUAL_OUTPUT,
  26. NUM_OUTPUTS
  27. };
  28. enum LightsIds {
  29. NUM_LIGHTS
  30. };
  31. enum State {
  32. LOW,
  33. HIGH,
  34. LAG_LOW,
  35. LAG_HIGH
  36. };
  37. State _thresholdState;
  38. int _thresholdLag = 0;
  39. State _windowState;
  40. int _windowLag = 0;
  41. Cmp() : Module(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS) {
  42. onReset();
  43. }
  44. void onReset() override;
  45. void step() override;
  46. void stepChannel(
  47. bool high,
  48. float highValue,
  49. float lowValue,
  50. State& state,
  51. int& channelLag,
  52. int& lag,
  53. Output& highOutput,
  54. Output& lowOutput
  55. );
  56. int lagInSamples();
  57. };
  58. } // namespace bogaudio