Sound Visualization Module Commands
(Last updated September 25, 1998)
-
audio
-
initSnack
-
playChannel
-
recordChannel
-
sound
-
spectrogram
-
stopChannel
-
waveform canvas item
-
spectrogram canvas item
-
spectrum section canvas item
NAME
initSnack - Initialize the Snack module
SYNOPSIS
initSnack
OPTIONS
None.
DESCRIPTION
This command should be run before any features of the Snack modules are
used.
NAME
playChannel - Start playing audio data from a channel (experimental, same
funcionality will be available in the sound command)
SYNOPSIS
playChannel channel ?options value option value ...?
OPTIONS
-output jack
-frequency f
-channels n
-format fmt
-eofCommand cmd
-byteOrder endianess
DESCRIPTION
This command initiates sound playback reading data from channel.
It is possible to specify a command to be executed when end of file is
reached using the -eofCommand option. Byte order can be specified
as littleEndian or bigEndian using the -byteOrder
option.
NAME
recordChannel - Start recording audio data to a channel (experimental,
same funcionality will be available in the sound command)
SYNOPSIS
recordChannel channel ?options value option value ...?
OPTIONS
-input jack
-frequency f
-channels n
-format fileformat
-fileFormat cmd
-byteOrder endianess
DESCRIPTION
This command initiates sound recording writing data to channel.
The data stream can be preceeded by a header using the -fileFormat
option. Currently only AU and RAW (no header) formats are supported. Byte
order can be specified as littleEndian or bigEndian
using the -byteOrder option.
NAME
stopChannel - Stop channel playing/recording (experimental, same
funcionality will be available in the sound command)
SYNOPSIS
stopChannel
OPTIONS
DESCRIPTION
This command stops the current channel play or record operation.
NAME
sound - Create and manipulate
sounds
SYNOPSIS
image create photo ?name?
?options?
DESCRIPTION
CREATING SOUNDS
-file name
SOUND COMMAND
soundName append variable ?-frequency f? ?-channels n?
?-format fmt? ?-skipHead n? ?-byteSwap boolean? ?-start start? ?-end end?
soundName byteswap
soundName channels ?n?
soundName concatenate sound
soundName copy sound ?-start start? ?-end end?
soundName cut sound
soundName crop start end
soundName data variable ?-frequency f? ?-channels n? ?-format
fmt? ?-skipHead n? ?-byteSwap boolean? ?-start start? ?-end end?
soundName data ?-start start? ?-end end? ?-fileFormat
fileformat?
soundName destroy
soundName format ?fmt?
soundName flush
soundName frequency ?freq?
soundName info
soundName insert sound ?-start start?
?-end end?
soundName max
soundName min
soundName length ?n? ?-units u?
soundName play ?-start start? ?-end end? ?-output jack? ?-blocking
boolean?
soundName read filename ?-frequency f? ?-channels
n? ?-format fmt? ?-skipHead n? ?-byteSwap boolean? ?-start start?
?-end end?
soundName record ?-frequency f? ?-channels n? ?-format fmt? ?-input
jack?
soundName sample n ?value? ...
soundName stop
soundName write filename ?-start start? ?-end end?
NAME
sound - Create and manipulate sounds
SYNOPSIS
sound soundName
soundName option ?arg arg ...?
DESCRIPTION
A sound is an object which contains audio data. Sounds can interact with
files, variables, canvas items and the audio hardware.
CREATING SOUNDS
The sound command is used to create, delete, and operate on sound objects.
It can take several different forms, depending on the option argument.
The legal forms are:
sound ?soundName? ?-file filename?
SOUND COMMAND
When a sound is created, Tcl also creates a new command whose name is the
same as the sound name specified. This command may be used to invoke various
operations on the sound. The following commands are possible for sounds:
soundName append variable ?-frequency
f? ?-channels n? ?-format fmt? ?-skipHead n? ?-byteSwap boolean? ?-start
start? ?-end
end?
Appends binary string data to the end of soundName.
soundName byteswap
soundName channels ?n?
Returns the number of channels of the sound. If used with an argument
it sets the number of channels to n (MONO, or STEREO are also valid).
soundName concatenate sound
Concatenates the sample data from sound to the end of soundName.
The sounds must be of the same type.
soundName copy sound ?-start start?
?-end end?
Copies sample data from sound. Optionally a range of samples
to copy can be specified.
soundName crop start end
Crops the sound to the given range [start end].
soundName cut start end
Cuts the given range [start end] from the sound.
soundName data ?variable? ?opt val? ...
Loads sound data from, or writes to, a binary string.
When loading data the same options apply as for the read command:
soundName data variable ?-frequency f? ?-channels n? ?-format
fmt? ?-skipHead n? ?-byteSwap boolean? ?-start start? ?-end end?
The command returns the file format detected.
When writing data to a binary string -start and -end options
can be given (as for the write command). Also, a -fileformat
option can be given if the file format should be different from the original.
soundName data ?-start start? ?-end end? ?-fileFormat
fileformat?
soundName destroy
Removes the sound command and frees the storage associated with it.
soundName flush
Removes all audio data from the sound.
soundName format ?fmt?
Returns the sample encoding format of the sound (LIN16, ALAW, or MULAW)
If used with an argument it sets the sample encoding format to fmt.
soundName frequency ?freq?
Returns the sample frequency of the sound. If used with an argument
it sets the sample frequency to freq.
soundName info
Returns a list with information about the sound: {length frequency
max min format channels}
soundName insert sound sample ?-start start?
?-end end?
Inserts sound at sample. Optionally a range of samples to copy can
be specified.
soundName length ?n? ?-units u?
Gets or sets the length of the sound in number of samples (default),
or seconds, by setting u to either SAMPLES or SECONDS. If the new
length is larger than the current the sound is padded with additional silence.
soundName max
Returns the largest positive sample value of the sound.
soundName min
Returns the largest negative sample value of the sound.
soundName play ?-start start? ?-end end?
?-output jack? ?-blocking boolean?
Plays a sound. Optionally a range of samples to play can be specified.
The -output option is used to specify any of the possible output
ports returned by the audio outputs command, such
as 'Speaker', 'Headphones', or 'Line Out'. The -blocking option
is used to specify whether playback should be asynchronous or not, i.e.
if it is to be played in the background or if the play command should
return only after the sound has been played. Asynchronous playback from
tclsh is only possible if the event loop is running, using for example
vwait.
soundName record ?-frequency f? ?-channels
n? ?-format fmt? ?-input jack?
Starts recording data from the audio device into the sound. The options
-frequency, -channels, and -format are used as with
the read command above. -input specifies one of the available
input ports returned by the audio inputs command,
for example 'Microphone' or 'Line In'.
soundName read filename ?-frequency
f? ?-channels n? ?-format fmt? ?-skipHead n? ?-byteSwap boolean? ?-start
start? ?-end end?
Reads new sound data from a file. The options are used when reading
raw binary files, -frequency and -channels are used to set
he sampling frequency and the number of channels (MONO/STEREO). The -format
option is used to specify sample encoding format, -skipHead is used
to skip an unknown header of size n bytes, and -byteSwap
is used to swap bytes. Currently, the formats LIN16, ALAW, and MULAW are
supported. Current supported file formats are WAV, SMP, AU, SND, NIST (TIMIT),
and raw binary. The command returns the file format detected.
soundName sample n ?value? ...
Gets or sets sample number n. Specify one value for each channel.
You can use a ? character to specify that you don't want to change a certain
value, i. e. snd sample 10000 ? 1000, would set the right channel of sample
number 10000 of sound snd to the value of 1000 without influencing the
left channel.
soundName stop
Stops current play or record operation.
soundName write filename ?-start
start? ?-end end?
Writes sound data to a file. Optionally a range of samples to save
can be specified. The file format is guessed from the filename extension.
Currently, the supported formats are WAV, SMP, AU, SND, and raw.
NAME
audio - Get/set properties of the audio device
SYNOPSIS
audio property ?arg?
DESCRIPTION
The audio command is used to get and set properties of the audio device
such as current input/output jack, supported ports, sample formats, sample
frequencies, and gain.
audio formats
Returns a list of supported sample formats.
audio frequencies
Returns a list of supported sample frequencies.
audio input ?jack?
Gets/sets the current input jack.
audio inputs
Returns a list of available input ports.
audio output ?jack?
Gets/sets the current output jack.
audio outputs
Returns a list of available output ports.
audio play_gain ?value?
Returns the current play gain value if invoked without a parameter,
else sets it to the given value. Valid values are in the range 0-100.
audio record_gain ?value?
Returns the current record gain value if invoked without a parameter,
else sets it to the given value. Valid values are in the range 0-100.
BUGS
This command is in a state of
development. Solaris, Linux, and HP-UX have the most complete implementation.
SGI users should use the system audio panel.
NAME
spectrogram - Real time spectrogram widget
SYNOPSIS
spectrogram pathName ?options value option value ...?
OPTIONS
-height size
-width size
-sound name
-winlength length
-fftlength length
-preemphasisfactor factor
-pixelspersecond value
-xscrollcommand value
-scrollincrement value
-brightness value
-contrast value
-topfrequency frequency
DESCRIPTION
See the code examples in the widget demonstration.
NAME
waveform - Waveform canvas item
SYNOPSIS
pathName create waveform x y ?option value option
value ...?
OPTIONS
-height size
-width size
-sound name
-fill color
-stipple bitmap
-start sample
-end sample
-channel value
-pixelspersecond value
-zerolevel boolean
-tags tagList
-frame boolean
-limit value
DESCRIPTION
See the code examples in the widget demonstration.
NAME
spectrogram - Spectrogram canvas item
SYNOPSIS
pathName create spectrogram x y ?options value option
value ...?
OPTIONS
-height size
-width size
-sound name
-winlength length
-fftlength length
-preemphasisfactor factor
-pixelspersecond value
-tags tagList
-start sample
-end sample
-channel value
-brightness value
-contrast value
-topfrequency frequency
-gridtspacing value
-gridfspacing value
DESCRIPTION
See the code examples in the widget demonstration.
NAME
section - Spectrum section canvas item
SYNOPSIS
pathName create section x y ?options value option
value ...?
OPTIONS
-height size
-width size
-sound name
-winlength length
-fftlength length
-preemphasisfactor factor
-tags tagList
-start sample
-end sample
-channel value
-fill value
-stipple value
-topfrequency frequency
-frame boolean
DESCRIPTION
See the code examples in the widget demonstration.
SNACK home