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.

78 lines
2.5KB

  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 modify
  7. it under the terms of version 2 of the GNU General Public License
  8. as published by the Free Software Foundation.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License (version 2 or later) for more details.
  13. You should have received a copy of the GNU General Public License (version 2)
  14. along with this program; if not, write to the Free Software Foundation,
  15. Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. */
  17. #include "MidiIn.h"
  18. #include "../globals.h"
  19. #include "InMgr.h"
  20. void MidiIn::midiProcess(unsigned char head,
  21. unsigned char num,
  22. unsigned char value)
  23. {
  24. MidiEvent ev;
  25. unsigned char chan = head & 0x0f;
  26. switch(head & 0xf0) {
  27. case 0x80: //Note Off
  28. ev.type = M_NOTE;
  29. ev.channel = chan;
  30. ev.num = num;
  31. ev.value = 0;
  32. InMgr::getInstance().putEvent(ev);
  33. break;
  34. case 0x90: //Note On
  35. ev.type = M_NOTE;
  36. ev.channel = chan;
  37. ev.num = num;
  38. ev.value = value;
  39. InMgr::getInstance().putEvent(ev);
  40. break;
  41. case 0xA0: /* pressure, aftertouch */
  42. ev.type = M_PRESSURE;
  43. ev.channel = chan;
  44. ev.num = num;
  45. ev.value = value;
  46. InMgr::getInstance().putEvent(ev);
  47. break;
  48. case 0xb0: //Controller
  49. ev.type = M_CONTROLLER;
  50. ev.channel = chan;
  51. ev.num = num;
  52. ev.value = value;
  53. InMgr::getInstance().putEvent(ev);
  54. break;
  55. case 0xc0: //Program Change
  56. ev.type = M_PGMCHANGE;
  57. ev.channel = chan;
  58. ev.num = num;
  59. ev.value = 0;
  60. InMgr::getInstance().putEvent(ev);
  61. break;
  62. case 0xe0: //Pitch Wheel
  63. ev.type = M_CONTROLLER;
  64. ev.channel = chan;
  65. ev.num = C_pitchwheel;
  66. ev.value = (num + value * (int) 128) - 8192;
  67. InMgr::getInstance().putEvent(ev);
  68. break;
  69. }
  70. }