Table of Contents

Class UINoteQueue

Namespace
PluginUI.NPlug
Assembly
PluginUI.NPlug.dll

Bounded queue carrying UINoteEvents from the UI thread to the audio thread. The audio side (TryDequeue(out UINoteEvent)) never blocks nor allocates; producers are serialized by a lock that the audio thread never takes.

public sealed class UINoteQueue
Inheritance
UINoteQueue
Inherited Members

Remarks

When the queue is full (host not calling process), note-ons are dropped and TryEnqueue(in UINoteEvent) returns false, but note-offs and "all notes off" are never lost: they are kept in a per-channel bitmap, delivered after the queued events, and note-ons are refused until that backlog is drained. No note can stay stuck.

Constructors

UINoteQueue(int)

Creates a queue.

public UINoteQueue(int capacity = 256)

Parameters

capacity int

Capacity, rounded up to a power of two (at least 2).

Properties

Capacity

Capacity of the queue.

public int Capacity { get; }

Property Value

int

Count

Number of events waiting (approximate while another thread works on the queue).

public int Count { get; }

Property Value

int

Methods

TryDequeue(out UINoteEvent)

Takes the oldest event (single consumer: the audio thread).

public bool TryDequeue(out UINoteEvent note)

Parameters

note UINoteEvent

The event.

Returns

bool

false if the queue is empty.

TryEnqueue(in UINoteEvent)

Adds an event (any thread except the audio thread).

public bool TryEnqueue(in UINoteEvent note)

Parameters

note UINoteEvent

The event.

Returns

bool

false if the queue was full and the event was dropped.