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.

69 lines
1.7KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. InMgr.h - MIDI Input Manager
  4. Copyright (C) 2016 Mark McCurry
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. */
  10. #ifndef INMGR_H
  11. #define INMGR_H
  12. #include <string>
  13. #include "ZynSema.h"
  14. #include "SafeQueue.h"
  15. enum midi_type {
  16. M_NOTE = 1,
  17. M_CONTROLLER = 2,
  18. M_PGMCHANGE = 3,
  19. M_PRESSURE = 4
  20. }; //type=1 for note, type=2 for controller, type=3 for program change
  21. //type=4 for polyphonic aftertouch
  22. struct MidiEvent {
  23. MidiEvent();
  24. int channel; //the midi channel for the event
  25. int type; //type=1 for note, type=2 for controller
  26. int num; //note, controller or program number
  27. int value; //velocity or controller value
  28. int time; //time offset of event (used only in jack->jack case at the moment)
  29. };
  30. //super simple class to manage the inputs
  31. class InMgr
  32. {
  33. public:
  34. static InMgr &getInstance();
  35. ~InMgr();
  36. void putEvent(MidiEvent ev);
  37. /**Flush the Midi Queue*/
  38. void flush(unsigned frameStart, unsigned frameStop);
  39. bool empty() const;
  40. bool setSource(std::string name);
  41. std::string getSource() const;
  42. void setMaster(class Master *master);
  43. friend class EngineMgr;
  44. private:
  45. InMgr();
  46. class MidiIn *getIn(std::string name);
  47. SafeQueue<MidiEvent> queue;
  48. mutable ZynSema work;
  49. class MidiIn * current;
  50. /**the link to the rest of zyn*/
  51. class Master *master;
  52. };
  53. #endif