Class Pattern<ValueType>

Pattern arpeggiates between the given notes in a number of patterns.

Example

const pattern = new Tone.Pattern((time, note) => {
// the order of the notes passed in depends on the pattern
}, ["C2", "D4", "E5", "A6"], "upDown");

Type Parameters

  • ValueType

Hierarchy (view full)

Constructors

Properties

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

The callback to be invoked at a regular interval

Type declaration

    • (time, value?): void
    • Parameters

      Returns void

context: BaseContext

The context belonging to the node.

debug: boolean = false

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

name: string = "Pattern"
version: string = version

The version number semver

Accessors

  • get blockTime(): number
  • The number of seconds of 1 processing block (128 samples)

    Returns number

    Example

    console.log(Tone.Destination.blockTime);
    
  • get disposed(): 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.

    Returns boolean

  • get humanize(): boolean | Unit.Time
  • Random variation +/-0.01s to the scheduled time. Or give it a time value which it will randomize by.

    Returns boolean | Unit.Time

  • set humanize(variation): void
  • Parameters

    Returns void

  • get index(): undefined | number
  • The current index of the pattern.

    Returns undefined | number

  • get interval(): Unit.Time
  • The time between successive callbacks.

    Returns Unit.Time

    Example

    const loop = new Tone.Loop();
    loop.interval = "8n"; // loop every 8n
  • set interval(interval): void
  • Parameters

    Returns void

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

    Returns number

  • set iterations(iters): void
  • Parameters

    • iters: number

    Returns void

  • get mute(): boolean
  • Muting the Loop means that no callbacks are invoked.

    Returns boolean

  • set mute(mute): void
  • Parameters

    • mute: boolean

    Returns void

  • get 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.

    Returns number

  • set playbackRate(rate): void
  • Parameters

    • rate: number

    Returns void

  • get probability(): number
  • The probably of the callback being invoked.

    Returns number

  • set probability(prob): void
  • Parameters

    • prob: number

    Returns void

  • get progress(): number
  • The progress of the loop as a value between 0-1. 0, when the loop is stopped or done iterating.

    Returns number

Methods

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

    Parameters

    • Optional time: Unit.Time

      The time after which events will be cancel.

    Returns this

  • Return the current time of the Context clock plus the lookAhead.

    Returns number

    Example

    setInterval(() => {
    console.log(Tone.now());
    }, 100);
  • Set multiple properties at once with an object.

    Parameters

    Returns this

    Example

    const filter = new Tone.Filter().toDestination();
    // set values using an object
    filter.set({
    frequency: "C6",
    type: "highpass"
    });
    const player = new Tone.Player("https://tonejs.github.io/audio/berklee/Analogsynth_octaves_highmid.mp3").connect(filter);
    player.autostart = true;
  • Start the loop at the specified time along the Transport's timeline.

    Parameters

    • Optional time: Unit.Time

      When to start the Loop.

    Returns this

  • Convert the incoming time to seconds. This is calculated against the current TransportClass bpm

    Parameters

    Returns number

    Example

    const gain = new Tone.Gain();
    setInterval(() => console.log(gain.toSeconds("4n")), 100);
    // ramp the tempo to 60 bpm over 30 seconds
    Tone.getTransport().bpm.rampTo(60, 30);
  • Convert the class to a string

    Returns string

    Example

    const osc = new Tone.Oscillator();
    console.log(osc.toString());