The [soundRef] command.
Introduction
The soundRef command lets you create and manipulate sound objects in
Alpha.
Synopsis
The formal syntax of the [soundRef] command is:
soundRef subcommand ?options? |
The possible subcommands are described below. Depending on the subcommand,
various options can be additionally specified.
The [create] subcommand
This subcommand creates a new sound object. It has the following syntax:
soundRef create (-data bin|-file str|-name str|-url str)
The [soundRef create] command returns a token used in the other
subcommands to uniquely identify the sound. One of the options -data,
-file, -name or -url must be specified.
Here is the description of the various options:
- the -data option lets you specify binary data corresponding
to the sound.
- the -file option lets you specify the name of a file
containing the sound. The value can be a full or relative path name
specifying the file with the desired sound data.
- the -name option lets you specify a sound by name.
- the -url option lets you specify a sound by its URL.
The -name option searches for named sounds in several places,
returning the first sound it finds matching the given name. The preferred
way to locate a sound is to pass a name without the file extension. The
order of the search is as follows:
- Search for an object whose name was set explicitly.
- Search the Application Kit framework for a system sound with the specified name.
The system sounds located in /System/Library/Sounds have been named by
the Application Kit using their filenames without the file extension. See
the table below.
- Search the application's main bundle for a file whose name matches the
specified string.
If no sound file can be located in the application bundle,
the following directories are searched in order:
- ~/Library/Sounds
- /Library/Sounds
- /Network/Library/Sounds
- /System/Library/Sounds
Here is, for instance, the list of sounds found in the
/System/Library/Sounds folder (as of Mac OS X 10.9, it may differ on
different versions of the system):
Basso |
Blow |
Bottle |
Frog |
Funk |
Glass |
Hero |
Morse |
Ping |
Pop |
Purr |
Sosumi |
Submarine |
Tink |
The [delete] subcommand
This subcommand lets you delete a sound. The syntax is:
soundRef delete token
After deletion, the token associated with this sound is not valid anymore.
The [list] subcommand
This subcommand returns a list of the existing sound tokens. The syntax is:
soundRef list
The [pause] subcommand
This subcommand lets you pause audio playback. The syntax is:
soundRef pause token
The [play] subcommand
This subcommand lets you initiate audio playback. The syntax is:
soundRef play token
The [resume] subcommand
This subcommand lets you resume audio playback. The syntax is:
soundRef resume token
The [stop] subcommand
This subcommand lets you conclude audio playback. The syntax is:
soundRef stop token
The [volume] subcommand
This subcommand lets you get or set the volume of a sound. The syntax is:
soundRef volume token
soundRef volume token value
The first form of the command returns the current volume.
The second form of the command is used to set the volume for a
sound.
Examples
Open the Tcl Shell (with ⌘Y
) and enter the following commands, one by one:
Welcome to Alpha's AlphaTcl shell.
«» soundRef create -name Submarine
sound1
«» soundRef play sound1
«» soundRef volume sound1
1.0
«» soundRef volume sound1 0.4
«» soundRef play sound1
«» soundRef delete sound1
Last updated 2019-10-17 13:29:32