ztcl::audio configure
Gives or sets the options of the audio engine or of an id.
ztcl::audio configure ?OPTION? ?VALUE OPTION VALUE ...?
ztcl::audio configure ID ?OPTION? ?VALUE OPTION VALUE ...?
Description
As the configure of a widget: with no OPTION, gives a list of each option and its value; with one OPTION, gives its value; with pairs, sets them. An error sets no option.
The options of the engine: -device is none (the default, no engine), offline (an engine with no sound card, for render), or default (the sound card, from stage 3 of the engine). -rate is the rate in Hz, 8000 to 192000, and 48000 by default; it changes only with no sound loaded. -latency asks for the buffer of the device in ms. -command is the script of the events of the engine. A change of -device or -rate ends the voices; the sounds stay.
The events of the audio session of the device default come to -command as a dict: {interruption began}, {interruption ended resume 0|1}, {route OUTPUT reason REASON lead MS}, and {remote play|pause|toggle|next|previous}. OUTPUT is speaker, headphones, bluetooth, airplay, hdmi, usb, or other; REASON is new, old (an output went away), category, override, or other. An interruption and the reason old pause the output; the voices and patterns wait. -interruption is pause (the default) or resume: with resume, the end of an interruption starts the output again when the system allows it. configure -device default starts a paused output again, or gives ZTCL AUDIO INTERRUPTED when the system does not let it play. -nowplaying is a dict with the keys title, artist, album, and duration (seconds) for the lock screen; a host with no lock screen keeps the option.
The options of a sound: -gain, and the read-only -frames and -length (ms). The options of a voice: -gain, -pan, and the read-only -sound.
The options of a pattern are those of ztcl::audio pattern, and -tracks for its TRACKS. A change applies at the next bar. -tracks applies at the next step, with no hit played twice, and its cycle must have the same count of steps. -countin is read-only after the start. cget gives the value that a script set last, and -tempo gives the tempo that plays now.
Returns
The options, a value, or an empty string.
Examples
% ztcl::audio configure -device offline -rate 44100; ztcl::audio configure
-command {} -device offline -interruption pause -latency 0 -nowplaying {} -rate 44100
Errors
% ztcl::audio configure -device default
the audio device is not available on this platform
-errorcode ZTCL AUDIO UNAVAILABLE
% ztcl::audio configure -device loud
bad device "loud": must be default, none, or offline
-errorcode NONE
% ztcl::audio configure -fast 1
bad option "-fast": must be -command, -device, -interruption, -latency, -nowplaying, or -rate
-errorcode NONE
% ztcl::audio configure -interruption later
bad interruption "later": must be pause or resume
-errorcode NONE
% ztcl::audio configure -nowplaying {cover x}
bad key "cover": must be album, artist, duration, or title
-errorcode NONE
% ztcl::audio configure voice7 -gain 1
voice "voice7" doesn't exist
-errorcode TCL LOOKUP AUDIO voice7
% ztcl::audio configure pattern7 -tempo 90
pattern "pattern7" doesn't exist
-errorcode TCL LOOKUP AUDIO pattern7
Facts
- Capability
audio. A new interpreter does not have it until the host turns it on.- Tcl release
- Tcl 9.1 and 8.6.
- Since
- ztcl 1.0.0-beta.6