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
2.1KB

  1. /*
  2. ZynAddSubFX - a software synthesizer
  3. MidiIn.C - This class is inherited by all the Midi input classes
  4. Copyright (C) 2002-2005 Nasca Octavian Paul
  5. Author: Nasca Octavian Paul
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or (at your option) any later version.
  10. */
  11. #include "MidiIn.h"
  12. #include "../globals.h"
  13. #include "InMgr.h"
  14. void MidiIn::midiProcess(unsigned char head,
  15. unsigned char num,
  16. unsigned char value)
  17. {
  18. MidiEvent ev;
  19. unsigned char chan = head & 0x0f;
  20. switch(head & 0xf0) {
  21. case 0x80: //Note Off
  22. ev.type = M_NOTE;
  23. ev.channel = chan;
  24. ev.num = num;
  25. ev.value = 0;
  26. InMgr::getInstance().putEvent(ev);
  27. break;
  28. case 0x90: //Note On
  29. ev.type = M_NOTE;
  30. ev.channel = chan;
  31. ev.num = num;
  32. ev.value = value;
  33. InMgr::getInstance().putEvent(ev);
  34. break;
  35. case 0xA0: /* pressure, aftertouch */
  36. ev.type = M_PRESSURE;
  37. ev.channel = chan;
  38. ev.num = num;
  39. ev.value = value;
  40. InMgr::getInstance().putEvent(ev);
  41. break;
  42. case 0xb0: //Controller
  43. ev.type = M_CONTROLLER;
  44. ev.channel = chan;
  45. ev.num = num;
  46. ev.value = value;
  47. InMgr::getInstance().putEvent(ev);
  48. break;
  49. case 0xc0: //Program Change
  50. ev.type = M_PGMCHANGE;
  51. ev.channel = chan;
  52. ev.num = num;
  53. ev.value = 0;
  54. InMgr::getInstance().putEvent(ev);
  55. break;
  56. case 0xe0: //Pitch Wheel
  57. ev.type = M_CONTROLLER;
  58. ev.channel = chan;
  59. ev.num = C_pitchwheel;
  60. ev.value = (num + value * (int) 128) - 8192;
  61. InMgr::getInstance().putEvent(ev);
  62. break;
  63. }
  64. }