Constructors

  • Creates a new Sequence.

    Parameters

    • target: HTMLCanvasElement

      The canvas element to render the animation on.

    • bpm: number = 120

      The beats per minute for the animation.

    • ticksPerBeat: number = 4

      The number of ticks per beat.

    • beatsPerBar: number = 4

      The number of beats per bar.

    • audioLoader: IAudioLoader

      The IAudioLoader instance to load the audio.

    • Optionalscenes: Scene[]

      An optional array of scenes to include in the sequence.

    • maxFps: number = 60

      The maximum frames per second (not yet implemented).

    Returns Sequence

Properties

analyser: AnalyserNode
audioBuffer: AudioBuffer
audioContext: AudioContext
audioSource: AudioBufferSourceNode
beatCounter: number = 0
beatsPerBar: number = 0
bpm: number = 0
conductor?: Conductor
currentBar: number = 0
currentBeat: number = 0
currentSceneIndex: number = 0
currentTick: number = 0
currentTime: number = 0
durationMs: number = 0
fftData: Uint8Array
isPlaying: boolean = false
lastBeatTime: number = 0
requestAnimationFrameID: number
scenes: Scene[] = []
target: HTMLCanvasElement

The canvas element to render the animation on.

targetCtx: null | CanvasRenderingContext2D
tickCounter: number = 0
ticksPerBeat: number = 0

Accessors

  • get currentScene(): undefined | Scene
  • Gets the current scene being played.

    Returns undefined | Scene

    The current Scene or undefined if no scene is active.

Methods

  • Adds a post-processing function to the sequence.

    Parameters

    • processor: ((ctx: CanvasRenderingContext2D, sequence: Sequence) => void)

      The post-processing function to add.

        • (ctx, sequence): void
        • Parameters

          • ctx: CanvasRenderingContext2D
          • sequence: Sequence

          Returns void

    Returns void

  • Adds a scene to the sequence.

    Parameters

    • scene: Scene

      The scene to add.

    Returns void

  • Adds multiple scenes to the sequence.

    Parameters

    • scenes: Scene[]

      The scenes to add.

    Returns Sequence

    The Sequence instance for chaining.

  • Adds multiple scenes to the sequence.

    Parameters

    • Rest...scenes: Scene[]

      The scenes to add.

    Returns Sequence

    The Sequence instance for chaining.

  • Adds a transition-in listener for a specific scene.

    Parameters

    • scene: Scene

      The scene to add the listener to.

    • startTime: number

      The time (in milliseconds) within the scene when the transition should start.

    • duration: number
    • listener: ((ctx: CanvasRenderingContext2D, scene: Scene, progress: number) => void)

      The transition function to apply.

        • (ctx, scene, progress): void
        • Parameters

          • ctx: CanvasRenderingContext2D
          • scene: Scene
          • progress: number

          Returns void

    Returns void

  • Adds a transition-out listener for a specific scene.

    Parameters

    • scene: Scene

      The scene to add the listener to.

    • startTime: number

      The time (in milliseconds) relative to the end of the scene when the transition should start.

    • duration: number
    • listener: ((ctx: CanvasRenderingContext2D, scene: Scene, progress: number) => void)

      The transition function to apply.

        • (ctx, scene, progress): void
        • Parameters

          • ctx: CanvasRenderingContext2D
          • scene: Scene
          • progress: number

          Returns void

    Returns void

  • Adds a WGSL post-processing effect to the sequence for a specific scene.

    Parameters

    • scene: Scene

      The scene to apply the effect to.

    • device: GPUDevice
    • processor: ((ctx: CanvasRenderingContext2D, scene: Scene, device: GPUDevice) => void)

      The WGSL post-processing function.

        • (ctx, scene, device): void
        • Parameters

          • ctx: CanvasRenderingContext2D
          • scene: Scene
          • device: GPUDevice

          Returns void

    Returns void

  • Gets the remaining time in the current scene.

    Parameters

    • timeStamp: number

      The current timestamp in the animation.

    Returns number

    The remaining time in milliseconds.

  • Asynchronously initializes the Sequence by loading the audio.

    Returns Promise<Sequence>

    A Promise that resolves to the Sequence instance.

  • Adds an event listener for when a bar is complete.

    Parameters

    • listener: ((bar: number) => void)

      The function to call when a bar is complete.

        • (bar): void
        • Parameters

          • bar: number

          Returns void

    Returns void

  • Adds an event listener for when a beat occurs.

    Parameters

    • listener: ((scene: number, ts: number) => void)

      The function to call when a beat occurs.

        • (scene, ts): void
        • Parameters

          • scene: number
          • ts: number

          Returns void

    Returns void

  • Adds an event listener for each frame.

    Parameters

    • listener: ((scene: number, time: number) => void)

      The function to call on each frame.

        • (scene, time): void
        • Parameters

          • scene: number
          • time: number

          Returns void

    Returns void

  • Adds an event listener for when the frame rate drops below a threshold.

    Parameters

    • listener: ((fps: number) => void)

      The function to call when the frame rate is low.

        • (fps): void
        • Parameters

          • fps: number

          Returns void

    Returns void

  • Adds an event listener for when a tick occurs.

    Parameters

    • listener: ((scene: number, ts: number) => void)

      The function to call when a tick occurs.

        • (scene, ts): void
        • Parameters

          • scene: number
          • ts: number

          Returns void

    Returns void

  • Pauses   the animation sequence.

    Returns void

  • Starts the animation sequence.

    Parameters

    • OptionalmaxFps: number

      The maximum frames per second.

    Returns void

  • Removes a scene from the sequence.

    Parameters

    • scene: Scene

      The scene to remove.

    Returns void

  • Render a specific time

    Parameters

    • time: number

    Returns void

  • Sets the function to be used for resetting the rendering context when switching scenes.

    Parameters

    • resetFunction: ((ctx: CanvasRenderingContext2D) => void)

      The function to call to reset the context.

        • (ctx): void
        • Parameters

          • ctx: CanvasRenderingContext2D

          Returns void

    Returns void

  • Stops the animation sequence.

    Returns void