Tone.js
    Preparing search index...

    Class Sequence<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();

    Type Parameters

    • ValueType = any

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    The callback to invoke.

    context: BaseContext

    The context belonging to the node.

    debug: boolean = false

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

    mute: boolean

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

    name: string = "Sequence"

    The name of the class

    value: ValueType

    The value which is passed to the callback function.

    version: string = version

    The version number semver

    Accessors

    • get blockTime(): number

      The number of seconds of 1 processing block (128 samples)

      Returns number

      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

      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.

      Returns boolean | Unit.Time

      const event = new Tone.ToneEvent();
      event.humanize = true;
    • set humanize(variation: boolean | Unit.Time): void

      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.

      Parameters

      Returns void

      const event = new Tone.ToneEvent();
      event.humanize = true;
    • get 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.

      Returns number | boolean

    • set loop(l: number | boolean): void

      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.

      Parameters

      • l: number | boolean

      Returns void

    • get loopEnd(): number

      The index at which the sequence should end looping

      Returns number

    • set loopEnd(index: number): void

      The loopEnd point is the time the event will loop if ToneEvent.loop is true.

      Parameters

      • index: number

      Returns void

    • get loopStart(): number

      The index at which the sequence should start looping

      Returns number

    • set loopStart(index: number): void

      The time when the loop should start.

      Parameters

      • index: number

      Returns void

    • get playbackRate(): number

      The playback rate of the event. Defaults to 1.

      Returns number

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

      The playback rate of the event. Defaults to 1.

      Parameters

      • rate: number

      Returns void

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

      The probability of the notes being triggered.

      Returns number

    • set probability(prob: number): void

      The probability of the notes being triggered.

      Parameters

      • prob: number

      Returns void

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

      Returns number

    • get startOffset(): number

      The start from the scheduled start time.

      Returns number

    • set startOffset(start: number): void

      The start from the scheduled start time.

      Parameters

      • start: number

      Returns void

    • get subdivision(): number

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

      Returns number

    Methods

    • Set multiple properties at once with an object.

      Parameters

      • props: RecursivePartial<Options>

      Returns this

      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;
    • Convert the class to a string

      Returns string

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