spessasynth_core documentation
    Preparing search index...

    Class SpessaSynthSequencer

    This module is responsible for playing back BasicMIDI sequences to SpessaSynthProcessor.

    Index
    externalMIDIPlayback: boolean = false

    If the MIDI messages should be sent to an event instead of the synth. This is used by spessasynth_lib to pass them over to Web MIDI API.

    If true, SequencerEvent.midiMessage will be emitted.

    isFinished: boolean = false

    Indicates if the sequencer has finished playing the song list.

    loopCount: number = 0

    The current loop count of the sequencer. If set to Infinity, it will loop forever. If set to 0, the loop is disabled.

    This value will decrease with every loop.

    onEventCall?: (event: SequencerEventCallback) => unknown

    This property can be defined as a function that listens for events. All events are defined in SequencerEvent.

    Type Declaration

    preload: boolean = true

    A boolean indicating if the smart preloading should be enabled. It is highly recommended. This causes the sequencer to BasicMIDI.preloadSynth all the songs when loading them (except for those with embedded sound banks).

    Defaults to true.

    retriggerPausedNotes: boolean = true

    If the notes that were playing when the sequencer was paused should be re-triggered. This will re-trigger the notes at the same velocity when unpausing the sequencer.

    Defaults to true.

    shuffledSongIndexes: number[] = []

    The shuffled song indexes. These will be played in order when the shuffle mode is enabled.

    skipToFirstNoteOn: boolean = true

    Indicates if the sequencer should skip to the first note on event. Defaults to true.

    songs: BasicMIDI[] = []

    Sequencer's current song list.

    The synthesizer connected to the sequencer.

    • get currentTime(): number

      The current time of the sequencer. This is the time in seconds since the sequencer started playing.

      This field can be set to trigger a change.

      Returns number

    • set currentTime(time: number): void

      The current time of the sequencer. This is the time in seconds since the sequencer started playing.

      This field can be set to trigger a change.

      Parameters

      • time: number

        the time to set in seconds.

      Returns void

    • get playbackRate(): number

      The sequencer's playback rate. This is the rate at which the sequencer plays back the MIDI data.

      This field can be set to trigger a change.

      Returns number

    • set playbackRate(value: number): void

      The sequencer's playback rate. This is the rate at which the sequencer plays back the MIDI data.

      This field can be set to trigger a change.

      Parameters

      • value: number

        the playback rate to set.

      Returns void

    • get shuffleMode(): 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 loadNewSongList call.

      Returns boolean

    • set shuffleMode(on: 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 loadNewSongList call.

      Parameters

      • on: boolean

      Returns void

    • get songIndex(): number

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

      This field can be set to trigger a change.

      Returns number

    • set songIndex(value: number): void

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

      This field can be set to trigger a change.

      Parameters

      • value: number

      Returns void

    • Starts or resumes the playback of the sequencer. If the sequencer is paused, it will resume from the paused time.

      Returns void

    • Processes all messages at the current time. Call this every rendering quantum to process the sequencer events in real-time.

      Returns void

      while (filledSamples < sampleCount) {
      // Process sequencer
      seq.processTick();
      // Render
      const bufferSize = Math.min(BUFFER_SIZE, sampleCount - filledSamples);
      synth.process(outLeft, outRight, filledSamples, bufferSize);
      filledSamples += bufferSize;
      }