midiOutShortMsg()also supports a running status as described in the MIDI file format specification. If running status is used, the command byte is omitted and the previously sent command byte is assumed. The lowest-order two bytes then become the data bytes and the highest-order two bytes are unused.
| 31 - 24 | 23 - 16 | 15 - 8 | 7 - 0 | ‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒‒ | Unused | Unused | Data 2 | Data 1 |
The following example demonstrates playing a single note (Middle-C) held for one second.
Note that the message parameter is in little-endian byte order. This is important because data in the MIDI file format is stored in big-endian format. When these values are read from the MIDI file they must be packed in the message in the correct order.
The lowest-order byte
0x90 is the MIDI
command for note-on (play note, key down, etc…). The next
0x3c is the first data parameter for the
note-on command. This is the actual note number for Middle-C.
The next byte
0x40 is the velocity for which
the note is played (e.g. how hard the key is pressed). The
highest order byte is not used and is set to 0.
This message will cause the note to start playing. In
order to hear the note we need to pause, in this case we
Sleep() for 1 second.