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();Constructor
Section titled “Constructor”new Sequence(callback?: ToneEventCallback<ValueType>, events?: SequenceEventDescription<ValueType>, subdivision?: Time)Parameters
-
callback
ToneEventCallback<ValueType>optionalThe callback to invoke with every note
-
events
SequenceEventDescription<ValueType>optionalThe sequence of events
-
subdivision
TimeoptionalThe subdivision between which events are placed.
new Sequence(options?: Partial<SequenceOptions<ValueType>>)Parameters
- options
Partial<SequenceOptions<ValueType>>optional
Properties
Section titled “Properties”callback
Section titled “callback”↳ inherited from ToneEvent
callback: ToneEventCallback<ValueType>The callback to invoke.
humanize
Section titled “humanize”humanize: boolean | TimeIf 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;
loop: number | booleanIf 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.
loopStart
Section titled “loopStart”loopStart: numberThe index at which the sequence should start looping
playbackRate
Section titled “playbackRate”playbackRate: numberThe 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
Section titled “probability”probability: numberThe probability of the notes being triggered.
progress
Section titled “progress”read-only
progress: numberThe current progress of the loop interval. Returns 0 if the event is not started yet or it is not set to loop.
startOffset
Section titled “startOffset”startOffset: numberThe start from the scheduled start time.
read-only ↳ inherited from ToneEvent
state: BasicPlaybackStateReturns the playback state of the note, either “started” or “stopped”.
subdivision
Section titled “subdivision”read-only
subdivision: numberThe subdivision of the sequence. This can only be set in the constructor. The subdivision is the interval between successive steps.
Methods
Section titled “Methods”cancel()
Section titled “cancel()”↳ inherited from ToneEvent
cancel(time?: Time | TransportTimeClass<number>): thisCancel all scheduled events greater than or equal to the given time
Parameters
-
time
Time | TransportTimeClass<number>optionalThe time after which events will be cancel.
Returns this
start()
Section titled “start()”start(time?: Time, offset?: number): thisStart the part at the given time.
Parameters
-
time
TimeoptionalWhen to start the part.
-
offset
numberoptionalThe offset index to start at
Returns this
stop()
Section titled “stop()”stop(time?: Time): thisStop the part at the given time.
Parameters
-
time
TimeoptionalWhen to stop the part.
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): SequenceOptions<any>Returns all of the default options belonging to the class.
Returns SequenceOptions<any>
Inherited members
Section titled “Inherited members”- From
ToneWithContext: context, blockTime, sampleTime, get(), immediate(), now(), set(), toFrequency(), toSeconds(), toTicks() - From
Tone: debug, version, disposed, toString()