root/trunk/libjdkmidi/trunk/include/jdkmidi/midi.h

Revision 552, 7.4 kB (checked in by jeffk@…, 8 months ago)

formatting fixed

Line 
1/*
2 *  libjdkmidi-2004 C++ Class Library for MIDI
3 *
4 *  Copyright (C) 2004  J.D. Koftinoff Software, Ltd.
5 *  www.jdkoftinoff.com
6 *  jeffk@jdkoftinoff.com
7 *
8 *  *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 ***
9 *
10 *  This program is free software; you can redistribute it and/or modify
11 *  it under the terms of the GNU General Public License as published by
12 *  the Free Software Foundation; either version 2 of the License, or
13 *  (at your option) any later version.
14 *
15 *  This program is distributed in the hope that it will be useful,
16 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
17 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 *  GNU General Public License for more details.
19 *
20 *  You should have received a copy of the GNU General Public License
21 *  along with this program; if not, write to the Free Software
22 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23*/
24/*
25** Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd.
26**
27** All rights reserved.
28**
29** No one may duplicate this source code in any form for any reason
30** without the written permission given by J.D. Koftinoff Software, Ltd.
31**
32*/
33
34
35#ifndef JDKMIDI_MIDI_H
36#define JDKMIDI_MIDI_H
37
38#include "jdkmidi/world.h"
39
40namespace jdkmidi
41{
42
43  typedef unsigned long MIDIClockTime;
44 
45  ///
46  /// MIDI Status bytes
47  ///
48 
49  enum
50  {
51    NOTE_OFF =0x80, ///< Note off message with velocity
52    NOTE_ON  =0x90, ///< Note on message with velocity or Note off if velocity is 0
53    POLY_PRESSURE =0xa0,  ///< Polyphonic key pressure/aftertouch with note and pressure
54    CONTROL_CHANGE =0xb0, ///< Control change message with controller number and 7 bit value
55    PROGRAM_CHANGE =0xc0, ///< Program change message with 7 bit program number
56    CHANNEL_PRESSURE=0xd0, ///< Channel pressure/aftertouch with pressure
57    PITCH_BEND =0xe0, ///< Channel bender with 14 bit bender value
58    SYSEX_START =0xf0, ///< Start of a MIDI System-Exclusive message
59    MTC  =0xf1, ///< Start of a two byte MIDI Time Code message
60    SONG_POSITION =0xf2, ///< Start of a three byte MIDI Song Position message
61    SONG_SELECT =0xf3, ///< Start of a two byte MIDI Song Select message
62    TUNE_REQUEST =0xf6,  ///< Single byte tune request message
63    SYSEX_END =0xf7,  ///< End of a MIDI System-Exclusive message
64    RESET  =0xff, ///< 0xff is a reset byte on the serial line. We never used as reset in a MIDIMessage object,
65    META_EVENT =0xff ///< 0xff means a meta event in our internal processing.
66  };
67 
68 
69 
70  ///
71  /// MIDI Real Time Messages
72  ///
73 
74  enum
75  {
76    TIMING_CLOCK =0xf8,  ///< 24 timing clocks per beat
77    MEASURE_END =0xf9, ///< Measure end byte
78    START  =0xfa,  ///< Sequence start message
79    CONTINUE =0xfb, ///< Sequence continue message
80    STOP  =0xfc, ///< Sequence stop message
81    ACTIVE_SENSE =0xfe ///< Active sense message
82  };
83 
84 
85  ///
86  /// Controller Numbers
87  ///
88 
89  enum
90  {
91    C_LSB  =0x20, ///< add this to a non-switch controller to access the LSB.
92   
93    C_GM_BANK =0x00, ///< general midi bank select
94    C_MODULATION =0x01, ///< modulation
95    C_BREATH =0x02, ///< breath controller
96    C_FOOT  =0x04, ///< foot controller
97    C_PORTA_TIME =0x05, ///< portamento time
98    C_DATA_ENTRY =0x06, ///< data entry value
99    C_MAIN_VOLUME =0x07, ///< main volume control
100    C_BALANCE =0x08, ///< balance control
101    C_PAN  =0x0a, ///< panpot stereo control
102    C_EXPRESSION =0x0b, ///< expression control
103    C_GENERAL_1 =0x10, ///< general purpose controller 1
104    C_GENERAL_2 =0x11, ///< general purpose controller 2
105    C_GENERAL_3 =0x12, ///< general purpose controller 3
106    C_GENERAL_4 =0x13, ///< general purpose controller 4
107   
108    C_DAMPER =0x40, ///< hold pedal (sustain)
109    C_PORTA  =0x41, ///< portamento switch
110    C_SOSTENUTO =0x42, ///< sostenuto switch
111    C_SOFT_PEDAL =0x43, ///< soft pedal
112    C_HOLD_2 =0x45, ///< hold pedal 2
113   
114    C_GENERAL_5 =0x50, ///< general purpose controller 5
115    C_GENERAL_6 =0x51, ///< general purpose controller 6
116    C_GENERAL_7 =0x52, ///< general purpose controller 7
117    C_GENERAL_8 =0x53, ///< general purpose controller 8
118   
119    C_EFFECT_DEPTH =0x5b, ///< external effects depth
120    C_TREMELO_DEPTH =0x5c, ///< tremelo depth
121    C_CHORUS_DEPTH =0x5d, ///< chorus depth
122    C_CELESTE_DEPTH =0x5e, ///< celeste (detune) depth
123    C_PHASER_DEPTH =0x5f, ///< phaser effect depth
124   
125    C_DATA_INC =0x60, ///< increment data value
126    C_DATA_DEC =0x61, ///< decrement data value
127   
128    C_NONRPN_LSB =0x62, ///< non registered parameter LSB
129    C_NONRPN_MSB =0x63, ///< non registered parameter MSB
130   
131    C_RPN_LSB =0x64, ///< registered parameter LSB
132    C_RPN_MSB =0x65, ///< registered parameter MSB
133   
134   
135   
136    C_RESET  =0x79, ///< reset all controllers
137   
138    C_LOCAL  =0x79, ///< local control on/off
139    C_ALL_NOTES_OFF =0x7a, ///< all notes off
140    C_OMNI_OFF =0x7c, ///< omni off, all notes off
141    C_OMNI_ON =0x7d, ///< omni on, all notes off
142    C_MONO  =0x7e, ///< mono on, all notes off
143    C_POLY  =0x7f ///< poly on, all notes off
144  };
145 
146 
147  ///
148  /// Registered Parameter Numbers:
149  ///
150 
151  enum
152  {
153    RPN_BEND_WIDTH =0x00, ///< bender sensitivity
154    RPN_FINE_TUNE =0x01, ///< fine tuning
155    RPN_COARSE_TUNE =0x02 ///< coarse tuning
156  };
157 
158 
159 
160  ///
161  /// META Event types (stored in first data byte if status==META_EVENT)
162  /// These types are the same as MIDIFile meta-events,
163  /// except when a meta-event is in a MIDIMessage, there is a limit
164  /// of two data bytes. So the format of the meta-events in a
165  /// MIDIMessage class will be different than the standard MIDIFile
166  /// meta-events.
167  ///
168 
169  enum
170  {
171    META_SEQUENCE_NUMBER =0x00, ///< value=16 bits. type 2 files
172   
173    META_GENERIC_TEXT =0x01, ///< value=16 bits, text item #
174    META_COPYRIGHT  =0x02, ///< value=17 bits, text item #
175    META_INSTRUMENT_NAME =0x03,
176    META_TRACK_NAME  =0x04,
177    META_LYRIC_TEXT  =0x05,
178    META_MARKER_TEXT =0x06,
179    META_CUE_TEXT  =0x07,
180   
181    META_OUTPUT_CABLE =0x21,
182    META_TRACK_LOOP  =0x2E,
183    META_DATA_END  =0x2f,
184    META_END_OF_TRACK =0x2F,
185    META_TEMPO  =0x51, ///< value=16 bits, tempo(bpm)*256
186    META_SMPTE  =0x54, ///< what for?
187    META_TIMESIG  =0x58,  ///< value=num, denom
188    META_KEYSIG  =0x59,  ///< value=# of sharps/flats, major/minor
189    META_BEAT_MARKER =0x7e,
190    META_SEQUENCER_SPECIFIC =0x7F,
191    META_NO_OPERATION =0x7f
192   
193  };
194 
195  extern const signed  char lut_msglen[16];
196  extern  const signed char lut_sysmsglen[16];
197  extern const bool lut_is_white[12];
198 
199 
200  ///
201  /// Message Length function. Not valid for Meta-events (0xff). Returns -1 if you need to call
202  /// GetSystemMessageLength() instead.
203  ///
204 
205  inline signed char GetMessageLength ( unsigned char stat )
206  {
207    return lut_msglen[stat>>4];
208  }
209 
210  ///
211  /// Message Length of system messages. Not valid for Meta-events (0xff). Returns -1 if this message
212  /// length is unknown until parsing is complete.
213  ///
214 
215  inline signed char GetSystemMessageLength ( unsigned char stat )
216  {
217    return lut_sysmsglen[stat-0xf0];
218  }
219 
220 
221  ///
222  /// Piano key color white test
223  ///
224 
225  inline bool IsNoteWhite ( unsigned char note )
226  {
227    return lut_is_white[ note%12 ];
228  }
229 
230  ///
231  /// Piano key color black test
232  ///
233 
234  inline bool IsNoteBlack ( unsigned char note )
235  {
236    return !lut_is_white[ note%12 ];
237  }
238 
239 
240  ///
241  /// Note # to standard octave conversion
242  ///
243 
244  inline int GetNoteOctave ( unsigned char note )
245  {
246    return ( note/12 )-1;
247  }
248 
249 
250 
251}
252
253
254
255
256#endif
Note: See TracBrowser for help on using the browser.