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.

56 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. friend class EngineMgr;
  34. private:
  35. InMgr();
  36. class MidiIn *getIn(std::string name);
  37. SafeQueue<MidiEvent> queue;
  38. mutable ZynSema work;
  39. class MidiIn * current;
  40. /**the link to the rest of zyn*/
  41. class Master & master;
  42. };
  43. #endif