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.

33 lines
671B

  1. #pragma once
  2. #include <cstdint>
  3. #include <vector>
  4. namespace SynthDevKit {
  5. enum EETypes {
  6. EVENT_CLEAR = -10,
  7. EVENT_RESET,
  8. EVENT_FIRST,
  9. EVENT_EVEN,
  10. EVENT_ODD,
  11. EVENT_MAX = 2048
  12. };
  13. const uint16_t TOP_EVENT = EVENT_MAX + 24;
  14. class EventEmitter {
  15. public:
  16. EventEmitter ( );
  17. void clear (bool all = false);
  18. void on (int16_t, void (*)(int16_t, float));
  19. void removeListener (int16_t, void(*)(int16_t, float));
  20. int16_t listenerCount (int16_t);
  21. void emit (int16_t, float);
  22. protected:
  23. bool has_emitted;
  24. private:
  25. int16_t realEvent (int16_t);
  26. std::vector<void (*)(int16_t, float)> emitters[TOP_EVENT];
  27. };
  28. }