MusicKit  0.0.0
midi_spec.h
00001 /*
00002   $Id$
00003   Defined In: The MusicKit
00004 
00005   Description: MIDI definitions
00006 
00007   Author: David Jaffe
00008         Copyright (C) 1991, NeXT, Inc.
00009 */
00010 /*
00011 Modification history:
00012 
00013   $Log$
00014   Revision 1.5  2001/07/02 16:58:03  sbrandon
00015   - commented out cruft after endif
00016   - added newline onto end of file
00017 
00018   Revision 1.4  2000/05/13 17:07:35  leigh
00019   Added extra controller type definitions
00020 
00021   Revision 1.3  2000/02/07 23:53:26  leigh
00022   added patch bank change and MIDI pitch bend range defintions
00023 
00024   Revision 1.2  1999/07/29 01:26:06  leigh
00025   Added Win32 compatibility, CVS logs, SBs changes
00026 
00027 */
00028 #ifndef _MIDI_SPEC_
00029 #define _MIDI_SPEC_
00030 
00031 /*
00032  * MIDI status bytes (from International MIDI Association document
00033  * MIDI-1.0, August 5, 1983)
00034  */
00035 #define MIDI_RESETCONTROLLERS   0x79
00036 #define MIDI_LOCALCONTROL       0x7a
00037 #define MIDI_ALLNOTESOFF        0x7b
00038 #define MIDI_OMNIOFF            0x7c
00039 #define MIDI_OMNION             0x7d
00040 #define MIDI_MONO               0x7e
00041 #define MIDI_POLY               0x7f
00042 #define MIDI_NOTEOFF            0x80
00043 #define MIDI_NOTEON             0x90
00044 #define MIDI_POLYPRES           0xa0
00045 #define MIDI_CONTROL            0xb0
00046 #define MIDI_PROGRAM            0xc0
00047 #define MIDI_CHANPRES           0xd0
00048 #define MIDI_PITCH              0xe0
00049 #define MIDI_CHANMODE           MIDI_CONTROL
00050 #define MIDI_SYSTEM             0xf0
00051 #define MIDI_SYSEXCL            (MIDI_SYSTEM | 0x0)
00052 #define MIDI_TIMECODEQUARTER    (MIDI_SYSTEM | 0x1)
00053 #define MIDI_SONGPOS            (MIDI_SYSTEM | 0x2)
00054 #define MIDI_SONGSEL            (MIDI_SYSTEM | 0x3)
00055 #define MIDI_TUNEREQ            (MIDI_SYSTEM | 0x6)
00056 #define MIDI_EOX                (MIDI_SYSTEM | 0x7)
00057 #define MIDI_CLOCK              (MIDI_SYSTEM | 0x8)
00058 #define MIDI_START              (MIDI_SYSTEM | 0xa)
00059 #define MIDI_CONTINUE           (MIDI_SYSTEM | 0xb)
00060 #define MIDI_STOP               (MIDI_SYSTEM | 0xc)
00061 #define MIDI_ACTIVE             (MIDI_SYSTEM | 0xe)
00062 #define MIDI_RESET              (MIDI_SYSTEM | 0xf)
00063 
00064 #define MIDI_MAXDATA            0x7f
00065 #define MIDI_OP(y)              (y & (MIDI_STATUSMASK))
00066 #define MIDI_DATA(y)            (y & (MIDI_MAXDATA))
00067 #define MIDI_MAXCHAN            0x0f
00068 #define MIDI_NUMCHANS           16
00069 #define MIDI_NUMKEYS            128
00070 #define MIDI_ZEROBEND           0x2000
00071 #define MIDI_DEFAULTVELOCITY    64
00072 
00073 /* MIDI Controller numbers */
00074 #define MIDI_BANKSELECT_MSB     0
00075 #define MIDI_MODWHEEL           1
00076 #define MIDI_BREATH             2
00077 #define MIDI_FOOT               4
00078 #define MIDI_PORTAMENTOTIME     5
00079 #define MIDI_DATAENTRY          6
00080 #define MIDI_MAINVOLUME         7
00081 #define MIDI_BALANCE            8
00082 #define MIDI_PAN                10
00083 #define MIDI_EXPRESSION         11
00084 #define MIDI_EFFECTCONTROL1     12
00085 #define MIDI_EFFECTCONTROL2     13                      
00086 
00087 /* LSB for above */
00088 #define MIDI_MODWHEELLSB        (1 + 31)  
00089 #define MIDI_BREATHLSB          (2 + 31)
00090 #define MIDI_FOOTLSB            (4 + 31)
00091 #define MIDI_PORTAMENTOTIMELSB  (5 + 31)
00092 #define MIDI_DATAENTRYLSB       (6 + 31)
00093 #define MIDI_MAINVOLUMELSB      (7 + 31)
00094 #define MIDI_BALANCELSB         (8 + 31)
00095 #define MIDI_PANLSB             (10 + 31)
00096 #define MIDI_EXPRESSIONLSB      (11 + 31)
00097 
00098 /* patch bank change commands */
00099 #define MIDI_BANKMSB            0
00100 #define MIDI_BANKLSB            32
00101 
00102 #define MIDI_DAMPER             64
00103 #define MIDI_PORTAMENTO         65
00104 #define MIDI_SOSTENUTO          66
00105 #define MIDI_SOFTPEDAL          67
00106 #define MIDI_LEGATOFOOTSWITCH   68
00107 #define MIDI_HOLD2              69
00108 
00109 // default sound controller values
00110 #define MIDI_SOUNDVARIATION     70
00111 #define MIDI_HARMONICINTENSITY  71
00112 #define MIDI_RELEASETIME        72
00113 #define MIDI_ATTACKTIME         73
00114 #define MIDI_BRIGHTNESS         74
00115 
00116 #define MIDI_PORTAMENTOCONTROL  84
00117 
00118 /*
00119  * Controller 91-95 definitions from original 1.0 MIDI spec
00120  */
00121 #define MIDI_EXTERNALEFFECTSDEPTH 91
00122 #define MIDI_TREMELODEPTH       92
00123 #define MIDI_CHORUSDEPTH        93
00124 #define MIDI_DETUNEDEPTH        94
00125 #define MIDI_PHASERDEPTH        95
00126 /*
00127  * Controller 91-95 definitions as of June 1990
00128  */
00129 #define MIDI_EFFECTS1           91
00130 #define MIDI_EFFECTS2           92
00131 #define MIDI_EFFECTS3           93
00132 #define MIDI_EFFECTS4           94
00133 #define MIDI_EFFECTS5           95
00134 #define MIDI_DATAINCREMENT      96
00135 #define MIDI_DATADECREMENT      97
00136 
00137 /* Controller 100-101 definitions for pitch bend range */
00138 #define MIDI_PITCHBENDRANGE     100
00139 
00140 /*
00141  * Masks for disassembling MIDI status bytes
00142  */
00143 #define MIDI_STATUSBIT  0x80    /* indicates this is a status byte */
00144 #define MIDI_STATUSMASK 0xf0    /* bits indicating type of status req */
00145 #define MIDI_SYSRTBIT   0x08    /* differentiates SYSRT from SYSCOM */
00146 
00147 /* Some useful parsing macros. */
00148 #define MIDI_TYPE_SYSTEM_REALTIME(byte) (((byte)&0xf8) == 0xf8)
00149 #define MIDI_TYPE_1BYTE(byte)   (   MIDI_TYPE_SYSTEM_REALTIME(byte) \
00150                                  || (byte) == 0xf6 || (byte) == 0xf7)
00151 #define MIDI_TYPE_2BYTE(byte)   (   (((byte)&0xe0) == 0xc0) \
00152                                  || (((byte)&0xe0) == 0xd0) \
00153                                  || ((byte)&0xfd) == 0xf1)
00154 #define MIDI_TYPE_3BYTE(byte)   (   ((byte)&0xc0) == 0x80 \
00155                                  || ((byte)&0xe0) == 0xe0 \
00156                                  || (byte) == 0xf2)
00157 #define MIDI_TYPE_SYSTEM(byte)  (((byte)&0xf0) == 0xf0)
00158 #define MIDI_EVENTSIZE(byte)    (MIDI_TYPE_1BYTE(byte) ? 1 : \
00159                                  MIDI_TYPE_2BYTE(byte) ? 2 : 3)
00160 
00161 #endif   /* _MIDI_SPEC_ */