beetlebug▾
/

ztcl::audio tempo

Changes the tempo of a pattern at once, at a bar, or at a frame.

ztcl::audio tempo PATTERN BPM ?-bar N|-at FRAME?

Description

With no option, the new tempo starts at once. With -bar N it starts exactly on the first step of bar N; a bar that started gives the change at the next step. With -at FRAME it starts at the first tick at or after that frame. The position of the pattern stays continuous: the beats after the change are exact at the new tempo. BPM is 20 to 400.

At most 8 changes of a pattern wait at one time. cget PATTERN -tempo gives the tempo that plays now.

Returns

An empty string.

Examples

# Bar 2 starts at 2.5 seconds at 96 BPM.
% ztcl::audio configure -device offline; set s [ztcl::audio load -wave sine -length 10]; set m [ztcl::audio pattern [list $s {X x x x}] -tempo 96]; ztcl::audio tempo $m 104 -bar 2; ztcl::audio render 2600; ztcl::audio cget $m -tempo
104

% ztcl::audio tempo $m 90; ztcl::audio cget $m -tempo
90

Errors

% ztcl::audio tempo pattern9 100
pattern "pattern9" doesn't exist
-errorcode TCL LOOKUP AUDIO pattern9

% ztcl::audio tempo $m 500
bad tempo "500": must be 20 to 400
-errorcode ZTCL AUDIO VALUE

% ztcl::audio tempo $m 100 -bar 0
bad bar "0": must be 1 or more
-errorcode ZTCL AUDIO VALUE

% ztcl::audio tempo $m
wrong # args: should be "ztcl::audio tempo pattern bpm ?-bar n|-at frame?"
-errorcode TCL WRONGARGS

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