spessasynth_lib documentation
    Preparing search index...

    Class Sequencer

    The sequencer plays MIDI sequences using a WorkletSynthesizer or WorkerSynthesizer.

    Index
    eventHandler: SeqEventHandler = ...

    The sequencer's event handler. It allows setting up custom event listeners for the sequencer.

    isFinished: boolean = false

    Indicates whether the sequencer has finished playing a sequence.

    midiData?: MIDIData

    The data of the current sequence. Undefined if the data is currently loading or if no song is playing.

    The BasicMIDI.embeddedSoundBank and BasicMIDI.timeline properties and MIDITrack.events in the tracks are all empty to avoid copying the entire file between threads.

    songListData: MIDIData[] = []

    The data of all the sequences, stored like the Sequencer.midiData property, but for all songs. Allows creating playlists with the decoded titles and metadata.

    The synthesizer attached to this sequencer.

    • get currentTime(): number

      The current playback time of the song in seconds.

      Returns number

    • set currentTime(time: number): void

      Seeks to the specified time.

      Parameters

      • time: number

        The new time in seconds.

      Returns void

    • get duration(): number

      The current song's length, in seconds. 0 if no track is currently loaded.

      Returns number

    • get loopCount(): number

      The number of loops remaining until the loop is disabled.

      Returns number

    • set loopCount(val: number): void

      The number of loops remaining until the loop is disabled. Set to Infinity to loop forever. It will automatically decrease by one every loop. Set to 0 to disable loops.

      Parameters

      • val: number

        The new loop count.

      Returns void

    • get playbackRate(): number

      Controls how fast the song plays (1 is normal, 0.5 is half speed, etc.).

      Returns number

    • set playbackRate(value: number): void

      Controls how fast the song plays (1 is normal, 0.5 is half speed, etc.).

      Parameters

      • value: number

        The new playback rate.

      Returns void

    • get shuffleSongs(): boolean

      Controls if the sequencer should shuffle the songs in the song list. If true, the sequencer will play the songs in a random order.

      Songs are shuffled on a Sequencer.loadNewSongList call.

      Returns boolean

    • set shuffleSongs(value: boolean): void

      Controls if the sequencer should shuffle the songs in the song list. If true, the sequencer will play the songs in a random order.

      Songs are shuffled on a Sequencer.loadNewSongList call.

      Parameters

      • value: boolean

        The new value for this parameter.

      Returns void

    • get skipToFirstNoteOn(): boolean

      Indicates if the sequencer should skip to the first note-on event when the time is set before it.

      Returns boolean

    • set skipToFirstNoteOn(val: boolean): void

      Indicates if the sequencer should skip to the first note-on event when the time is set before it.

      Parameters

      • val: boolean

        The new value for this parameter.

      Returns void

    • get songIndex(): number

      The current song number in the playlist. If shuffle mode is enabled, this is the index of the shuffled song list.

      Returns number

    • set songIndex(value: number): void

      Sets the current song number in the playlist. If shuffle mode is enabled, this is the index of the shuffled song list.

      Parameters

      • value: number

        The new song index to set.

      Returns void

    • Connects a given MIDI output port and plays the sequence to it.

      Parameters

      • output: { send: (data: number[]) => unknown }

        The output to connect.

      • channelOffset: number = 0

        The channel offset of this output for multi-port files. For example 0 means the first port, 16 means the second port and so on.

      Returns void

    • Disconnects a given MIDI output port from the sequencer.

      Parameters

      • output: { send: (data: number[]) => unknown }

        The output to disconnect.

      Returns void

    • Gets the actual BasicMIDI sequence, complete with track data.

      Returns Promise<BasicMIDI>

      Error If no MIDI is loaded.