1 /* 2 * midifile.h standard midifile parser 3 * 4 * Copyright (C) 1997-1998 Masaki Chikama (Wren) <chikama@kasumi.ipl.mech.nagoya-u.ac.jp> 5 * 1998- <masaki-c@is.aist-nara.ac.jp> 6 * 7 * Based on midiplay+ by Daisuke NAGANO <breeze.nagano@nifty.ne.jp> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 * 23 */ 24 /* $Id: midifile.h,v 1.2 2001/03/22 11:10:13 chikama Exp $ */ 25 26 #ifndef __MIDIFILE_H__ 27 #define __MIDIFILE_H__ 28 29 #include <stdio.h> 30 #include <sys/types.h> 31 32 #include "portab.h" 33 34 /* Non-standard MIDI file formats */ 35 #define RIFF 0x52494646 36 #define CTMF 0x43544d46 37 /* Standard MIDI file format definitions */ 38 #define MThd 0x4d546864 39 #define MTrk 0x4d54726b 40 41 /* MIDI COMMANDS */ 42 #define MIDI_NOTEOFF 0x80 /* Note off */ 43 #define MIDI_NOTEON 0x90 /* Note on */ 44 #define MIDI_PRESSURE 0xa0 /* Polyphonic key pressure */ 45 #define MIDI_CONTROL 0xb0 /* Control change */ 46 #define MIDI_PROGRAM 0xc0 /* Program change */ 47 #define MIDI_CHANPRES 0xd0 /* Channel pressure */ 48 #define MIDI_PITCHB 0xe0 /* Pitch wheel change */ 49 #define MIDI_SYSEX 0xf0 /* System exclusive data */ 50 51 #define MAXMIDIEVENT 65536 /* maxium event sequence number */ 52 53 struct midievent { 54 int type; /* Data type 55 0: normal 56 1: text 57 2: tempo change 58 3: system35 message 59 */ 60 unsigned long ctime; /* steptime */ 61 int n; /* data length */ 62 int port; /* midi port */ 63 unsigned char *data; /* midi data */ 64 }; 65 66 struct midiinfo { 67 int format; /* MIDI format version ( only 0 is supported) */ 68 int division; /* division for delta time*/ 69 int ntrks; /* number of track */ 70 71 BYTE *data; 72 BYTE *cdata; 73 int length; 74 int length_left; 75 76 struct midievent event[MAXMIDIEVENT]; /* event data */ 77 int eventsize; /* total event size */ 78 int ceptr; /* current event pointer */ 79 80 /* work info */ 81 long curtime; /* current time */ 82 int msgindex; /* midi message buffer index */ 83 int msgsize; /* size of current allocaed msg */ 84 unsigned char *msgbuffer; /* message buffer */ 85 86 /* system35 jump info */ 87 int sys35_label[127]; 88 int marker; 89 }; 90 91 extern struct midiinfo *mf_read_midifile(BYTE *stream, off_t len); 92 extern void mf_remove_midifile(struct midiinfo *m); 93 94 #endif /* __MIDIFILE_H__ */ 95