beetlebug▾
/

ztcl::audio load

Makes a sound of the audio engine.

ztcl::audio load FILE ?-gain G?
ztcl::audio load -data BYTES ?-gain G?
ztcl::audio load -wave sine|square|saw|noise ?OPTION VALUE ...?

Description

Decodes a WAV file one time and resamples it to the rate of the engine, or makes a wave, and gives the id of the sound, such as sound1. The sound is stereo f32 in the memory of the interpreter, so it counts in its memory limit. WAV files have PCM of 8, 16, 24, or 32 bits, or 32-bit float, with 1 or 2 channels; other formats come with the host of stage 3. FILE follows the root folder and needs the capability channels, as play FILE.

The options of -wave: -freq (Hz, 1000 by default), -length (ms, 100), and an envelope: -attack (ms, 1), -decay (ms, 0), -sustain (0 to 1, 1), and -release (ms, 5). -gain (0 to 1) scales the sound. A sound is at most 20 minutes long.

Returns

The id of the sound.

Examples

% ztcl::audio configure -device offline; ztcl::audio load -wave square -freq 1500 -length 30 -decay 25 -sustain 0
sound1

Errors

% ztcl::audio configure -device none; ztcl::audio load -wave sine
no audio device: use ztcl::audio configure -device
-errorcode ZTCL AUDIO DEVICE

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

See also