DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::plugin::clap_backend::VoiceTable< NumPerVoice > Class Template Reference

The voices this backend started (one per NoteOn it delivered), with the host's modulation amount of every perVoice() parameter for each one. More...

#include <DSParkClap.h>

Classes

struct  Voice
 A voice's identity (the part every scan reads; kept small). More...
 
struct  VoiceParams
 What the host set for each perVoice() parameter of one voice. More...
 

Public Member Functions

void clear () noexcept
 
int start (int channel, int key, int32_t noteId) noexcept
 
int oldest () const noexcept
 
int end () const noexcept
 
template<typename Fn >
void forEachMatching (int port, int channel, int key, int32_t noteId, Fn &&fn) noexcept
 
Voice & operator[] (int slot) noexcept
 
VoiceParams & paramsOf (int slot) noexcept
 
void release (int slot) noexcept
 

Static Public Attributes

static constexpr int kCapacity = 128
 

Detailed Description

template<size_t NumPerVoice>
class dspark::plugin::clap_backend::VoiceTable< NumPerVoice >

The voices this backend started (one per NoteOn it delivered), with the host's modulation amount of every perVoice() parameter for each one.

CLAP addresses voices by (port, channel, key, note id), any part -1 for "any". MidiEvent names one voice, so the backend resolves each per-voice event (note expression, polyphonic modulation, per-note automation) against this table and delivers it once per matching voice - which also covers the per-key, per-channel and per-port forms. Audio thread only; fixed capacity, no allocation. When every slot is in use, a new voice takes the slot of the oldest one (a released voice first): the backend reports that voice's end to the host first, so every voice the host started still receives exactly one NOTE_END.

Definition at line 127 of file DSParkClap.h.

Member Function Documentation

◆ clear()

template<size_t NumPerVoice>
void dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::clear ( )
inlinenoexcept

Definition at line 154 of file DSParkClap.h.

◆ end()

template<size_t NumPerVoice>
int dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::end ( ) const
inlinenoexcept

One past the highest slot in use (scans stop there).

Definition at line 211 of file DSParkClap.h.

◆ forEachMatching()

template<size_t NumPerVoice>
template<typename Fn >
void dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::forEachMatching ( int  port,
int  channel,
int  key,
int32_t  noteId,
Fn &&  fn 
)
inlinenoexcept

Calls fn(slot) for every voice the address matches (each part -1 for "any"; the one note port has index 0).

Definition at line 216 of file DSParkClap.h.

◆ oldest()

template<size_t NumPerVoice>
int dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::oldest ( ) const
inlinenoexcept

The slot a new voice takes when the table is full: the oldest released voice, else the oldest one; -1 when no voice is in use.

Definition at line 189 of file DSParkClap.h.

◆ operator[]()

template<size_t NumPerVoice>
Voice & dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::operator[] ( int  slot)
inlinenoexcept

Definition at line 231 of file DSParkClap.h.

◆ paramsOf()

template<size_t NumPerVoice>
VoiceParams & dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::paramsOf ( int  slot)
inlinenoexcept

The perVoice() parameter state of voice slot.

Definition at line 234 of file DSParkClap.h.

◆ release()

template<size_t NumPerVoice>
void dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::release ( int  slot)
inlinenoexcept

Frees voice slot.

Definition at line 240 of file DSParkClap.h.

◆ start()

template<size_t NumPerVoice>
int dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::start ( int  channel,
int  key,
int32_t  noteId 
)
inlinenoexcept

Starts a voice; returns its slot, or -1 when every slot is in use.

Definition at line 161 of file DSParkClap.h.

Member Data Documentation

◆ kCapacity

template<size_t NumPerVoice>
constexpr int dspark::plugin::clap_backend::VoiceTable< NumPerVoice >::kCapacity = 128
staticconstexpr

Definition at line 130 of file DSParkClap.h.


The documentation for this class was generated from the following file: