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