Class NoteStreamRunner
- Namespace
- Sigil.Sound
- Assembly
- Sigil.Sound.Notes.dll
A Sigil.Sound.NoteStream built to run: a host calls Sigil.Sound.NoteStreamRunner.Process(System.Int32) once per block and reads the notes that come out, to send them to a device or an instrument of its own. This is the other half of Sigil.Sound.NoteStream.Play(System.Func{Sigil.Sound.Voice,Sigil.Sound.Sound},System.Int32), which plays the notes itself.
public sealed class NoteStreamRunner : IDisposableInheritance
Implements
Inherited Members
Remarks
Not thread safe: one thread (the audio thread, normally) calls Sigil.Sound.NoteStreamRunner.Process(System.Int32), Sigil.Sound.NoteStreamRunner.Poll and Sigil.Sound.NoteStreamRunner.Reset. The input side takes its notes from control threads through a lock-free queue and needs nothing from you.
Call Sigil.Sound.NoteStreamRunner.Process(System.Int32) before the host clock advances for the block, as the clock then still reads the block's first beat. The events it returns are valid until the next call.
Properties
Dropped
Starts that were dropped because a step of the stream was full. Zero in normal use.
public int Dropped { get; }Property Value
Seconds
The time, in seconds, that the blocks passed to Sigil.Sound.NoteStreamRunner.Process(System.Int32) and Sigil.Sound.NoteStreamRunner.Poll add up to.
public double Seconds { get; }Property Value
Sounding
Notes the stream has sounding now.
public int Sounding { get; }Property Value
Methods
Dispose()
Stops listening to the input. The notes still sounding are not ended; call Sigil.Sound.NoteStreamRunner.Reset first for that.
public void Dispose()Poll()
Runs the stream for the time that has passed since the last call to this method or Sigil.Sound.NoteStreamRunner.Process(System.Int32), as the clock (or, without one, the wall clock) tells. This is for readers that are asked at no fixed rate: a pattern that follows the stream is queried once per block by whoever plays it, and each query catches the stream up.
public ReadOnlySpan<NoteEvent> Poll()Returns
- ReadOnlySpan<NoteEvent>
-
The events of the elapsed time, valid until the next call.
Process(int)
Runs the stream for the next block of frames frames and returns the events that fall in it, in order.
public ReadOnlySpan<NoteEvent> Process(int frames)Parameters
framesint-
The block length, 0 or more. A host may pass 0 to read what has arrived without letting time pass.
Returns
- ReadOnlySpan<NoteEvent>
-
The starts and ends of the block, valid until the next call.
Reset()
Forgets all state, as for a stop, a bypass or a transport locate, and returns the ends of the notes that were sounding so the host can pass them on. Keys still held start again with the next block.
public ReadOnlySpan<NoteEvent> Reset()Returns
- ReadOnlySpan<NoteEvent>
-
The ends of every note the stream had sounding, valid until the next call.