home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 581b.lha / M2Midi / MidiLibrary_v2p0.LZH / MidiLibrary_v2.0 / include.h / midi / midifile.h < prev   
C/C++ Source or Header  |  1989-06-25  |  3KB  |  94 lines

  1. #ifndef MIDI_MIDIFILE_H
  2. #define MIDI_MIDIFILE_H
  3.  
  4. /*
  5.     MIDI Files definitions
  6.     ---- ----- -----------
  7.  
  8.     This is based on the MIDI Files spec 1.0 from IMA.
  9. */
  10.  
  11. #ifndef EXEC_TYPES_H
  12. #include <exec/types.h>
  13. #endif
  14.  
  15.  
  16. /* chunks */
  17.  
  18. #define MFCK_NULL 0L
  19. #define MFCK_MThd (ULONG)'MThd'
  20. #define MFCK_MTrk (ULONG)'MTrk'
  21.  
  22. struct ckhdr {        /* always at the beginning of a chunk */
  23.     ULONG id;        /* id byte */
  24.     LONG len;        /* length of chunk in bytes (bytes after this header) */
  25. };
  26.  
  27.  
  28. /* header */
  29.  
  30. struct mfheader {   /* MIDI File header chunk */
  31.     UWORD format;   /* format id */
  32.     UWORD ntracks;  /* number of tracks */
  33.     WORD division;  /* division if >0 is # of divisions per notated qtr note, <0 is SMPTE division (see spec) */
  34. };
  35.  
  36. #define MFFMT_ONETRACK     0    /* single track */
  37. #define MFFMT_SIMTRACKS  1    /* multiple simultaneous tracks */
  38. #define MFFMT_INDTRACKS  2    /* multiple temporally indepent single-track patterns */
  39.  
  40.  
  41. /* track */
  42.  
  43. /*
  44.     tracks consist of one or more events:
  45.  
  46.     <channel msg> | <sysex msg> | <meta event>
  47.  
  48.     <channel msg> uses running status so there may or may not be a
  49.     status byte here
  50.  
  51.     <sysex msg>:  F0 len data
  52.           F7 len data
  53.           F7 len data F7
  54.     where len is a variable length value.
  55.  
  56.     <meta event>:  FF type len data
  57.  
  58.     (see spec for more info)
  59. */
  60.  
  61.  
  62.     /* special track event status bytes */
  63. #define MS_ESCAPE    0xF7    /* either a sys/ex continuation or an "escape" sequence, tell apart using running status */
  64. #define MS_META      0xFF    /* meta event */
  65.  
  66.     /* meta event types */
  67. #define MFMETA_SEQNUM      0x00    /* FF 00 02 ssss: ssss is a sequence number */
  68. #define MFMETA_TEXT      0x01    /* FF 01 len text: as are types 01 - 0F */
  69. #define MFMETA_COPYRIGHT  0x02
  70. #define MFMETA_TRACKNAME  0x03
  71. #define MFMETA_INSTRNAME  0x04
  72. #define MFMETA_LYRIC      0x05
  73. #define MFMETA_MARKER      0x06
  74. #define MFMETA_CUEPOINT   0x07
  75. #define MFMETA_CHANPREFIX 0x20    /* FF 20 01 cc: Identifies channel for subsequent sys/ex and meta-events for track association */
  76. #define MFMETA_TRACKEND   0x2f    /* FF 2F 00: denote the end of a track and is mandatory */
  77. #define MFMETA_TEMPO      0x51    /* FF 51 03 tttttt: set tempo in microseconds per MIDI qtr-note */
  78. #define MFMETA_SMPTEOFFSET 0x54 /* FF 54 05 hr mn se fr ff: SMPTE offset */
  79. #define MFMETA_TIMESIG      0x58    /* FF 58 04 nn dd cc bb: uses struct timesig below */
  80. #define MFMETA_KEYSIG      0x59    /* FF 59 02 sf mi: key signature */
  81. #define MFMETA_SEQSPEC      0x7f    /* FF 7f len data: sequencer-specific meta-event */
  82.  
  83.  
  84. struct mftimesig {    /* MIDI File time signature */
  85.     UBYTE numerator;    /* numerator */
  86.     UBYTE denompower;    /* negative power of two of denominator */
  87.     UBYTE metronome;    /* number of midi clocks per metronome click */
  88.     UBYTE division;    /* number of notated 32nd-notes per midi qtr note */
  89. };
  90.  
  91. #define TEMPOLEN 3    /* current length of tempo change */
  92.  
  93. #endif
  94.