Skip to content
Tone.js

Sequence

class Event ↳ extends ToneEvent<ValueType>

A sequence is an alternate notation of a part. Instead of passing in an array of [time, event] pairs, pass in an array of events which will be spaced at the given subdivision. Sub-arrays will subdivide that beat by the number of items are in the array. Sequence notation inspiration from Tidal Cycles

const synth = new Tone.Synth().toDestination();
const seq = new Tone.Sequence((time, note) => {
	synth.triggerAttackRelease(note, 0.1, time);
	// subdivisions are given as subarrays
}, ["C4", ["E4", "D4", "E4"], "G4", ["A4", "G4"]]).start(0);
Tone.Transport.start();
new Sequence(callback?: ToneEventCallback<ValueType>, events?: SequenceEventDescription<ValueType>, subdivision?: Time)

Parameters

  • callback ToneEventCallback<ValueType> optional

    The callback to invoke with every note

  • events SequenceEventDescription<ValueType> optional

    The sequence of events

  • subdivision Time optional

    The subdivision between which events are placed.

new Sequence(options?: Partial<SequenceOptions<ValueType>>)

Parameters

↳ inherited from ToneEvent

callback: ToneEventCallback<ValueType>

The callback to invoke.

↳ inherited from ToneEvent

mute: boolean

If mute is true, the callback won’t be invoked.

read-only

name: string

The name of the class

Default: "Sequence"

↳ inherited from ToneEvent

value: ValueType

The value which is passed to the callback function.

events: any[]

The sequence

humanize: boolean | Time

If set to true, will apply small random variation to the callback time. If the value is given as a time, it will randomize by that amount.

const event = new Tone.ToneEvent();
event.humanize = true;

read-only

length: number

The number of scheduled events

loop: number | boolean

If the note should loop or not between ToneEvent.loopStart and ToneEvent.loopEnd. If set to true, the event will loop indefinitely, if set to a number greater than 1 it will play a specific number of times, if set to false, 0 or 1, the part will only play once.

loopEnd: number

The index at which the sequence should end looping

loopStart: number

The index at which the sequence should start looping

playbackRate: number

The playback rate of the event. Defaults to 1.

const note = new Tone.ToneEvent();
note.loop = true;
// repeat the note twice as fast
note.playbackRate = 2;
probability: number

The probability of the notes being triggered.

read-only

progress: number

The current progress of the loop interval. Returns 0 if the event is not started yet or it is not set to loop.

startOffset: number

The start from the scheduled start time.

read-only ↳ inherited from ToneEvent

Returns the playback state of the note, either “started” or “stopped”.

read-only

subdivision: number

The subdivision of the sequence. This can only be set in the constructor. The subdivision is the interval between successive steps.

↳ inherited from ToneEvent

cancel(time?: Time | TransportTimeClass<number>): this

Cancel all scheduled events greater than or equal to the given time

Parameters

Returns this

clear(): this

Clear all of the events

Returns this

dispose(): this

disconnect and dispose.

Returns this

start(time?: Time, offset?: number): this

Start the part at the given time.

Parameters

  • time Time optional

    When to start the part.

  • offset number optional

    The offset index to start at

Returns this

stop(time?: Time): this

Stop the part at the given time.

Parameters

  • time Time optional

    When to stop the part.

Returns this

static

getDefaults(): SequenceOptions<any>

Returns all of the default options belonging to the class.

Returns SequenceOptions<any>