Basic voice allocator with low/high note priority.
Version: 1.1.0
License:
Advanced versions:
Requires:
Included in Brickworks, which is:
Here you can download one or more example VST3 plugins for Windows, macOS and Linux. Source code of the audio engine(s) is included in the archive(s).
| Description | Link |
|---|---|
| Polyphonic subtractive synth | Download |

Module type: Utility
typedef enum {
bw_voice_alloc_priority_low,
bw_voice_alloc_priority_high
} bw_voice_alloc_priority;
Note priority:
bw_voice_alloc_priority_low: low note priority;bw_voice_alloc_priority_high: high note priority.typedef struct {
bw_voice_alloc_priority priority;
void (*note_on)(
void * BW_RESTRICT voice,
unsigned char note,
float velocity);
void (*note_off)(
void * BW_RESTRICT voice,
float velocity);
unsigned char (*get_note)(
const void * BW_RESTRICT voice);
char (*is_free)(
const void * BW_RESTRICT voice);
} bw_voice_alloc_opts;
Voice allocation options:
priority: note priority;note_on: note on callback, where voice is an opaque pointer to the chosen voice, note is the note number, and velocity is the note velocity in [0.f, 1.f] or otherwise negative to indicate unknown / not available;note_off: note off callback, where voice is an opaque pointer to the chosen voice and velocity is the note velocity in [0.f, 1.f] or otherwise negative to indicate unknown / not available;get_note: callback that returns the note number associated to the given voice;is_free: callback that returns whether the given voice is free (non-0) or not (0);static inline void bw_voice_alloc(
const bw_voice_alloc_opts * BW_RESTRICT opts,
bw_note_queue * BW_RESTRICT queue,
void * BW_RESTRICT const * BW_RESTRICT voices,
size_t n_voices);
It performs voice allocation according to opts and using the events in queue.
voices is the array of opaque voice pointers and n_voices indicates the number of elements in voices.
static inline to bw_voice_alloc().BW_INCLUDE_WITH_QUOTES and BW_CXX_NO_EXTERN_C.BW_NULL.bw_voice_alloc_opts.size_t instead of BW_SIZE_T.const and BW_RESTRICT where needed to callback types in bw_voice_alloc_opts and to bw_voice_alloc().BW_SIZE_T to count voices in bw_voice_alloc().