Class SpessaSharpSequencer

Namespace
SpessaSharp.Sequencer
Assembly
SpessaSharp.dll
public sealed class SpessaSharpSequencer
Inheritance
SpessaSharpSequencer
Inherited Members

Constructors

SpessaSharpSequencer(SpessaSharpProcessor)

Initializes a new Sequencer without any songs loaded.

public SpessaSharpSequencer(SpessaSharpProcessor proc)

Parameters

proc SpessaSharpProcessor

The synthesizer processor to use with this sequencer.

Fields

ExternalPlayback

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.

public bool ExternalPlayback

Field Value

bool

LoopCount

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

public int LoopCount

Field Value

int

OnEventCall

Called when the sequencer calls an event.

public Action<Event>? OnEventCall

Field Value

Action<Event>

Preload

Indicates if the synthesizer should preload the voices for the newly loaded sequence. Recommended.

public bool Preload

Field Value

bool

RetriggerPausedNotes

If the notes that were playing when the sequencer was paused should be re-triggered. Defaults to true.

public bool RetriggerPausedNotes

Field Value

bool

ShuffledSongIndexes

The shuffled song indexes. This is used when shuffle mode is enabled.

public readonly List<int> ShuffledSongIndexes

Field Value

List<int>

SkipToFirstNoteOn

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

public bool SkipToFirstNoteOn

Field Value

bool

Synth

The synthesizer connected to the sequencer.

public readonly SpessaSharpProcessor Synth

Field Value

SpessaSharpProcessor

Properties

BPM

public int BPM { get; }

Property Value

int

CurrentTime

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

public TimeSpan CurrentTime { get; set; }

Property Value

TimeSpan

Duration

The length of the current sequence in seconds.

public TimeSpan Duration { get; }

Property Value

TimeSpan

IsFinished

Indicates if the sequencer has finished playing.

public bool IsFinished { get; }

Property Value

bool

Midi

The currently loaded MIDI data.

public Midi? Midi { get; }

Property Value

Midi

Paused

True if paused, false if playing or stopped

public bool Paused { get; }

Property Value

bool

PlaybackRate

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

public float PlaybackRate { get; set; }

Property Value

float

ShuffleMode

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.

public bool ShuffleMode { get; set; }

Property Value

bool

SongIndex

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

public int SongIndex { get; set; }

Property Value

int

Songs

public ReadOnlySpan<Midi> Songs { get; }

Property Value

ReadOnlySpan<Midi>

Tick

public int Tick { get; }

Property Value

int

TimeSignature

public (int Top, int Bottom) TimeSignature { get; }

Property Value

(int Min, int Max)

Methods

Add(Midi)

Adds a new song to the playlist if wasn't added yet

public int Add(Midi song)

Parameters

song Midi

The song to add

Returns

int

The index of the added song

LoadNewSongList(IEnumerable<Midi>)

Loads a new song list into the sequencer.

public void LoadNewSongList(IEnumerable<Midi> midiBuffers)

Parameters

midiBuffers IEnumerable<Midi>

The list of songs to load.

Pause()

Pauses the playback.

public void Pause()

Play()

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

public void Play()

ProcessTick()

Processes a single MIDI tick. You should call this every rendering quantum to process the sequencer events in real-time.

public void ProcessTick()

Remove(Midi)

Removes the song from the playlist if existed before

public bool Remove(Midi song)

Parameters

song Midi

The song to be removed

Returns

bool

Whether the playlist contained the song

Remove(int)

Removes the song from the playlist if existed before

public bool Remove(int songIndex)

Parameters

songIndex int

The song index to be removed

Returns

bool

Whether the playlist contained the song

Stop()

Stops the playback

public void Stop()