11

Is the 127 note values in MIDI musically significant (certain number of octaves or something)? or was it set at 127 due to the binary file format, IE for the purposes of computing?

6 Answers 6

23

In the MIDI protocol there are status bytes (think commands, such as note-on or note-off) and there are data bytes (think parameters, such as pitch value and velocity). The way to determine the difference between them is by the first bit. If that first bit is 1, then it is a status byte. If the first bit is 0, then it is a data byte. This leaves only 7 bits available for the rest of the status or data byte value.

So to answer your question in short, this has more to do with the protocol specification, but it just so happens to nicely line up to good number of available pitch values.

Now, these pitch values do not correspond to specific pitches. Yes it is true that typically a pitch value of 60 will give you C4, or middle C. Most synths work this way, but certainly not all. It isn't even a requirement that the synth uses the pitch value for pitches! MIDI doesn't care... it is just a protocol. You may be wondering how alternate tunings work... they work just fine. It is up to the synthesizer to produce the correct pitches for these alternate tunings. MIDI simply provides for a selection of 128 different values to be sent.

Also, if you are wondering why it is so important for that first bit to signify what the data is... There are system realtime messages that can be interjected in the middle of some other command. These are things like the timing clock which is often used to sync up LFOs among other things.

You can read more about the types of MIDI messages here: http://www.midi.org/techspecs/midimessages.php

1
  • 1
    +1 I might tattoo that first paragraph on the back of my hand :) ... Regarding pitches: I'm just speculating, but I think that it's NOT a coincidence that you can fit 10+ octaves of 12 tones in 0-127. Feb 11, 2012 at 17:14
8

127 = 27 - 1

It's the maximum positive value of an 8-bit signed integer, and so is a meaningful limit in file formats--it's the highest value you can store in a byte (on most systems) without making it unsigned.

12
  • 1
    Thanks for the response - I'm familiar with the binary significance, I was just told by someone that it was set to 128 for some audio-based reason but I felt confident that it was really just a computer consideration....so you're confirming that it was a decision based on computing logistics and not anything to do with audio like a certain number of octaves or any harmonic purposes?
    – Matt
    Feb 24, 2011 at 15:46
  • Well, note 127 in MIDI is about 12.5 kHz. That's very high, and would sound like a high-pitched squeal to most ears, if it could be heard at all (many adults can't hear noises above 10kHz.) So more notes at the high end would be wasteful, and more notes at the low end would be impossible to produce on most consumer audio hardware. Feb 24, 2011 at 16:04
  • 1
    No, because notes in Western notation have specific frequencies. That is, middle C is precisely 261.626Hz, middle C# is precisely 277.183Hz, and so forth. G9, the highest MIDI note, is always 12.544kHz. Interpolating extra notes would not serve a meaningful purpose because such notes are not used in Western music. Such notes exist, but they're irrelevant to MIDI. Feb 24, 2011 at 16:27
  • 1
    Probably a bit of both. The history of MIDI is long and winding. The format is quite old, and dates back to a time when every byte of memory mattered. Feb 24, 2011 at 16:40
  • 4
    I didn't downvote this answer at the time, and in fact upvoted it, but I can't figure out why. You don't even mention the status byte. You might want to look at @Brad's answer below and perhaps cop a few licks from it. This answer, as it stands, while it's right, doesn't explain anything. Jun 24, 2012 at 13:51
5

I think what you are missing is that MIDI was created in the early 1980's, not to run on personal computers, but to run on musical instruments with extremely limited processing and storage capabilities. Storing 127 values seemed GIANT back then, especially when the largest keyboard typically has only 88 keys, and most electronic instruments only had 48. If you think MIDI is doing something in a strange way, it is likely that stems from its jurassic heritage.

Yes it is true that typically a pitch value of 60 will give you C4, or middle C. Most synths work this way, but certainly not all.

Yes ... there has always been a disagreement about where middle C is in MIDI. On Yamaha keyboards it is C3, on Roland keyboards it is C4. Yamaha did it one way and Roland did it another.

Now, these pitch values do not correspond to specific pitches.

Not originally. However, in the "General MIDI" standard, A = 440, which is standard tuning. General MIDI also describes which patch is a piano, which is a guitar, and so on, so that MIDI files become portable across multitimbral sound sources.

4

Simple efficiency.

As a serial protocol MIDI was designed around simple serial chips of the time which would take 8 data bits in and transmit them as a stream out of one separate serial data pin at a proscribed rate. In the MIDI world this was 31,250 Hz. It added stop and start bits so all data could travel over one wire. It was designed to be cheap and simple and the simplicity was extended into the data format.

The most significant bit of the 8 data bits was used to signal if the data byte was a command or data. So- To send Middle C note ON on channel 1 at a velocity of 56 A command bytes is sent first and the command for Note on was the upper 4 bits of that command bit 1001. Notice the 1 in the Most significant bit, this was followed by the channel ID for channel 1 0000 ( computers preferring to start counting from 0)

10010000 or 128 + 16 = 144

This was followed by the actual Note data

72 for Middle C or 01001000

and then the velocity data again specified in the range 0 -127 with a 0 MSB

56 in our case

00111000 So what would go down the wire (ignoring stop start & sync bits was)

144, 72, 56

For the almost brain dead microcomputers of the time in electronic keyboards the ability to separate command from data by simply looking at the first bit was a godsend.

As has been stated 127 bits covers pretty much any western keyboard you care to mention. So made perfectly logical sense and the protocols survival long after many serial protocols have disappeared into obscurity is a great compliment to http://en.wikipedia.org/wiki/Dave_Smith_(engineer) Dave Smith of Sequential Circuits who started the discussions with other manufacturers to set all this in place.

Modern music and composition would be considerably different without him and them.

Enjoy!

0

127 is enough to cover all piano keys

2
  • Where did you find a piano with 104 keys? Most have 88. Even the Bösendorfer Imperial only has 97.
    – SSteve
    Jul 25, 2012 at 14:31
  • to be honest now i can't say how 104 cames to my mind, i m not a pianist (but i have programmed C midi software for years ) .. anyway you are right i have changed my answer stating 127 is enough for piano keys :) Jul 26, 2012 at 20:19
0

0 ~ 127 fits nicely for ADC conversions.

Many MIDI hardware devices rely on performing Analog to Digital conversions (ADC). Considering MIDI is a real time communication protocol, when performing an ADC conversion using successive-approximation (a commonly used algorithm), a good rule of thumb is to use 8 bit resolution for fast computation. This will yield values in the 0 ~ 1023 range, which can be converted to MIDI range by dividing by 8.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.