ztcl::audioaudio
Plays sounds on a phone, sets its audio session, and runs the audio engine.
ztcl::audio SUBCOMMAND ?ARG ...?
Description
Plays sounds and sets the audio session of a phone. The command is not a package: it exists when the embedder turns on the capability audio, and a child interp has it only when its parent has it.
The services come from Interp.device_host of the embedder, which ztk fills on Android and iOS. A host with no service for a subcommand, as the ztcl program on a desktop, gives the error ZTCL AUDIO UNAVAILABLE.
The audio engine (docs/dev/audio-engine.md) mixes sounds in ztcl with its own clock of frames: configure, cget, load, unload, play of a sound, pattern, tempo, stop of a voice or a pattern, position, render, and info. Its ids behave as the ids of after: sound1, voice2, pattern3. Its device offline needs no host, and render gives the bytes of the sound, the same on each platform.
The examples of this page run with --allow audio and no host.
Subcommands
| Subcommand | Description |
|---|---|
ztcl::audio session | Gives or sets the audio session. |
ztcl::audio play | Plays a sound. |
ztcl::audio pattern | Starts a pattern of steps in the sequencer of the audio engine. |
ztcl::audio tempo | Changes the tempo of a pattern at once, at a bar, or at a frame. |
ztcl::audio stop | Stops a sound or a pattern. |
ztcl::audio volume | Gives or sets the volume of a sound. |
ztcl::audio configure | Gives or sets the options of the audio engine or of an id. |
ztcl::audio cget | Gives an option of the audio engine or of an id. |
ztcl::audio load | Makes a sound of the audio engine. |
ztcl::audio unload | Frees a sound of the audio engine. |
ztcl::audio position | Gives the clock of the audio engine, or the position of a pattern. |
ztcl::audio render | Renders the sound of the device offline. |
ztcl::audio info | Gives the ids of the audio engine, or the facts of one. |
Returns
The result of the subcommand.
Examples
% catch {ztcl::audio play -data RIFF} msg opts; list $msg [dict get $opts -errorcode]
{audio is not available on this platform} {ZTCL AUDIO UNAVAILABLE}
Errors
% ztcl::audio
wrong # args: should be "ztcl::audio subcommand ?arg ...?"
-errorcode TCL WRONGARGS
% ztcl::audio bogus
unknown or ambiguous subcommand "bogus": must be cget, configure, info, load, pattern, play, position, render, session, stop, tempo, unload, or volume
-errorcode TCL LOOKUP SUBCOMMAND
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
The full page: ztcl::audio.