User Tools

Site Tools


MIDI Tracker

There is a second page
A thing I am wondering if it is feasible to do?
I found this MIDI Library: JDKSmidi


Somewhat ambitious - but if you don't ask you don't get.

- Parse a MIDI file
- Parse a real-time MIDI stream
- Port to Arduino board. Overview


Here's an online book in the Uni. Library 'Midi Power!'

It doesn't have to be Arduino - perhaps a laptop could do it using the above JDKSmidi library?

MIDI Power! : The Comprehensive Guide (2nd Edition)

Guerin, Robert. MIDI Power! : The Comprehensive Guide (2nd Edition).
Boston, MA, USA: Course Technology / Cengage Learning, 2005. p 7.
Copyright © 2005. Course Technology / Cengage Learning. All rights reserved.


MIDI sends information at a rate of 31,250 bps (or bits per second (Baud)).
Every byte in a MIDI message uses 10 bits of data (8 bits for the information and 2 bits for error correction).
Thus MIDI sends about 3,125 bytes/second (31,250 bps divided by 8 bits to convert into bytes).
Up to 500 MIDI notes per second.
It takes about one millisecond to transmit a single note.
The threshold for distinguishing individual sound events is roughly 10 milliseconds,
so you'll perceive with 10 or more simultaneous events.

The five pins in the MIDI connector are not all active. As mentioned earlier, MIDI sends information using a serial transmission protocol, so in reality, only one of the five pins is sending the actual MIDI information. Table 1.1 describes each pin in the MIDI connector and its purpose.
Table. 1.1 MIDI Pin Description

Pin No. Description (see Figure 1.6)
1 Not used; in most MIDI cables, this pin is not even connected to a wire.
2 This is used as electrical shielding (ground). This shielding protects the MIDI cable from transmitting undesirable electrical or radio interference.
3 Like Pin 1, Pin 3 is not used, and in most MIDI cables it is not connected to a wire.
4 This is the actual MIDI data receiver. Information on this cable flows in one direction only.
5 This is the actual MIDI data transmitter. As with Pin 4, the information on this cable flows in one direction

The Standard MIDI File comes in three formats, which are described in the following table.
Table. 1.2 Standard MIDI File Format Types Explained

MIDI Type Number of Tracks Contains All MIDI Messages Number of Songs, Patterns, or Musical Performance Saved in the File
11 per channelyes1
21 per channelyesunlimited

Basic MIDI messages

TypeDecimal RangeBinary Range
Status128-2551000 0000 to 1111 1111MSBit is always 1
Data0-1270000 0000 t0 0111 1111MSBit is always 0

A MIDI device receives the following three values: 190, 245, and 98. It will interpret the first number (190) as a Status byte, and since the second one is also between 128 and 255, it too will be considered a Status byte. However, the last value (98) will be interpreted as the Data byte for the number 245.s Status byte.

The MIDI specification PDF is in the Dropbox under ref\music

The last four bits of the status byte represent the channel 0 - f

Types of message

  • Channel Voice messages are the basic MIDI events representing a musical performance. The most common channel voice messages are Note On and Note Off.
  • Channel Mode messages tell devices to send or receive information in a certain way, which is defined by the mode being sent. An example of this would be to turn all sounds off or all notes off.
  • System Common messages are, as the name would suggest, common to all instruments, devices, or software in your MIDI setup. Sequencers use system common messages for MIDI time references (through MIDI Time Code), song position, song selection, and tuning.
  • System Real Time messages are synchronization commands used by MIDI to control sequences, such as Start and Stop commands imbedded as a MIDI command, along with the MIDI Timing Clock.
  • System Exclusive messages are used to send or receive instrument settings such as patch or performance memories. You can also use System Exclusive (SysEx) messages to transfer sample waveforms via MIDI along with other non-music related functions or use SysEx messages to record parameter automations on software synthesizers using a remote MIDI controller.

Note ON with a velocity of 0 respresents Note OFF (hence velocities must be between 1-127).
A Channel voice meesage example - three bytes

3 bytes Note onChannel#NoteVelocity
MIDI ValuesNoteOnChnl.360100
Binary100100100011 11000110 0100

…and the equivalent note off

3 bytes Note onChannel#NoteVelocity
MIDI ValuesNoteOnChnl.3600
Binary100100100011 11000000 0000

Pitch bend

Uses two data bytes and covers -8192 t0 8191. These are interpreted as a percentage of the set PB Range.

Byte 1 (LSB) Byte 2 (MSB)Interpretation
164One above 0
12763One below 0

Thus 0-127 thru 64-64Doesn't make much sense to me 7F = 127 = 1111 1110

Control Change

Channel Voice messages are 0-119 Control Change run from 120-127

Channel MODE messages

Four modes Omni-on Omni-off Poly Mono

