native_midi_common.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. native_midi: Hardware Midi support for the SDL_mixer library
  3. Copyright (C) 2000,2001 Florian 'Proff' Schulze & Max Horn
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Florian 'Proff' Schulze
  16. florian.proff.schulze@gmx.net
  17. Max Horn
  18. max@quendi.de
  19. */
  20. #ifndef _NATIVE_MIDI_COMMON_H_
  21. #define _NATIVE_MIDI_COMMON_H_
  22. #include "SDL.h"
  23. /* Midi Status Bytes */
  24. #define MIDI_STATUS_NOTE_OFF 0x8
  25. #define MIDI_STATUS_NOTE_ON 0x9
  26. #define MIDI_STATUS_AFTERTOUCH 0xA
  27. #define MIDI_STATUS_CONTROLLER 0xB
  28. #define MIDI_STATUS_PROG_CHANGE 0xC
  29. #define MIDI_STATUS_PRESSURE 0xD
  30. #define MIDI_STATUS_PITCH_WHEEL 0xE
  31. #define MIDI_STATUS_SYSEX 0xF
  32. /* We store the midi events in a linked list; this way it is
  33. easy to shuffle the tracks together later on; and we are
  34. flexible in the size of each elemnt.
  35. */
  36. typedef struct MIDIEvent
  37. {
  38. Uint32 time; /* Time at which this midi events occurs */
  39. Uint8 status; /* Status byte */
  40. Uint8 data[2]; /* 1 or 2 bytes additional data for most events */
  41. Uint32 extraLen; /* For some SysEx events, we need additional storage */
  42. Uint8 *extraData;
  43. struct MIDIEvent *next;
  44. } MIDIEvent;
  45. /* Load a midifile to memory, converting it to a list of MIDIEvents.
  46. This function returns a linked lists of MIDIEvents, 0 if an error occured.
  47. */
  48. MIDIEvent *CreateMIDIEventList(SDL_RWops *rw, Uint16 *division);
  49. /* Release a MIDIEvent list after usage. */
  50. void FreeMIDIEventList(MIDIEvent *head);
  51. #endif /* _NATIVE_MIDI_COMMON_H_ */