Skip to content
Tone.js

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");
new Pattern(callback?: ToneEventCallback<ValueType>, values?: ValueType[], pattern?: PatternName)

Parameters

  • callback ToneEventCallback<ValueType> optional

    The callback to invoke with the event.

  • values ValueType[] optional

    The values to arpeggiate over.

  • pattern PatternName optional

    The name of the pattern

new Pattern(options?: Partial<PatternOptions<ValueType>>)

Parameters

callback: (time: number, value?: ValueType) => void

The callback to be invoked at a regular interval

read-only

name: string

The name of the class

Default: "Pattern"

↳ inherited from Loop

humanize: boolean | Time

Random variation +/-0.01s to the scheduled time. Or give it a time value which it will randomize by.

read-only

index: number | undefined

The current index of the pattern.

↳ inherited from Loop

interval: Time

The time between successive callbacks.

const loop = new Tone.Loop();
loop.interval = "8n"; // loop every 8n

↳ inherited from Loop

iterations: number

The number of iterations of the loop. The default value is Infinity (loop forever).

↳ inherited from Loop

mute: boolean

Muting the Loop means that no callbacks are invoked.

pattern: PatternName

The pattern type.

↳ inherited from Loop

playbackRate: number

The playback rate of the loop. The normal playback rate is 1 (no change). A playbackRate of 2 would be twice as fast.

↳ inherited from Loop

probability: number

The probably of the callback being invoked.

read-only ↳ inherited from Loop

progress: number

The progress of the loop as a value between 0-1. 0, when the loop is stopped or done iterating.

read-only ↳ inherited from Loop

The state of the Loop, either started or stopped.

read-only

value: ValueType | undefined

The current value of the pattern.

values: ValueType[]

The array of events.

↳ inherited from Loop

cancel(time?: Time): this

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

Parameters

  • time Time optional

    The time after which events will be cancel.

Returns this

↳ inherited from Loop

dispose(): this

disconnect and dispose.

Returns this

↳ inherited from Loop

start(time?: Time): this

Start the loop at the specified time along the Transport’s timeline.

Parameters

  • time Time optional

    When to start the Loop.

Returns this

↳ inherited from Loop

stop(time?: Time): this

Stop the loop at the given time.

Parameters

  • time Time optional

    When to stop the Loop.

Returns this

static

getDefaults(): PatternOptions<any>

Returns all of the default options belonging to the class.

Returns PatternOptions<any>