MP3 to MIDI Pitch Bend and Tuning: What the Note Number Leaves Out
The note number is not the pitch. A MIDI file holds 128 of them, but the format also carries a fourteen-bit pitch wheel and tuning messages that move a channel off the equal-tempered grid. Two files with identical note numbers can sound in different keys.
Pitch, answered
- 128 note numbers, 16,384 wheel positions. A note number is seven bits. The pitch wheel is fourteen, so it has 128 positions for every pitch the file can name.
- The wheel's range is not in the format. The specification says the wheel's sensitivity is a function of the transmitter, so one bend means different intervals on different devices.
- A channel can be retuned. General MIDI standardises coarse and fine tuning messages, so the A440 reference that every note-to-hertz conversion assumes is a value the file can change.
- Tuning is a parameter, not a note. Its value goes to whichever parameter was selected last, which is why the sequence ends with an explicit de-select.
A note number is seven bits; the wheel is fourteen
A Note On message is written 1001nnnn, a channel and a seven-bit key number, which gives 128 pitches to choose from. A Pitch Wheel Change is written 1110nnnn with two data bytes, a least and a most significant byte, and the specification calls the result a fourteen bit value: 16,384 positions, 128 of them for every note number the file can name.
Its neutral position is 2000H, which is 8,192, one step above the middle: values 0 through 8,191 sit below it, 8,193 through 16,383 above.
The wheel's range is left to the device
The specification fixes the wheel's resolution and declines to fix its interval: sensitivity, it says, is a function of the transmitter. Nothing in the message states how far a bend travels, so two files can carry the same note numbers and the same wheel bytes and still play in different keys.
General MIDI keeps the missing number as a parameter. Pitch bend range is registered parameter 0,0, so the wheel's reach is data a file can carry; a file that bends without setting it leaves the interval to the receiving device.
Tuning moves a whole channel
The same parameter list holds two tuning entries, channel fine tuning at 1,0 and channel coarse tuning at 2,0. Both act on a channel rather than a note, so a retuned part moves all at once.
The specification's own example sets coarse tuning to A440 with the sequence 101:0, 100:2, 6:64, 101:127, 100:127, which makes 64 the A440 reference for that parameter. Every conversion from a note number to a frequency assumes a reference, and the tool jukeblocks publishes asks you to set your A4 reference, defaulting to 440 Hz. In a MIDI file that reference is data the file can carry.
Selecting a parameter takes three messages, and the last is a de-select
Registered parameters are set in three steps: two Control Change messages using controller numbers 101 and 100 to select the parameter, then any number of Data Entry messages of one or two bytes, controller 6 carrying the most significant and 38 the least, and finally an End of RPN message.
Because the two Data Entry controllers are shared, a value lands on whichever parameter is selected at the time, and that selection survives until the third step clears it. Two seven-bit selectors give 16,384 possible slots, of which seven are standardised, the last being the null that closes the sequence.
What a pitch claim has to produce
songscription's comparison page praises a free converter for detecting pitch bends. In file terms that is a 1110nnnn message rather than an extra note, and it belongs to a channel. A file carrying bends but no pitch bend range parameter has not said how far they reach.