Gardner Lab

Psychology Department

Neurosciences Institute

Stanford University


Sound functions

mglInstallSound: Install an .aiff file for playing with mglPlaySound

purpose: Install an .aiff file for playing with mglPlaySound
usage: mglInstallSound(soundName)

argument value
soundName aiff filename

This will install sounds to be played using mglPlaySound. Note that if you just want to use systems sounds then you do not need to call this function directly, it will be called by mglOpen to install all your system sounds. Once the sound is installed you can play it with mglPlaySound

soundNum = mglInstallSound('/System/Library/Sounds/Submarine.aiff');

With no arguments, mglInstallSound uninstalls all sounds


Version 2.0

You can also specify a directory of sound files to install:


which will install all sounds named *.aif or *.aiff. You can play the sounds by specifying the name of the file (without the file extension):


mglPlaySound: Play a system sound

purpose: Play a sound
usage: mglPlaySound(soundNum)

argument value
soundNum number of sound

Plays a system sound. After calling mglOpen, all of the system sounds will be installed and you can play a specific one as follows:

global MGL;

With no arguments mglPlaySound plays the system alert sound


Note that this function returns right after it starts playing the sound (it does not wait until the sound finishes playing).