List all Musical Instruments
This program lists all available music instruments stored in the computer’s music synthesizer. When you click an entry in the list box, the instrument plays “Do-Re-Mi”. Additional controls are available for speed, octave, and volume.
The program shows how to assemble musical notes, and how to interact with list box and scroll bar controls.
See the SoundCheck program for a simpler program that lists and plays all available sounds, and FontCheck for a program that displays all available fonts installed on your computer.
InstrumentCheck.lgo
; Routine to review all the instruments
TO INSTRUMENTCHECK
IF MEMBER? "INSTRUMENTWINDOW EVERY "WINDOW SETACTIVEWINDOW "INSTRUMENTWINDOW STOP
DECLARE "GRAPHICS "INSTRUMENTWINDOW
PPROP "INSTRUMENTWINDOW "DRAWSIZE [400 250]
PPROP "INSTRUMENTWINDOW "POSITION [200 80]
PPROP "INSTRUMENTWINDOW "TITLE "|Instrument Check|
DECLARE "LISTBOX "INSTRUMENTS
PPROP "INSTRUMENTS "SIZE [160 200]
PPROP "INSTRUMENTS "TOOLTIP "|Click to play Do Re Mi with selected instrument|
PPROP "INSTRUMENTS "RUN [PLAY.SAMPLE]
DECLARE "BUTTON "INSTRUMENTCLOSE
PPROP "INSTRUMENTCLOSE "POSITION [140 60]
PPROP "INSTRUMENTCLOSE "TEXT "|Close|
PPROP "INSTRUMENTCLOSE "TOOLTIP "|Ends the program|
PPROP "INSTRUMENTCLOSE "RUN [ERASEO "INSTRUMENTWINDOW]
DECLARE "SCROLLBAR "IC.OCTAVE
PPROP "IC.OCTAVE "POSITION [140 27]
PPROPS "IC.OCTAVE [MINIMUM 0 MAXIMUM 6 VALUE 4 SMALLINC 1 LARGEINC 1]
PPROP "IC.OCTAVE "TOOLTIP "|Adjust octave size from 0 6|
PPROP "IC.OCTAVE "RUN [PLAY.SAMPLE]
DECLARE "SCROLLBAR "IC.VOLUME
PPROP "IC.VOLUME "POSITION [140 -16]
PPROPS "IC.VOLUME [MINIMUM 0 MAXIMUM 127 VALUE 65 SMALLINC 5 LARGEINC 20]
PPROP "IC.VOLUME "TOOLTIP "|Adjust volume level from 0 to 127|
PPROP "IC.VOLUME "RUN [PLAY.SAMPLE]
DECLARE "SCROLLBAR "IC.TEMPO
PPROP "IC.TEMPO "POSITION [140 -60]
PPROPS "IC.TEMPO [MINIMUM 80 MAXIMUM 300 VALUE 120 SMALLINC 10 LARGEINC 20]
PPROP "IC.TEMPO "TOOLTIP "|Adjust tempo (default is 120)|
PPROP "IC.TEMPO "RUN [PLAY.SAMPLE]
DECLARE "STATICTEXT "ST.OCTAVE
PPROP "ST.OCTAVE "POSITION [140 10]
PPROP "ST.OCTAVE "TEXT "|Octave 4|
PPROP "ST.OCTAVE "TOOLTIP "
PPROP "ST.OCTAVE "VALUE 4
DECLARE "STATICTEXT "ST.VOLUME
PPROP "ST.VOLUME "POSITION [140 -33]
PPROP "ST.VOLUME "TEXT "|Volume 65|
PPROP "ST.VOLUME "TOOLTIP "
PPROP "ST.VOLUME "VALUE 65
DECLARE "STATICTEXT "ST.TEMPO
PPROP "ST.TEMPO "POSITION [140 -77]
PPROP "ST.TEMPO "TEXT "|Tempo 120|
PPROP "ST.TEMPO "TOOLTIP "
PPROP "ST.TEMPO "VALUE 120
DECLARE "BUTTON "IC.RESET
PPROP "IC.RESET "POSITION [140 86]
PPROP "IC.RESET "SIZE [80 18]
PPROP "IC.RESET "TEXT "|Reset|
PPROP "IC.RESET "TOOLTIP "|Resets all values|
PPROP "IC.RESET "RUN [RESET.PLAY]
ignore ask "instruments [append "|00 Acoustic grand piano |]
ignore ask "instruments [append "|01 Bright acoustic piano |]
ignore ask "instruments [append "|02 Electric grand piano |]
ignore ask "instruments [append "|03 Honky-tonk piano |]
ignore ask "instruments [append "|04 Rhodes piano |]
ignore ask "instruments [append "|05 Chorused piano |]
ignore ask "instruments [append "|06 Harpsichord |]
ignore ask "instruments [append "|07 Clavinet |]
ignore ask "instruments [append "|08 Celesta |]
ignore ask "instruments [append "|09 Glockenspiel |]
ignore ask "instruments [append "|10 Music box |]
ignore ask "instruments [append "|11 Vibraphone |]
ignore ask "instruments [append "|12 Marimba |]
ignore ask "instruments [append "|13 Xylophone |]
ignore ask "instruments [append "|14 Tubular bells |]
ignore ask "instruments [append "|15 Dulcimer |]
ignore ask "instruments [append "|16 Hammond organ |]
ignore ask "instruments [append "|17 Percussive organ |]
ignore ask "instruments [append "|18 Rock organ |]
ignore ask "instruments [append "|19 Church organ |]
ignore ask "instruments [append "|20 Reed organ |]
ignore ask "instruments [append "|21 Accordion |]
ignore ask "instruments [append "|22 Harmonica |]
ignore ask "instruments [append "|23 Tango accordion |]
ignore ask "instruments [append "|24 Acoustic guitar (nylon) |]
ignore ask "instruments [append "|25 Acoustic guitar (steel) |]
ignore ask "instruments [append "|26 Electric guitar (jazz) |]
ignore ask "instruments [append "|27 Electric guitar (clean) |]
ignore ask "instruments [append "|28 Electric guitar (muted) |]
ignore ask "instruments [append "|29 Overdriven guitar |]
ignore ask "instruments [append "|30 Distortion guitar |]
ignore ask "instruments [append "|31 Guitar harmonics |]
ignore ask "instruments [append "|32 Acoustic bass |]
ignore ask "instruments [append "|33 Electric bass (finger) |]
ignore ask "instruments [append "|34 Electric bass (pick) |]
ignore ask "instruments [append "|35 Fretless bass |]
ignore ask "instruments [append "|36 Slap bass 1 |]
ignore ask "instruments [append "|37 Slap bass 2 |]
ignore ask "instruments [append "|38 Synth bass 1 |]
ignore ask "instruments [append "|39 Synth bass 2 |]
ignore ask "instruments [append "|40 Violin |]
ignore ask "instruments [append "|41 Viola |]
ignore ask "instruments [append "|42 Cello |]
ignore ask "instruments [append "|43 Contrabass |]
ignore ask "instruments [append "|44 Tremolo strings |]
ignore ask "instruments [append "|45 Pizzicato strings |]
ignore ask "instruments [append "|46 Orchestral harp |]
ignore ask "instruments [append "|47 Timpani |]
ignore ask "instruments [append "|48 String ensemble 1 |]
ignore ask "instruments [append "|49 String ensemble 2 |]
ignore ask "instruments [append "|50 Synth. strings 1 |]
ignore ask "instruments [append "|51 Synth. strings 2 |]
ignore ask "instruments [append "|52 Choir Aahs |]
ignore ask "instruments [append "|53 Voice Oohs |]
ignore ask "instruments [append "|54 Synth voice |]
ignore ask "instruments [append "|55 Orchestra hit |]
ignore ask "instruments [append "|56 Trumpet |]
ignore ask "instruments [append "|57 Trombone |]
ignore ask "instruments [append "|58 Tuba |]
ignore ask "instruments [append "|59 Muted trumpet |]
ignore ask "instruments [append "|60 French horn |]
ignore ask "instruments [append "|61 Brass section |]
ignore ask "instruments [append "|62 Synth. brass 1 |]
ignore ask "instruments [append "|63 Synth. brass 2 |]
ignore ask "instruments [append "|64 Soprano sax |]
ignore ask "instruments [append "|65 Alto sax |]
ignore ask "instruments [append "|66 Tenor sax |]
ignore ask "instruments [append "|67 Baritone sax |]
ignore ask "instruments [append "|68 Oboe |]
ignore ask "instruments [append "|69 English horn |]
ignore ask "instruments [append "|70 Bassoon |]
ignore ask "instruments [append "|71 Clarinet |]
ignore ask "instruments [append "|72 Piccolo |]
ignore ask "instruments [append "|73 Flute |]
ignore ask "instruments [append "|74 Recorder |]
ignore ask "instruments [append "|75 Pan flute |]
ignore ask "instruments [append "|76 Bottle blow |]
ignore ask "instruments [append "|77 Shakuhachi |]
ignore ask "instruments [append "|78 Whistle |]
ignore ask "instruments [append "|79 Ocarina |]
ignore ask "instruments [append "|80 Lead 1 (square) |]
ignore ask "instruments [append "|81 Lead 2 (sawtooth) |]
ignore ask "instruments [append "|82 Lead 3 (calliope lead) |]
ignore ask "instruments [append "|83 Lead 4 (chiff lead) |]
ignore ask "instruments [append "|84 Lead 5 (charang) |]
ignore ask "instruments [append "|85 Lead 6 (voice) |]
ignore ask "instruments [append "|86 Lead 7 (fifths) |]
ignore ask "instruments [append "|87 Lead 8 (brass + lead) |]
ignore ask "instruments [append "|88 Pad 1 (new age) |]
ignore ask "instruments [append "|89 Pad 2 (warm) |]
ignore ask "instruments [append "|90 Pad 3 (polysynth) |]
ignore ask "instruments [append "|91 Pad 4 (choir) |]
ignore ask "instruments [append "|92 Pad 5 (bowed) |]
ignore ask "instruments [append "|93 Pad 6 (metallic) |]
ignore ask "instruments [append "|94 Pad 7 (halo) |]
ignore ask "instruments [append "|95 Pad 8 (sweep) |]
PPROP "INSTRUMENTS "INDEX 0
END
TO PLAY.SAMPLE
FOREACH [INSTRUMENTS IC.OCTAVE IC.VOLUME IC.TEMPO] [
PPROP "? "ENABLED "FALSE
]
PPROP "ST.OCTAVE "TEXT WORD "|Octave | INT GPROP "IC.OCTAVE "VALUE
PPROP "ST.VOLUME "TEXT WORD "|Volume | INT GPROP "IC.VOLUME "VALUE
PPROP "ST.TEMPO "TEXT WORD "|Tempo | INT GPROP "IC.TEMPO "VALUE
PLAY (LIST "R WORD "I GET.INSTRUMENT WORD "O GET.OCTAVE WORD "V GET.VOLUME WORD "T GET.TEMPO "C "D "E)
FOREACH [INSTRUMENTS IC.OCTAVE IC.VOLUME IC.TEMPO] [
PPROP "? "ENABLED "TRUE
]
END
TO GET.INSTRUMENT
LOCAL "TEXT
MAKE "TEXT GPROP "INSTRUMENTS "TEXT
OUTPUT WORD (FIRST :TEXT) (FIRST BUTFIRST :TEXT)
END
TO GET.INSTRUMENT.NAME
LOCAL "TEXT
MAKE "TEXT GPROP "INSTRUMENTS "TEXT
OUTPUT BUTFIRST BUTFIRST BUTFIRST :TEXT
END
TO GET.OCTAVE
OUTPUT INT GPROP "IC.OCTAVE "VALUE
END
TO GET.VOLUME
OUTPUT INT GPROP "IC.VOLUME "VALUE
END
TO GET.TEMPO
OUTPUT INT GPROP "IC.TEMPO "VALUE
END
TO RESET.PLAY
PPROP "IC.VOLUME "VALUE 65
PPROP "IC.OCTAVE "VALUE 4
PPROP "IC.TEMPO "VALUE 120
PPROP "INSTRUMENTS "INDEX 0
PLAY.SAMPLE
END
BURY [INSTRUMENTCHECK PLAY.SAMPLE GET.INSTRUMENT GET.INSTRUMENT.NAME GET.OCTAVE GET.VOLUME GET.TEMPO RESET.PLAY]
INSTRUMENTCHECK
Procedure | INSTRUMENTCHECK |
Description | Lists and plays all available music instruments |
Level | Intermediate |
Tags | Controls, Music, Instruments, Play |