Audio plugin host https://kx.studio/carla
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.

53 lines
1.1KB

  1. #ifndef INMGR_H
  2. #define INMGR_H
  3. #include <string>
  4. #include <semaphore.h>
  5. #include "SafeQueue.h"
  6. enum midi_type {
  7. M_NOTE = 1,
  8. M_CONTROLLER = 2,
  9. M_PGMCHANGE = 3,
  10. M_PRESSURE = 4
  11. }; //type=1 for note, type=2 for controller, type=3 for program change
  12. //type=4 for polyphonic aftertouch
  13. struct MidiEvent {
  14. MidiEvent();
  15. int channel; //the midi channel for the event
  16. int type; //type=1 for note, type=2 for controller
  17. int num; //note, controller or program number
  18. int value; //velocity or controller value
  19. };
  20. //super simple class to manage the inputs
  21. class InMgr
  22. {
  23. public:
  24. static InMgr &getInstance();
  25. ~InMgr();
  26. void putEvent(MidiEvent ev);
  27. /**Flush the Midi Queue*/
  28. void flush();
  29. bool setSource(std::string name);
  30. std::string getSource() const;
  31. friend class EngineMgr;
  32. private:
  33. InMgr();
  34. class MidiIn *getIn(std::string name);
  35. SafeQueue<MidiEvent> queue;
  36. sem_t work;
  37. class MidiIn * current;
  38. /**the link to the rest of zyn*/
  39. class Master & master;
  40. };
  41. #endif