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?

Matt
  • 1,996
  • 5
  • 18
  • 24

6 Answers6

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

Brad
  • 159,648
  • 54
  • 349
  • 530
  • 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. – Dan Rosenstark Feb 11 '12 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.

Jonathan Grynspan
  • 43,286
  • 8
  • 74
  • 104
  • 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 '11 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. – Jonathan Grynspan Feb 24 '11 at 16:04
  • Wouldn't that be the case no matter how many bits were used? If 8 bits were used and we had 256 different values, then wouldn't 256 still be mapped to 21kHz? That is, if we had 8 bits wouldn't MIDI have just doubled the density of notes rather than covering a greater frequency range? – Matt Feb 24 '11 at 16:08
  • 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. – Jonathan Grynspan Feb 24 '11 at 16:27
  • Ah yes that is an issue. So then returning to the original consideration of the number of bits, did it just work out nicely that 7 bits offered a note set that matches western harmony? or was this a conscious consideration that actually drove the decision to define the protocol in terms of 7 bits for note values (as opposed, lets say, to 8 bits or 6 bits, etc)? – Matt Feb 24 '11 at 16:32
  • 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. – Jonathan Grynspan Feb 24 '11 at 16:40
  • Actually MIDI pitch values and frequencies have absolutely nothing to do with each other. The synthesizer can produce whatever frequencies it wants for a given pitch value. Furthermore, most adults can hear a whole octave above 10kHz... all the way to 20kHz. Usually though not as easy with just tones. As you get older, yes, these frequencies roll off. – Brad Feb 25 '11 at 14:16
  • I did say *many* adults. There are millions in the US alone with hearing limitations. – Jonathan Grynspan Feb 25 '11 at 19:35
  • There are certainly instruments that don't follow the general pattern of note assignment (percussion instruments come to mind) but I was speaking in the general case--any melodic MIDI instrument is going to have notes arranged in order, and due to the logarithmic scale of music, they're going to run out of audible notes on either end after only so many. – Jonathan Grynspan Feb 26 '11 at 14:22
  • MIDI is transmitted over slow channels to small-brained devices. Every byte does, and always will, matter! – XTL Dec 28 '11 at 09:49
  • 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. – Dan Rosenstark Jun 24 '12 at 13:51
  • @Yar: I was directly answering the question that was posed. Nobody asked anything about status bytes. :) – Jonathan Grynspan Jun 24 '12 at 14:34
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.

3

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!

wyleu
  • 59
  • 4
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.

0

127 is enough to cover all piano keys

Luca Rocchi
  • 6,272
  • 1
  • 23
  • 23
  • Where did you find a piano with 104 keys? Most have 88. Even the Bösendorfer Imperial only has 97. – SSteve Jul 25 '12 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 :) – Luca Rocchi Jul 26 '12 at 20:19