Tempo

Tempo helps you create synchronized and rhythmic animations.

Class implements IPlayer in src/Play.ts

Constructor

new Tempo ( bpm )

Construct a new Tempo instance by beats-per-minute. Alternatively, you can use Tempo.fromBeat to create from milliseconds.

parameters
bpm: number

beats per minute

returns
An instance of Tempo
source

Accessors

GET SET bpm : number

Beats-per-minute value

GET SET ms : number

Milliseconds per beat (Note that this is derived from the bpm value).

Methods

action ( type, px, py, evt )

IPlayer interface. Not implementated.

parameters
type: string

px: number

py: number

evt: Event

returns
void

source

animate ( time, ftime )

IPlayer interface. Internal implementation that calls track( time ).

parameters
time: any

ftime: any

returns
void

source

every ( beats )

This is a core function that let you specify a rhythm and then define responses by calling the start and progress functions from the returned object. See Animation guide for more details. The start function lets you set a callback on every start. It takes a function (ITempoStartFn). The progress function lets you set a callback during progress. It takes a function (ITempoProgressFn). Both functions let you optionally specify a time offset and a custom name. See Animation guide for more details.

parameters
beats: number | number[]

a rhythm in beats as a number or an array of numbers

returns
ITempoResponses

an object with chainable functions

example

tempo.every(2).start( (count) => ... ), tempo.every([2,4,6]).progress( (count, t) => ... )

source

STATIC fromBeat ( ms )

Create a new Tempo instance by specifying milliseconds-per-beat.

parameters
ms: number

milliseconds per beat

returns
Tempo

source

resize ( bound, evt )

IPlayer interface. Not implementated.

parameters
bound: Bound

evt: Event

returns
void

source

stop ( name )

Remove a start or progress callback function from the list of callbacks. See Tempo.every for details

parameters
name: string

a name string specified when creating the callback function.

returns
void

source

track ( time )

Usually you can add a tempo instance to a space via Space.add and it will track time automatically. But if necessary, you can track time manually via this function.

parameters
time: any

current time in milliseconds

returns
void

source