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'.

midi1.gif (661 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.

midi2.gif (27742 bytes)

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
16 -    Hammond Organ
17 -    Percussive Organ
18 -    Rock Organ
19 -    Church Organ
20 -    Reed Organ
21 -    Accordian
22 -    Harmonica
23 -    Tango Accordian

Guitar
24 -    Acoustic Guitar (nylon)
25 -    Acoustic Guitar (steel)
26 -    Electric Guitar (jazz)
27 -    Electric Guitar (clean)
28 -    Electric Guitar (muted)
29 -    Overdriven Guitar
30 -    Distortion Guitar
31 -    Guitar Harmonics

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
40 -    Violin
41 -    Viola
42 -    Cello
43 -    Contrabass
44 -    Tremolo Strings
45 -    Pizzicato Strings
46 -    Orchestral Harp
47 -    Timpani

Ensemble
48 -    String Ensemble 1
49 -    String Ensemble 2
50 -    Synth Strings 1
51 -    Synth Strings 2
52 -    Choir Aahs
53 -    Voice Oohs
54 -    Synth Voice
55 -    Orchestra Hit

Brass
56 -    Trumpet
57 -    Trombone
58 -    Tuba
59 -    Muted Trumpet
60 -    French Horn
61 -    Brass Section
62 -    Synth Brass 1
63 -    Synth Brass 2

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
80 -    Lead 1 (square)
81 -    Lead 2 (sawtooth)
82 -    Lead 3 (caliope lead)
83 -    Lead 4 (chiff lead)
84 -    Lead 5 (charang)
85 -    Lead 6 (voice)
86 -    Lead 7 (fifths)
87 -    Lead 8 (brass + lead)

Synth Pad
88 -    Pad 1 (new age)
89 -    Pad 2 (warm)
90 -    Pad 3 (polysynth)
91 -    Pad 4 (choir)
92 -    Pad 5 (bowed)
93 -    Pad 6 (metallic)
94 -    Pad 7 (halo)
95 -    Pad 8 (sweep)

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
104 -    Sitar
105 -    Banjo
106 -    Shamisen
107 -    Koto
108 -    Kalimba
109 -    Bagpipe
110 -    Fiddle
111 -    Shanai

Percussive
112 -    Tinkle Bell
113 -    Agogo
114 -    Steel Drums
115 -    Woodblock
116 -    Taiko Drum
117 -    Melodic Tom
118 -    Synth Drum
119 -    Reverse Cymbal

Sound Effects
120 -    Guitar Fret Noise
121 -    Breath Noise
122 -    Seashore
123 -    Bird Tweet
124 -    Telephone Ring
125 -    Helicopter
126 -    Applause
127 -    Gunshot

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


Return to Music Page