List all Sounds
This program creates a small window with a listbox containing all available sounds. Clicking a sound causes the sound to be played. The program is a great example of how to create and to use controls.
See the InstrumentCheck program for a more compex set of controls that plays every instrument available in the computer’s music synthesizer, and FontCheck for a program that displays all available fonts installed on your computer.
SoundCheck.lgo
; Routine to review all the sound files
TO SOUNDCHECK
IF MEMBER? "SOUNDWINDOW EVERY "WINDOW SETACTIVEWINDOW "SOUNDWINDOW STOP
DECLARE "GRAPHICS "SOUNDWINDOW
PPROP "SOUNDWINDOW "DRAWSIZE [400 250]
PPROP "SOUNDWINDOW "POSITION [120 30]
PPROP "SOUNDWINDOW "TITLE "|Sound Check|
DECLARE "LISTBOX "SOUNDS
PPROP "SOUNDS "SIZE [200 250]
PPROP "SOUNDS "RUN [PLAY GPROP "SOUNDS "TEXT]
PPROP "SOUNDS "TOOLTIP "|Click to play sound|
DECLARE "BUTTON "SOUNDCLOSE
PPROP "SOUNDCLOSE "POSITION [150 0]
PPROP "SOUNDCLOSE "TEXT "|Close|
PPROP "SOUNDCLOSE "RUN [ERASE "SOUNDWINDOW]
PPROP "SOUNDCLOSE "TOOLTIP "|Ends the program|
FOREACH (DIR "|~home/Sounds/*.wav|) [
IGNORE ASK "SOUNDS [ADDSORTED UPPERCASE BL BL BL BL "?]
]
IGNORE ASK "SOUNDS [APPEND "|Logo's error sound|]
SETACTIVEWINDOW "SOUNDWINDOW
END
BURY [SOUNDCHECK]
SOUNDCHECK
Procedure | SOUNDCHECK |
Description | Lists and plays all available sounds |
Level | Intermediate |
Tags | Controls, Sounds, Play |