Pattern
class Event ↳ extends Loop<PatternOptions<ValueType>>
Pattern arpeggiates between the given notes in a number of patterns.
const pattern = new Tone.Pattern((time, note) => {
// the order of the notes passed in depends on the pattern
}, ["C2", "D4", "E5", "A6"], "upDown");Constructor
Section titled “Constructor”new Pattern(callback?: ToneEventCallback<ValueType>, values?: ValueType[], pattern?: PatternName)Parameters
-
callback
ToneEventCallback<ValueType>optionalThe callback to invoke with the event.
-
values
ValueType[]optionalThe values to arpeggiate over.
-
pattern
PatternNameoptionalThe name of the pattern
new Pattern(options?: Partial<PatternOptions<ValueType>>)Parameters
- options
Partial<PatternOptions<ValueType>>optional
Properties
Section titled “Properties”callback
Section titled “callback”callback: (time: number, value?: ValueType) => voidThe callback to be invoked at a regular interval
humanize
Section titled “humanize”↳ inherited from Loop
humanize: boolean | TimeRandom variation +/-0.01s to the scheduled time. Or give it a time value which it will randomize by.
interval
Section titled “interval”↳ inherited from Loop
interval: TimeThe time between successive callbacks.
const loop = new Tone.Loop(); loop.interval = "8n"; // loop every 8n
iterations
Section titled “iterations”↳ inherited from Loop
iterations: numberThe number of iterations of the loop. The default value is Infinity (loop forever).
playbackRate
Section titled “playbackRate”↳ inherited from Loop
playbackRate: numberThe playback rate of the loop. The normal playback rate is 1 (no change).
A playbackRate of 2 would be twice as fast.
probability
Section titled “probability”↳ inherited from Loop
probability: numberThe probably of the callback being invoked.
progress
Section titled “progress”read-only ↳ inherited from Loop
progress: numberThe progress of the loop as a value between 0-1. 0, when the loop is stopped or done iterating.
read-only ↳ inherited from Loop
state: BasicPlaybackStateThe state of the Loop, either started or stopped.
read-only
value: ValueType | undefinedThe current value of the pattern.
Methods
Section titled “Methods”cancel()
Section titled “cancel()”↳ inherited from Loop
cancel(time?: Time): thisCancel all scheduled events greater than or equal to the given time
Parameters
-
time
TimeoptionalThe time after which events will be cancel.
Returns this
dispose()
Section titled “dispose()”↳ inherited from Loop
dispose(): thisDispose and disconnect
Returns this
start()
Section titled “start()”↳ inherited from Loop
start(time?: Time): thisStart the loop at the specified time along the Transport’s timeline.
Parameters
-
time
TimeoptionalWhen to start the Loop.
Returns this
stop()
Section titled “stop()”↳ inherited from Loop
stop(time?: Time): thisStop the loop at the given time.
Parameters
-
time
TimeoptionalWhen to stop the Loop.
Returns this
getDefaults()
Section titled “getDefaults()”static
getDefaults(): PatternOptions<any>Returns all of the default options belonging to the class.
Returns PatternOptions<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()