System Common messages

Usually synchronaisation - song position; tuning, something broadcast to all instruments.
These include:

MTC - MIDI Time-code Quarter Frame

MTC is an alternative to MIDI Timing Clock (confusingly also MTC and so referred to as Timing Clock).
MTC is meant for video synchronization and refers to a fixed time or absolute reference. Timing Clock is a relative reference: It is relative to the tempo of a sequence, since it subdivides each beat into 24 ticks (ticks are sub-divisions of beats), no matter the tempo of the sequence.

The MTC message contains only one Data byte that holds the type of time code and the value for the time address. This message is called Quarter Frame because each message contains a quarter of the information: In the first MIDI message, it gives the hour value, the second represents the minutes, the third represents the seconds, and the fourth gives the frame number. In other words, it takes four MIDI messages (each one containing a Status byte and a Data byte) to represent a full SMPTE time.

Song Position Pointer (SPP)

What the SPP message does is simple: It gives an address to each 16th note step in a song, starting with beat 0 at the beginning.
SPP messages don't tell the sequence to start or stop, but rather tell the devices where to start again once stopped.
This 16th note step is set every six MIDI Timing Clocks from the start of the sequence.
Since there are 24 ticks per beat and the SPP identifies every sixth one, i.e. four SPP addresses per beat, or one SPP address per 16th note (24 ticks/6 ticks = 4 times per beat or quarter note = 1 16th note).
It uses two data bytes and can thus accommodate 1024 bars in 4/4 time.
In 4/4 goto Beat 2 of Bar 33:
32bars * 4 beats * 4 sixteenths = 512
plus 1beat * 4sixteenths = 4
TOTAL 516 + 1 to get onto the second beat thus, 517.
This is represented in MSB LSB format as follows
LSB 0000 0000
LSB 0000 0000
0000 0010 0000 0101
LSB 0000 0000

Tune request

Just tells the instrument to recallibrate itself.

EO SysEx

Full-stop on a SysEx dump.

System Real-time Messages

Imagine the stick is a System Common message and the rubber band is a Real Time message. Now, stretch the rubber band; notice that the markings on the rubber band no longer match up with the markings on the stick. Notice also that the spaces separating the marks are still of equal distance in relation to each other. There lies the difference between these two types of synchronizing messages: One is relative to the tempo of a sequence, the other is absolute and will not vary with the tempo of the sequence.
There are six types:

Timimg Clock

Sent 24 times per beat

Active Sensing

Reassuring pulses that the channel is live - every 300ms. If connections fails an the pulse is not received in this time the the receiver knows things are broken and it should stop sounding the notes.

System Reset

Does what is says on the tin. No particiiular instrumrent there is only a status byte

System Exclusive (SysEx) Messages

Following hand-shaking, each data byte must be accompanied by a Status Byte identifying it as SysEx Data, or it is automatically assumed the SysEx data is complete.

Note numbers

System Reset

Does what is says on the tin. No particiiular instrumrent there is only a status byte

Note numbers

Discrepancy lies in the octave number. Roland documentation always refers to middle C as C4, while Yamaha refers to the same note as C3. The MIDI protocol assigns the MIDI note number 60 to middle C.

Table 3.1 List of Control Change Names in Alphabetical Order
All Notes offModulation wheel
All Sound OffNon-Registered Parameter Number
BalanceOmni mode off (+ all notes off)
Bank SelectOmni mode on (+ all notes off)
Breath ControlPan
Channel Volume (formerly Main Volume)Poly mode on (incl mono=off +all notes off)
Damper Pedal On/Off (Sustain)Poly mode on/off (+ all notes off)
Data EntryPortamento Control 1 & 2
Effect ControlPortamento On/Off
Effects 1. 5 (Reverb Send and Chorus Send Effect)Portamento time
Expression ControllerRegistered Parameter Number
Foot ControllerReset All Controllers
General Purpose Controller 1 to 8Soft pedal On/Off
Hold 2Sound Controller 1 to 10
Local Control On/OffSustenuto On/OfF

All Control messages have three bytes of information. You will see later that some Control changes use two sets of Control Change messages to add a level of precision to the position of the controller. However, the principle of identifying each byte remains the same, no matter how many Control Messages are sent.

Some Control Change Messages are high-def, and so require 2 messages - e.g. Bank Select requires 0x0 and 0x20 (0,32 dec)

Control change heirarchy

Control Change Messages
+-- Continuous Controllers
|     +--- HiRes (0-63)
|     |	  +- MSB Controller (0-31)
|     |	  +- LSB Controller (MSB Subset 32-63)
|     |
|     +--- LoRes (70-101)
+-- Switch Controllers (64-69)
+-- Channel Mode Controllers (102-127)
programming/miditracker.txt · Last modified: 2020/04/08 00:24 (external edit)