MIDI - Musical Instrument Digital Interface
Also See: http://midipads.homestead.com/
Most sounds used on computers are the result of converting sound pulses ("waves") into digital format. The process is called Analogue to Digital conversion, or "AtoD conversion".
Analogue to Digital Conversion changes sound 'waves' into digital 'bytes'. |
|
![]() Analogue Waves |
01001010 10010010 01011001 10011011 10001010 11101001 ....... Digital Bytes |
MP3 and ".WAV" files are produced by using AtoD conversion processes. The sound existed originally and was converted into a format for storage and reproduction on a computer. MIDI files are different.
A MIDI file never really existed as a 'true' sound. MIDI is a set of definitions that describe the sound, rather than a recording of it. MIDI files contain information that represent sounds as a set of 'descriptions', or "messages". MIDI devices convert these 'messages' into sound.
The MIDI specification originated in the early eighties and is now well established. Many electronic musical instruments have built-in MIDI 'synthesizers' that can read and write MIDI instructions. Most computer "sound cards" are able to make use of the MIDI standard.
MIDI Terms:
Channel: A channel is a number from 0-15 which
corresponds to channels 1-16.
Pitch: A pitch is a number from 0-127 and corresponds to a note on the
instrument.
Velocity: A velocity is a number from 0-127 and corresponds to how fast
the key (or string) is pressed or released (most terminology is in reference to
keyboards). 0 means is released. For simplicity you can think of "velocity" as
meaning "volume", but keep in mind that it is not quite that simple.
Pressure: A pressure is a number from 0-127 and corresponds to the
characteristics of how the key is hit.
Program: A program is a number from 0-127 and corresponds to the
instrument to use. The term "program" can also be thought of as meaning
"voice", or "instrument". See below:
TABLE 1 MIDI "programs" - from the MSW Logo HELP files. | |||
Piano 0 - Acoustic Grand Piano 1 - Bright Acoustic Piano 2 - Electric Grand Piano 3 - Honky-tonk Piano 4 - Rhodes Piano 5 - Chorused Piano 6 - Harpsichord 7 - Clavinet Chromatic Percussion 8 - Celesta 9 - Glockenspiel 10 - Music box 11 - Vibraphone 12 - Marimba 13 - Xylophone 14 - Tubular Bells 15 - Dulcimer Organ Guitar |
Bass 32 - Acoustic Bass 33 - Electric Bass (finger) 34 - Electric Bass (pick) 35 - Fretless Bass 36 - Slap Bass 1 37 - Slap Bass 2 38 - Synth Bass 1 39 - Synth Bass 2 Strings |
Reed 64 - Soprano Sax 65 - Alto Sax 66 - Tenor Sax 67 - Baritone Sax 68 - Oboe 69 - English Horn 70 - Bassoon 71 - Clarinet Pipe 72 - Piccolo 73 - Flute 74 - Recorder 75 - Pan Flute 76 - Bottle Blow 77 - Shakuhachi 78 - Whistle 79 - Ocarina Synth Lead |
Synth Effects 96 - FX 1 (rain) 97 - FX 2 (soundtrack) 98 - FX 3 (crystal) 99 - FX 4 (atmosphere) 100 - FX 5 (brightness) 101 - FX 6 (goblins) 102 - FX 7 (echoes) 103 - FX 8 (sci-fi) Ethnic |
Note: The term "program" is also used to mean "voice", or "instrument".
TABLE 2 MIDI Command Codes - from the MSW Logo HELP files. |
|||
COMMAND NAME | COMMAND CODE | STATUS BYTE | DATA BYTE |
Note Off Note On Poly Pressure Control Change Program Change Channel Pressure Pitch Wheel System Exclusive Undefined Song Position Song Select Undefined Undefined Tune Request End of Exclusive Timing Clock Undefined Start Continue Stop Undefined Active Sensing System Reset |
128 + Channel 144 + Channel 160 + Channel 176 + Channel 192 + Channel 208 + Channel 224 + Channel 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
0-127 Pitch 0-127 Pitch 0-127 Pitch 0-127 MIDI Control 0-127 Program ("Voice") 0-127 Pressure 0-127 LSB 0-127 Id Code Not used 0-127 LSB 0-127 Song Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used |
0-127 Velocity 0-127 Velocity 0-127 Pressure 0-127 MSB Not used Not used 0-127 MSB Any number of bytes Not used 0-127 MSB Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used Not used |
NOTE: The following notes assume you are using MSW Logo as your control language.
Structure of a MIDI Message -
MIDI messages are made up of a "Command Code" and two 'bytes'. (A byte is just a computer 'word'. A typical 8-bit byte would be: 10011010.) The first byte is called the Status Byte and the second is called the Data Byte.
A typical MIDI message is of the form:
MIDI_Output <CommandCode + Channel> <Status Byte> <Data Byte>
In MSWLogo this would be along the lines of: MIDIMESSAGE (LIST 144+3 50 100) An alternative to the 'list' form of the command is MIDIMESSAGE [147 50 100] The 'list' form is used to clarify the Command Code.
Changing Instruments (or "programs", or "voices") -
To change to a different instrument you must issue a "Program Change" command using:
MIDIMESSAGE (LIST 192+3 <program code*>)
NOTE: The "program code" is the decimal number representing the 'instrument, or 'voice' as in Table 1 above.
Sample MSW Logo MIDI Code -
to sample1
;
; Sample code to demonstrate simple MIDI commands.
; This code will set up channel 3 to play the Sitar (Ethnic 104)
; at a 'pitch' of 50 and a velocity
of 100.
; NOTE: In MIDI terms the word "velocity" refers to how fast a
; keyboard key is hit. You can think of it as meaning "volume".
;
; NOTE: You must begin your MIDI session by turning
; on MIDI functionality using: print midiopen
; You must turn MIDI off again when you have finished
; with the command: midiclose
;
print midiopen
midimessage (list 192+3 104)
midimessage (list 144+3 50 100)
; Don't forget to issue a midiclose command when you have
finished.
end
More Sample MSW Logo MIDI Files -
midi1.LGO - Basics of using MIDI with buttons in MSW Logo
midi2.LGO - Controlling one channel.
midi3.LGO - Template code for a single channel MIDI system
midi4.LGO - A four channel MIDI system