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
procSpessaSharpProcessorThe 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
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
OnEventCall
Called when the sequencer calls an event.
public Action<Event>? OnEventCall
Field Value
Preload
Indicates if the synthesizer should preload the voices for the newly loaded sequence. Recommended.
public bool Preload
Field Value
RetriggerPausedNotes
If the notes that were playing when the sequencer was paused should be re-triggered. Defaults to true.
public bool RetriggerPausedNotes
Field Value
ShuffledSongIndexes
The shuffled song indexes. This is used when shuffle mode is enabled.
public readonly List<int> ShuffledSongIndexes
Field Value
SkipToFirstNoteOn
Indicates if the sequencer should skip to the first note on event. Defaults to true.
public bool SkipToFirstNoteOn
Field Value
Synth
The synthesizer connected to the sequencer.
public readonly SpessaSharpProcessor Synth
Field Value
Properties
BPM
public int BPM { get; }
Property Value
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
Duration
The length of the current sequence in seconds.
public TimeSpan Duration { get; }
Property Value
IsFinished
Indicates if the sequencer has finished playing.
public bool IsFinished { get; }
Property Value
Midi
The currently loaded MIDI data.
public Midi? Midi { get; }
Property Value
Paused
True if paused, false if playing or stopped
public bool Paused { get; }
Property Value
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
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
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
Songs
public ReadOnlySpan<Midi> Songs { get; }
Property Value
Tick
public int Tick { get; }
Property Value
TimeSignature
public (int Top, int Bottom) TimeSignature { get; }
Property Value
Methods
Add(Midi)
Adds a new song to the playlist if wasn't added yet
public int Add(Midi song)
Parameters
songMidiThe 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
midiBuffersIEnumerable<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
songMidiThe 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
songIndexintThe song index to be removed
Returns
- bool
Whether the playlist contained the song
Stop()
Stops the playback
public void Stop()