Timeline < GenericEvent >

A Timeline class for scheduling and maintaining state along a timeline. All events must have a "time" property. Internally, events are stored in time order for fast retrieval.

Hierarchy

Constructor

new Timeline (
memory?:undefined | number

The number of previous events that are retained.

) => Timeline
new Timeline (
options?:Partial<TimelineOptions >
) => Timeline

Properties

debug #

boolean

Set this debug flag to log all events that happen in this class.

disposed #

readonly boolean

Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.

increasing #

boolean

If the time value must always be greater than or equal to the last element on the list.

length #

readonly number

The number of items in the timeline.

memory #

number

The memory of the timeline, i.e. how many events in the past it will retain

name #

string

static version #

string

The version number semver

Methods

add #

Insert an event object onto the timeline. Events must have a "time" attribute.

add (
event:GenericEvent

The event object to insert into the timeline.

) => this

cancel #

Cancel events at and after the given time

cancel (
after:number

The time to query.

) => this

cancelBefore #

Cancel events before or equal to the given time.

cancelBefore (
time:number

The time to cancel before.

) => this

dispose #

Clean up.

dispose ( ) => this

forEach #

Iterate over everything in the array

forEach (
callback:(event) => void

The callback to invoke with every item

) => this

forEachAfter #

Iterate over everything in the array after the given time.

forEachAfter (
time:Seconds ,

The time to check if items are before

callback:(event) => void

The callback to invoke with every item

) => this

forEachAtTime #

Iterate over everything in the array at the given time

forEachAtTime (
time:number ,

The time to check if items are before

callback:(event) => void

The callback to invoke with every item

) => this

forEachBefore #

Iterate over everything in the array at or before the given time.

forEachBefore (
time:Seconds ,

The time to check if items are before

callback:(event) => void

The callback to invoke with every item

) => this

forEachBetween #

Iterate over everything in the array between the startTime and endTime. The timerange is inclusive of the startTime, but exclusive of the endTime. range = [startTime, endTime).

forEachBetween (
startTime:number ,

The time to check if items are before

endTime:number ,

The end of the test interval.

callback:(event) => void

The callback to invoke with every item

) => this

forEachFrom #

Iterate over everything in the array at or after the given time. Similar to forEachAfter, but includes the item(s) at the given time.

forEachFrom (
time:number ,

The time to check if items are before

callback:(event) => void

The callback to invoke with every item

) => this

get #

Get the nearest event whose time is less than or equal to the given time.

get (
time:number ,

The time to query.

param= "time":TimelineSearchParam
) => GenericEvent | null

getAfter #

Get the event which is scheduled after the given time.

getAfter (
time:number ,

The time to query.

param= "time":TimelineSearchParam
) => GenericEvent | null

getBefore #

Get the event before the event at the given time.

getBefore (
time:number

The time to query.

) => GenericEvent | null

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => TimelineOptions

peek #

Return the first event in the timeline without removing it

peek ( ) => GenericEvent | undefined
The first event object

previousEvent #

Returns the previous event if there is one. null otherwise

previousEvent (
event:GenericEvent

The event to find the previous one of

) => GenericEvent | null
The event right before the given event

remove #

Remove an event from the timeline.

remove (
event:GenericEvent

The event object to remove from the list.

) => this
this

shift #

Return the first event in the timeline and remove it

shift ( ) => GenericEvent | undefined

toString #

Convert the class to a string


import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());
toString ( ) => string