Documentation
    Preparing search index...

    Class StateTimeline<AdditionalOptions>Internal

    A Timeline State. Provides the methods: setStateAtTime("state", time) and getValueAtTime(time)

    The initial state of the StateTimeline. Defaults to undefined

    Type Parameters

    • AdditionalOptions extends Record<string, any> = Record<string, any>

    Hierarchy (View Summary)

    Index

    The array of scheduled timeline events

    debug: boolean

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

    increasing: boolean

    If the time value must always be greater than or equal to the last element on the list.

    memory: number

    The memory of the timeline, i.e. how many events in the past it will retain

    name: string

    The name of the class

    version: string

    The version number semver

    • 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 length(): number

      The number of items in the timeline.

      Returns number

    • Does a binary search on the timeline array and returns the nearest event index whose time is after or equal to the given time. If a time is searched before the first index in the timeline, -1 is returned. If the time is after the end, the index of the last item is returned.

      Parameters

      Returns number

    • Cancel events at and after the given time

      Parameters

      • after: number

        The time to query.

      Returns this

    • Cancel events before or equal to the given time.

      Parameters

      • time: number

        The time to cancel before.

      Returns this

    • Clean up.

      Returns this

    • Iterate over everything in the array after the given time.

      Parameters

      Returns this

    • Iterate over everything in the array at the given time

      Parameters

      Returns this

    • Iterate over everything in the array at or before the given time.

      Parameters

      Returns this

    • Iterate over everything in the array between the startTime and endTime. The timerange is inclusive of the startTime, but exclusive of the endTime. range = [startTime, endTime).

      Parameters

      • startTime: number

        The time to check if items are before

      • endTime: number

        The end of the test interval.

      • callback: (event: StateTimelineEvent & AdditionalOptions) => void

        The callback to invoke with every item

      Returns this

    • Iterate over everything in the array at or after the given time. Similar to forEachAfter, but includes the item(s) at the given time.

      Parameters

      Returns this

    • Returns the scheduled state scheduled before or at the given time.

      Parameters

      • time: number

        The time to query.

      Returns PlaybackState

      The name of the state input in setStateAtTime.

    • Prints the outputs to the console log for debugging purposes. Prints the contents only if either the object has a property called debug set to true, or a variable called TONE_DEBUG_CLASS is set to the name of the class.

      Parameters

      • ...args: any[]

      Returns void

      const osc = new Tone.Oscillator();
      // prints all logs originating from this oscillator
      osc.debug = true;
      // calls to start/stop will print in the console
      osc.start();
    • Add a state to the timeline.

      Parameters

      • state: PlaybackState

        The name of the state to set.

      • time: number

        The time to query.

      • Optionaloptions: AdditionalOptions

        Any additional options that are needed in the timeline.

      Returns this

    • Convert the class to a string

      Returns string

      const osc = new Tone.Oscillator();
      console.log(osc.toString());
    • Returns all of the default options belonging to the class.

      Returns TimelineOptions