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.

73 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. namespace zyncarla {
  16. enum midi_type {
  17. M_NOTE = 1,
  18. M_CONTROLLER = 2,
  19. M_PGMCHANGE = 3,
  20. M_PRESSURE = 4
  21. }; //type=1 for note, type=2 for controller, type=3 for program change
  22. //type=4 for polyphonic aftertouch
  23. struct MidiEvent {
  24. MidiEvent();
  25. int channel; //the midi channel for the event
  26. int type; //type=1 for note, type=2 for controller
  27. int num; //note, controller or program number
  28. int value; //velocity or controller value
  29. int time; //time offset of event (used only in jack->jack case at the moment)
  30. };
  31. //super simple class to manage the inputs
  32. class InMgr
  33. {
  34. public:
  35. static InMgr &getInstance();
  36. ~InMgr();
  37. void putEvent(MidiEvent ev);
  38. /**Flush the Midi Queue*/
  39. void flush(unsigned frameStart, unsigned frameStop);
  40. bool empty() const;
  41. bool setSource(std::string name);
  42. std::string getSource() const;
  43. void setMaster(class Master *master);
  44. friend class EngineMgr;
  45. private:
  46. InMgr();
  47. class MidiIn *getIn(std::string name);
  48. SafeQueue<MidiEvent> queue;
  49. mutable ZynSema work;
  50. class MidiIn * current;
  51. /**the link to the rest of zyn*/
  52. class Master *master;
  53. };
  54. }
  55. #endif