ztcl::audio position
Gives the clock of the audio engine, or the position of a pattern.
ztcl::audio position ?-heard? ?PATTERN?
Description
With no PATTERN, gives a dict: frame, the count of frames that the engine played since its start; ms, the same time in milliseconds; and time, the time of that frame on the clock of the host in nanoseconds (for the device offline, the time of the frames).
With PATTERN, gives a dict of its last step before the clock: bar (0 or less in a count-in), beat, step (the step in the bar, from 1), and muted (1 in a muted bar of -gap). Before its start, a pattern gives its first step.
-heard gives the position that the ear hears now: the clock less the output latency of the device. The device offline has no latency, so -heard gives the same position.
Returns
A dict with the keys frame, ms, and time, or bar, beat, step, and muted.
Examples
% ztcl::audio configure -device offline; ztcl::audio render 10; ztcl::audio position
frame 480 ms 10 time 10000000
% set s [ztcl::audio load -wave sine -length 10]; set m [ztcl::audio pattern [list $s {X x x x}]]; ztcl::audio render 1100; ztcl::audio position -heard $m
bar 1 beat 3 step 3 muted 0
Errors
% ztcl::audio position -heard a b
wrong # args: should be "ztcl::audio position ?-heard? ?pattern?"
-errorcode TCL WRONGARGS
% ztcl::audio position pattern9
pattern "pattern9" doesn't exist
-errorcode TCL LOOKUP AUDIO pattern9
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