vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
VVMIDI.h
1 
2 /*
3 
4  a brief intro on how midi works
5 
6  all messages have something in common: the first byte of the message is the status byte.
7  the status byte is special, because it's the only byte that has bit #7 set. any of the bytes
8  following the status byte will *not* have bit #7 set. this is how you detect the start of
9  a midi message. status bytes will be in the range of 0x80 - 0xFF. all remaining data bytes
10  will be in the range of 0x00 - 0x7F.
11 
12  the byte 0x80 is 1000 0000
13  the byte 0xFF is 1111 1111
14 
15  the status bytes in the range 0x80 to 0xEF are for messages that broadcast to any of
16  the 16 MIDI channels. these are called the voice messages. for voice messages, break the
17  8-bit byte into 2, 4-bit nibbles. a status byte of 0x92 would be broken up into two
18  nibbles: 9 (high nibble), and 2 (low nibble). the high nibble tells you what type of message
19  it is, the low nibble tells you what channel the message is on. here's what the high
20  nibbles mean:
21 
22  8 note off
23  9 note on
24  A afterTouch (key pressure)
25  B control change
26  C program (patch) change
27  D channel pressure
28  E pitch wheel
29 
30  the status bytes in the range 0xF0 to 0xFF are for messages that aren't going to a
31  specific channel; these messages can be rececived by anything in a daisy chain. these
32  status bytes are therefore typically reserved for messages that synchronize playback
33  between all the instruments, and other such tasks. these status bytes are divided into
34  two categories:
35 
36  0xF0 - 0xF7 system common messages
37  0xF8 - 0xFF system realtime messages
38 
39 */
40 
41 
42 
43 /*
44  // these are all STATUS MESSAGES: all status mesages have bit 7 set. ONLY status msgs have bit 7 set to 1!
45 // these status messages go to a specific channel (these are voice messages)
46 #define VVMIDINoteOffVal 0x80 // +2 data bytes
47 #define VVMIDINoteOnVal 0x90 // +2 data bytes
48 #define VVMIDIAfterTouchVal 0xA0 // +2 data bytes
49 #define VVMIDIControlChangeVal 0xB0 // +2 data bytes
50 #define VVMIDIProgramChangeVal 0xC0 // +1 data byte
51 #define VVMIDIChannelPressureVal 0xD0 // +1 data byte
52 #define VVMIDIPitchWheelVal 0xE0 // +2 data bytes
53 // these status messages go anywhere/everywhere
54 // 0xF0 - 0xF7 system common messages
55 #define VVMIDIBeginSysexDumpVal 0xF0 // signals the start of a sysex dump; unknown amount of data to follow
56 #define VVMIDIMTCQuarterFrameVal 0xF1 // +1 data byte, rep. time code; 0-127
57 #define VVMIDISongPosPointerVal 0xF2 // + 2 data bytes, rep. 14-bit val; this is MIDI beat on which to start song.
58 #define VVMIDISongSelectVal 0xF3 // +1 data byte, rep. song number; 0-127
59 #define VVMIDIUndefinedCommon1Val 0xF4
60 #define VVMIDIUndefinedCommon2Val 0xF5
61 #define VVMIDITuneRequestVal 0xF6 // no data bytes!
62 #define VVMIDIEndSysexDumpVal 0xF7 // signals the end of a sysex dump
63 // 0xF8 - 0xFF system realtime messages
64 #define VVMIDIClockVal 0xF8 // no data bytes! 24 of these per. quarter note/96 per. measure.
65 #define VVMIDITickVal 0xF9 // no data bytes! when master clock playing back, sends 1 tick every 10ms.
66 #define VVMIDIStartVal 0xFA // no data bytes!
67 #define VVMIDIContinueVal 0xFB // no data bytes!
68 #define VVMIDIStopVal 0xFC // no data bytes!
69 #define VVMIDIUndefinedRealtime1Val 0xFD
70 #define VVMIDIActiveSenseVal 0xFE // no data bytes! sent every 300 ms. to make sure device is active
71 #define VVMIDIResetVal 0xFF // no data bytes! never received/don't send!
72 */
73 
74 typedef enum {
75  VVMIDIMsgUnknown = 0x00,
76  // these are all STATUS MESSAGES: all status mesages have bit 7 set. ONLY status msgs have bit 7 set to 1!
77  // these status messages go to a specific channel (these are voice messages)
78  VVMIDINoteOffVal = 0x80, // +2 data bytes
79  VVMIDINoteOnVal = 0x90, // +2 data bytes
80  VVMIDIAfterTouchVal = 0xA0, // +2 data bytes
81  VVMIDIControlChangeVal = 0xB0, // +2 data bytes
82  VVMIDIProgramChangeVal = 0xC0, // +1 data byte
83  VVMIDIChannelPressureVal = 0xD0, // +1 data byte
84  VVMIDIPitchWheelVal = 0xE0, // +2 data bytes
85  // these status messages go anywhere/everywhere
86  // 0xF0 - 0xF7 system common messages
87  VVMIDIBeginSysexDumpVal = 0xF0, // signals the start of a sysex dump; unknown amount of data to follow
88  VVMIDIMTCQuarterFrameVal = 0xF1, // +1 data byte, rep. time code; 0-127
89  VVMIDISongPosPointerVal = 0xF2, // + 2 data bytes, rep. 14-bit val; this is MIDI beat on which to start song.
90  VVMIDISongSelectVal = 0xF3, // +1 data byte, rep. song number; 0-127
91  VVMIDIUndefinedCommon1Val = 0xF4,
92  VVMIDIUndefinedCommon2Val = 0xF5,
93  VVMIDITuneRequestVal = 0xF6, // no data bytes!
94  VVMIDIEndSysexDumpVal = 0xF7, // signals the end of a sysex dump
95  // 0xF8 - 0xFF system realtime messages
96  VVMIDIClockVal = 0xF8, // no data bytes! 24 of these per. quarter note/96 per. measure.
97  VVMIDITickVal = 0xF9, // no data bytes! when master clock playing back, sends 1 tick every 10ms.
98  VVMIDIStartVal = 0xFA, // no data bytes!
99  VVMIDIContinueVal = 0xFB, // no data bytes!
100  VVMIDIStopVal = 0xFC, // no data bytes!
101  VVMIDIUndefinedRealtime1Val = 0xFD,
102  VVMIDIActiveSenseVal = 0xFE, // no data bytes! sent every 300 ms. to make sure device is active
103  VVMIDIResetVal = 0xFF, // no data bytes! never received/don't send!
104 } VVMIDIMsgType;
105 
106 
107 
108 
109 #import "VVMIDIMessage.h"
110 #import "VVMIDINode.h"
111 #import "VVMIDIManager.h"