Snack sound extension commands v1.4

(Last updated January 26, 1999)

Manual for version 1.3
Manual for version 1.2

The command package require snack gives you access to all commands described below. The command package require sound only gives you the sound and audio commands. No graphics because it is an extension to Tcl only.


audio
initSnack
sound
spectrogram (deprecated)
spectrogram canvas item
spectrum section canvas item
waveform canvas item

NAME

audio - Get/set properties of the audio device

SYNOPSIS

audio property ?arg?

DESCRIPTION

audio formats audio frequencies audio input ?jack? audio inputs audio output ?jack? audio outputs audio play_gain ?value? audio record_gain ?value?

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

initSnack - Initialize the Snack extension

SYNOPSIS

initSnack

OPTIONS

None.

DESCRIPTION

This command should be run before any features of the Snack extension are used. It makes sure that the Snack library is actually loaded into memory before any of the non-command features (e.g. canvas items) are used.



NAME
        sound - Create and manipulate sounds
SYNOPSIS
        sound ?name? ?options?
DESCRIPTION
CREATING SOUNDS
        sound ?name? ?-load filename?  ?-file filename?  ?-channel channelname? ?-frequency f? ?-channels n? ?-format fmt?
SOUND COMMAND
soundName append variable ?-frequency f? ?-channels n? ?-format fmt? ?-skipHead n? ?-byteOrder endianess? ?-start start? ?-end end?
soundName byteswap
soundName cget option
soundName concatenate sound
soundName configure option value
soundName convert option value
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? ?-byteOrder endianess? ?-start start? ?-end end?
soundName data ?-start start? ?-end end? ?-fileFormat fileformat?-byteOrder ?endianess?
soundName destroy
soundName flush
soundName info
soundNameinsert sound sample ?-start start? ?-end end?
soundName max
soundName min
soundName length ?n? ?-units u?
soundName pause
soundName play ?-start start? ?-end end? ?-output jack? ?-blocking boolean? -command ?callback?
soundName read filename ?-frequency f? ?-channels n? ?-format fmt? ?-skipHead n? ?-byteOrder endianess? ?-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 handles audio data. Sound objects 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? ?-load filename?  ?-file filename?  ?-channel channelname? ?-frequency f? ?-channels n? ?-format fmt?

soundName specifies the name of the sound. If it is omitted then Snack picks a name of the form soundn, where n is an integer. The -load option specifies that the file filename should be read into memory after creating the sound. The -file option specifies an on-disk file which should be linked to the sound. The -channel options specifies that audio data resides on a channel which should be linked to the sound. In these cases the audio data is not loaded into memory, which is useful when playing large files or when using streaming audio. However, the Snack canvas item types, e.g. waveform, can not be linked to sounds of these types.

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? ?-byteOrder endianess? ?-start start? ?-end end?

soundName byteswap soundName cget option soundName concatenate sound soundName configure option value ... soundName convert option value ... soundName copy sound ?-start start? ?-end end? soundName crop start end soundName cut start end soundName data ?variable? ?option value? ... soundName destroy soundName flush soundName info soundName insert sound sample ?-start start? ?-end end? soundName length ?n? ?-units u? soundName max soundName min soundName pause soundName play ?option value? ... soundName record ?option value? ... soundName read filename ?-frequency f? ?-channels n? ?-format fmt? ?-skipHead n? ?-byteOrder endianess? ?-start start? ?-end end? soundName sample n ?value? ... soundName stop soundName write filename ?-start start? ?-end end? ?-fileFormat fileformat?


NAME

spectrogram - Real time spectrogram widget (deprecated, use spectrogram canvas item)

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
-colormap colorlist

DESCRIPTION

The option -fftlength specifies the number of fft points (8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096), -winlength specifies the size of the hamming window (8-fftlength). -start and -end controls which part of the sound to display. -pixelspersecond determines the scaling factor in the x-direction. If  the -width option is also given only the last part of the sound is shown according to both values. -brightness and -contrast takes values beteween -100.0 and 100.0. -topfrequency is the frequency value at the top of the spectrogram. -colormap is a list of colors. At least two must be specified. The first color is used for the lowest intensity in the spectrogram. An empty list gives the default 32 level grey scale. See also 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
-gridcolor color
-colormap colorlist

DESCRIPTION

The option -fftlength specifies the number of fft points (8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096), -winlength specifies the size of the hamming window (8-fftlength). -pixelspersecond determines the scaling factor in the x-direction. -start and -end controls which part of the sound to display. Use the -channel option to select which channel to show for multichannel sounds. Use left, right, both, all, -1 (all) or a channel number counting from 0.  If the -width option is also given only the last part of the sound is shown according to both values. -brightness and -contrast takes values beteween -100.0 and 100.0. -topfrequency is the frequency value at the top of the spectrogram. -gridtspacing is the spacing between markers in seconds (default 0 means no grid) and -gridfspacing is the frequency spacing in Hz (default 0 means no grid). -gridcolor specifies the color of the grid. A colormap for the spectrogram is given with the -colormap option. It takes a list of colors as parameter and at least two must be specified. The first color is used for the lowest intensity in the spectrogram. An empty list gives the default 32 level grey scale. Currently spectrograms have a width limit of 32767 pixels. See also 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

The option -fftlength specifies the number of fft points (8, 16, 32, 64, 128, 256, 512, 1024, 2048, or 4096), -winlength specifies the size of the hamming window (8-fftlength). -start and -end controls which part of the sound to display. -topfrequency is the frequency value at the right end of the section. Use the -channel option to select which channel to show for multichannel sounds. Use left, right, both, all, -1 (all) or a channel number counting from 0. -frame specifies whether a frame will be drawn. See also 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
-subsample value

DESCRIPTION

The options -start and -end controls which part of the sound to display. -pixelspersecond determines the scaling factor in the x-direction. If the -width option is also given only the last part of the sound is shown according to both values. Use the -channel option to select which channel to show for multichannel sounds. Use left, right, both, all, -1 (all) or a channel number counting from 0. Use -limit to specify the maximal shown value for the sound amplitude. -zerolevel specifies whether the zero level will be displayed and -frame whether a frame will be drawn. See also the code examples in the widget demonstration. The -subsample option is useful for large sounds to specify how much detail the waveform should show. A value of 1 uses every sample in the sound to draw the waveform envelope, which can be slow for large sounds. A value of 10 uses every 10th. The default value 0 subsamples the waveform in such a way that only 100000 samples are used regardless of the waveform length.



Snack home