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.

58 lines
1.3KB

  1. #ifndef INMGR_H
  2. #define INMGR_H
  3. #include <string>
  4. #include "ZynSema.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. int time; //time offset of event (used only in jack->jack case at the moment)
  20. };
  21. //super simple class to manage the inputs
  22. class InMgr
  23. {
  24. public:
  25. static InMgr &getInstance();
  26. ~InMgr();
  27. void putEvent(MidiEvent ev);
  28. /**Flush the Midi Queue*/
  29. void flush(unsigned frameStart, unsigned frameStop);
  30. bool empty() const;
  31. bool setSource(std::string name);
  32. std::string getSource() const;
  33. void setMaster(class Master *master);
  34. friend class EngineMgr;
  35. private:
  36. InMgr();
  37. class MidiIn *getIn(std::string name);
  38. SafeQueue<MidiEvent> queue;
  39. mutable ZynSema work;
  40. class MidiIn * current;
  41. /**the link to the rest of zyn*/
  42. class Master *master;
  43. };
  44. #endif