DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::plugin Namespace Reference

Namespaces

namespace  clap_backend
 
namespace  vst3
 
namespace  webview_ui
 

Classes

class  ActiveNotes
 The notes a backend has delivered as sounding, per channel and key, with the host note id each started with. More...
 
struct  BlockEvent
 One timestamped in-block event, normalised across formats: a parameter point, a bypass point, or a MIDI event. The backends collect them per block, sort them, and either split processing at quantum boundaries (sample-accurate mode) or apply them all up front. More...
 
class  BlockEventList
 The fixed-capacity, allocation-free event list one block of host events is collected into (a member of each backend's plugin object, so nothing large lives on the audio thread's stack). More...
 
struct  Descriptor
 Static identity of a plugin. All fields are plain literals so the whole descriptor can live in a static constexpr of the user class. More...
 
class  DryDelay
 The dry signal of the wrappers' soft bypass, delayed by the plugin's latency. More...
 
struct  EditorSize
 Editor window size in logical pixels (physical = logical x host scale). More...
 
class  EditorSizeMemory
 The editor size the user last left, in logical pixels, kept by each backend across editor re-opens and saved in the state container (the reserved 'EDSW' / 'EDSH' entries), so a session reopens its editor at that size - in every format, since the size is logical. Only a resizable editor (EditorResize Free or KeepAspect) persists a size; a Fixed one always opens at editorSize. A remembered size is re-checked against the policy, so a later version with another size or policy never opens out of bounds. More...
 
struct  MidiEvent
 One incoming MIDI-ish event, normalised across formats. More...
 
struct  Param
 One automatable parameter. Plain values run [min, max]; hosts see the normalized [0, 1] projection. steps == 0 means continuous, steps == 1 a toggle, steps == N an N+1-position discrete control. A discrete control may name its positions (labels, steps+1 entries): hosts then display and accept those names. Build these with the helpers below - param(), toggle(), stepped(), choice(). More...
 
class  PendingParams
 Parameter changes made OFF the audio thread, handed to it. More...
 
struct  PluginBase
 Optional convenience base that makes EVERY contract method visible and overridable from one place - IDE-discoverable, without the virtuals. More...
 
struct  PresetDef
 One factory preset: a name plus a PLAIN value for every parameter, in parameter-table order. Build the table with preset()/presets() so the value count is checked at compile time against the parameter count. More...
 
struct  TransportInfo
 Host transport snapshot, delivered once per audio block. More...
 

Concepts

concept  HasReset
 
concept  HasLatency
 
concept  HasTail
 
concept  HasGetState
 
concept  HasSetState
 
concept  HasEditor
 Custom-editor switch. With hasEditor = false (or absent) hosts show their generic parameter UI. With hasEditor = true AND plugin/webview/DSParkWebViewEditor.h included BEFORE the format headers, the WebView editor layer serves editorHtml() inside the host window.
 
concept  HasSidechain
 Sidechain capability. Implement the two-buffer process - the same shape DSPark's own dynamics take:
 
concept  HasTransport
 Transport capability: void setTransport(const TransportInfo&) noexcept. Called on the audio thread, before processBlock, whenever the host supplied transport data for the block (no call means "same as last block"). This is how tempo-synced delays, LFOs and gates follow the song.
 
concept  HasNoteExpressions
 Optional note-expression declaration: static constexpr uint32_t noteExpressions = expressions(...) - the NoteExpression types the plugin acts on. VST3 hosts offer exactly these in their note-expression editors (INoteExpressionController; Pressure travels as VST3 poly pressure instead), so a class without the declaration gets no VST3 expressions. CLAP hosts send expressions undeclared, and the wrapper delivers only the declared ones when the declaration exists (all of them without it).
 
concept  HasVoiceQuery
 Optional voice query: bool isVoiceActive(int channel, int key, int32_t noteId) const noexcept - true while the voice that NoteOn started still sounds (its release tail included). With perVoice() parameters a CLAP host keeps a modulator per voice and the wrapper tells it when a voice is over (CLAP NOTE_END): with this query, when the voice actually falls silent; without it, at its NoteOff. Called on the audio thread after each processed block; answer from the voice array, never allocate or lock. noteId is -1 when the host gave the note none.
 
concept  HasMidi
 MIDI capability: void handleMidiEvent(const MidiEvent&) noexcept. Its presence grows a note/event input in every format (VST3 event bus, CLAP note port, AU music-device selectors) - which is also why PluginBase deliberately ships no default for it. Required for Category::Instrument, optional for MIDI-driven effects. Audio thread; allocation-free.
 
concept  HasOfflineMode
 Render-mode capability: void setOfflineRendering(bool) noexcept. The host flips it to true for non-realtime bounces (VST3 kOffline setup, the CLAP render extension, AU OfflineRender) - the moment to switch to more expensive algorithms (higher oversampling, longer lookahead). Called outside the audio thread, before processing (re)starts. Default: assume realtime.
 
concept  HasChannelSupport
 
concept  HasFactoryPresets
 Factory-preset capability: a static constexpr auto factoryPresets table built with presets(). The backends publish it natively - a VST3 program list, CLAP preset-load + preset-discovery, AU factory presets - so the host's own preset browser offers them. No PluginBase default on purpose: the table's presence changes what hosts display.
 
concept  HasSampleAccurateOptOut
 Sample-accurate opt-out: static constexpr bool sampleAccurateAutomation = false;. By default the wrappers split each audio block at automation points (snapped to kAutomationQuantum frames) so fast curves land where the host drew them instead of stepping once per block. Opt out when your plugin has a high fixed cost per processBlock CALL and block-rate automation is acceptable.
 
concept  HasEditorHtml
 static const char* editorHtml() - the editor page (HTML/CSS/JS), usually a raw string literal. Required when hasEditor is true.
 
concept  HasEditorSize
 Optional static constexpr EditorSize editorSize { w, h };.
 
concept  HasEditorResizable
 Optional static constexpr bool editorResizable = true; - shorthand for editorResize = EditorResize::Free (default: fixed size).
 
concept  HasEditorResize
 Optional static constexpr EditorResize editorResize = ...; - full resize policy; takes precedence over editorResizable.
 
concept  HasEditorDebug
 Optional static constexpr bool editorDebug = true; - enables the browser DevTools in the editor (WebView2; development builds only).
 
concept  HasEditorDevFile
 Optional static const char* editorDevFile() - absolute path of an HTML file to load INSTEAD of editorHtml() while developing: edit the file, reopen the editor, no recompile. Falls back to editorHtml() when the file is missing, so the same build still works elsewhere. Strip from releases.
 

Enumerations

enum class  Category { Fx , Instrument }
 Plugin category (reflected into each format's class metadata). More...
 
enum class  ChannelSupport { MonoAndStereo , StereoOnly , MonoOnly }
 Bus widths a plugin offers to the host. The DSPark contract is channel-agnostic by construction (prepare() receives numChannels and processBlock honours io.numChannels()), so the DEFAULT is mono+stereo: the plugin appears on every track type. Declare static constexpr auto channels = dspark::plugin::ChannelSupport::...; only to restrict it (e.g. StereoOnly for M/S wideners). All buses of an instance run the same width - a sidechain follows the main pair. More...
 
enum class  EditorResize { Fixed , Free , KeepAspect }
 How the host may resize the editor window. Declare static constexpr EditorResize editorResize = ...; in the plugin class; without it the window is Fixed (or Free if the simpler editorResizable = true shorthand is present). More...
 

Functions

constexpr Param param (const char *id, const char *name, float minValue, float maxValue, float defValue, const char *unit) noexcept
 Continuous parameter helper.
 
constexpr Param toggle (const char *id, const char *name, bool defaultOn) noexcept
 On/off parameter helper.
 
constexpr Param stepped (const char *id, const char *name, float minValue, float maxValue, float defValue, int steps, const char *unit="") noexcept
 Discrete parameter helper: steps + 1 evenly spaced positions from minValue to maxValue, e.g. stepped("voices", "Voices", 1, 8, 4, 7) for 1..8 (hosts show whole numbers when the positions are integers).
 
template<size_t N>
constexpr Param choice (const char *id, const char *name, const char *const (&labels)[N], int defaultIndex=0) noexcept
 Named-choice helper: one position per label, plain values 0..N-1 (the label index), e.g.
 
constexpr Param perVoice (Param p) noexcept
 Marks a parameter as modulatable per voice: params(perVoice(param("cutoff", "Cutoff", 20.0f, 20000.0f, 1000.0f, "Hz")), ...).
 
constexpr bool isToggle (const Param &p) noexcept
 True for an on/off parameter (two unnamed positions).
 
template<typename... Ps>
constexpr std::array< Param, sizeof...(Ps)> params (Ps... ps) noexcept
 Builds the parameter table (use inside static constexpr auto).
 
constexpr double toNormalized (const Param &p, double plain) noexcept
 Plain [min, max] -> normalized [0, 1] (steps snap on the way back).
 
constexpr double toPlain (const Param &p, double normalized) noexcept
 Normalized [0, 1] -> plain [min, max], snapped for stepped params.
 
int parseToggleText (const char *text) noexcept
 Case-insensitive "On"/"Off" recognition - the inverse of the toggle display below. Returns 1 for On, 0 for Off, -1 for anything else. Hosts round-trip displayed strings through text-to-value (automation lanes, typed values), so toggles must parse their own output.
 
constexpr int stepIndex (const Param &p, double plain) noexcept
 Position index (0..steps) of a plain value of a discrete parameter.
 
void formatValue (const Param &p, double plain, char *out, int outSize) noexcept
 Formats a plain value for host display ("3.5 dB", "On", "Saw", "4").
 
bool parseValue (const Param &p, const char *text, double &plain) noexcept
 Host text -> plain value, the inverse of formatValue(): a choice's label (any case), "On"/"Off" for a toggle, or a number (a trailing unit is ignored). The result is clamped to the range and snapped for discrete parameters. Returns false, leaving plain untouched, for text that is none of these (hosts then keep the current value).
 
constexpr uint32_t hash32 (const char *s) noexcept
 FNV-1a 32-bit over a C string - the per-parameter host id.
 
constexpr uint64_t hash64 (const char *s, uint64_t salt) noexcept
 FNV-1a 64-bit with a salt (two runs build a 128-bit class UID).
 
template<typename P >
constexpr bool paramIdsUnique () noexcept
 Compile-time guarantee that every parameter id hashes uniquely and collides with no id the wrappers reserve: the state ids 'PRGM', 'BYPS', 'EDSW' and 'EDSH', and the 0x4D44xxxx range the VST3 backend uses for its hidden MIDI controller parameters. A collision would silently cross-wire automation and state, so the backends refuse to build: static_assert(paramIdsUnique<MyPlugin>());.
 
template<typename P >
constexpr int paramIndexOf (uint32_t id) noexcept
 Table index of the parameter whose host id is id, or -1.
 
template<typename P >
constexpr size_t perVoiceParamCount () noexcept
 Number of parameters of P marked with perVoice().
 
constexpr std::array< uint8_t, 16 > makeUid (const char *productId, uint64_t salt) noexcept
 Deterministic 16-byte class UID from the stable productId. Each backend salts differently so VST3/CLAP/AU ids never collide.
 
constexpr uint32_t expressionBit (MidiEvent::ExpressionType type) noexcept
 The bit of one ExpressionType in a note-expression mask.
 
template<typename... Types>
constexpr uint32_t expressions (Types... types) noexcept
 Builds a note-expression mask for the noteExpressions declaration:
 
template<typename P >
constexpr uint32_t noteExpressionsOf () noexcept
 The note expressions P receives: its declaration, else all.
 
template<typename P >
constexpr ChannelSupport channelSupportOf () noexcept
 The declared channel support of P (default: mono+stereo).
 
template<typename P >
constexpr bool supportsChannelCount (int numChannels) noexcept
 True when P accepts a bus width of numChannels (1 or 2).
 
template<typename P >
constexpr int defaultChannelCount () noexcept
 The width every backend starts in before the host negotiates.
 
template<typename... Vs>
constexpr PresetDef< sizeof...(Vs)> preset (const char *name, Vs... values) noexcept
 Builds one factory preset: preset("Warm", 6.0f, 0.8f, ...) - one PLAIN value per parameter, in table order.
 
template<typename First , typename... Rest>
constexpr std::array< First, 1+sizeof...(Rest)> presets (First first, Rest... rest) noexcept
 Builds the factory preset table (all presets must cover the same parameter count - enforced here; matched against the parameter table by the backends). Declare as static constexpr auto factoryPresets = ....
 
template<typename P >
constexpr int factoryPresetCountOf () noexcept
 Number of factory presets of P (0 when none declared).
 
template<typename P >
constexpr double presetNormalized (int presetIndex, size_t paramIndex) noexcept
 Normalized value of parameter paramIndex in factory preset presetIndex (bounds already validated by the caller).
 
template<typename P >
constexpr bool sampleAccurateOf () noexcept
 
void sortBlockEvents (BlockEvent *events, int count) noexcept
 Insertion sort by (offset, arrival order) - tiny N, allocation-free, audio-thread safe; equal offsets keep arrival order.
 
template<typename P >
constexpr EditorSize editorSizeOf () noexcept
 The declared (logical) editor size, or the 480x320 default.
 
template<typename P >
constexpr EditorResize editorResizeOf () noexcept
 The effective resize policy for plugin class P.
 
constexpr int toBoundedInt (double value, int lo, int hi) noexcept
 A floating value from outside converted to an integer, with the range settled BEFORE the conversion.
 
template<typename P >
constexpr void constrainEditorSize (double &width, double &height, double scale) noexcept
 Applies the resize policy of P to a size the host proposes: Fixed pins it, Free clamps each axis to the 0.5x..3x window, KeepAspect fits the declared ratio INSIDE the proposal - never exceeding it on either axis. That last property is essential: hosts size the plugin area inside a window the user controls, so answering "larger" on any axis pushes the plugin outside its own window (clipped bottom in REAPER).
 
template<typename P >
std::vector< uint8_t > buildState (const P &user, const double *normalized, size_t numParams, int programIndex=-1, int bypassState=-1, const EditorSize *editorSize=nullptr)
 Serialises the plugin state: every parameter (normalized), the active factory preset (programIndex, -1 for none), the host bypass (bypassState, -1 for none), the editor size the user left (editorSize, null for none) and the user's own getState() section.
 
template<typename P >
void loadDefaultNormalized (double *normalized) noexcept
 Fills normalized with every parameter's DEFAULT (normalized): what a state load starts from, so a parameter the blob does not carry (added in a later version) takes its default rather than whatever value the instance happened to hold.
 
template<typename P >
bool applyState (P &user, const uint8_t *data, size_t size, double *normalized, int *programIndex=nullptr, int *bypassState=nullptr, EditorSize *editorSize=nullptr)
 Parses a state blob; fills normalized (defaults pre-loaded by the caller, see loadDefaultNormalized), reports a persisted program index, bypass and editor size through programIndex, bypassState and editorSize (each left untouched when absent; the size only when both of its entries are present) and forwards the user section. Returns false on a foreign blob.
 

Variables

template<typename P >
constexpr auto paramIdTable
 The hash32 of every parameter id of P, computed at compile time (table order), so id lookups on the audio thread compare integers instead of re-hashing every id string for every event.
 
template<typename P >
constexpr auto perVoiceSlotTable
 For every parameter of P, its position among the perVoice() parameters (table order), or -1 for a parameter without the mark.
 
constexpr uint32_t kAllNoteExpressions
 Every ExpressionType at once (the mask of a class that declares none).
 
constexpr int kAutomationQuantum = 32
 Sub-block grain: automation/event splits snap to this many frames (bounds the per-call overhead; ~0.7 ms at 48 kHz is inaudible).
 
constexpr int kMaxBlockEvents = 256
 Capacity of the per-block event list. Past it the list merges rather than drops: an intermediate parameter point gives up its slot (the newest point of every parameter and every MIDI event are kept), so only a block carrying more than this many distinct parameters plus MIDI events loses anything. See BlockEventList.
 
constexpr int kDryDelayMinCapacity = 8192
 Ring headroom of the bypass dry path: latencies up to this (or twice the latency at activation, if larger) stay sample-aligned when a plugin's lookahead grows while running.
 
constexpr double kEditorMinSizeFactor = 0.5
 Resize bounds: hosts may shrink to half and grow to 3x the declared size.
 
constexpr double kEditorMaxSizeFactor = 3.0
 
constexpr double kEditorMaxPixels = 32767.0
 Pixel ceiling for a negotiated editor size.
 
constexpr uint32_t kStateMagic = 0x4453504Bu
 
constexpr uint32_t kStateVersion = 1u
 
constexpr size_t kMaxStateBytes = size_t { 1 } << 30
 Largest state a backend reads back (1 GiB). It only bounds a hostile, endless host stream: getState() itself has no size limit, so any cap a real state could exceed would break the save/load round trip.
 
constexpr uint32_t kProgramStateId = 0x5052474Du
 Reserved entry id persisting the active factory-preset index ('PRGM'); never a user parameter. Older builds skip it (unknown id).
 
constexpr uint32_t kBypassStateId = 0x42595053u
 Reserved entry id persisting the host bypass ('BYPS' - the same value every backend uses as the bypass ParamID). Hosts treat bypass as one more parameter, so it must survive a state round-trip like any other. Older builds skip it (unknown id).
 
constexpr uint32_t kEditorWidthStateId = 0x45445357u
 Reserved entry ids persisting the editor size the user left ('EDSW' / 'EDSH', logical pixels; see EditorSizeMemory). Older builds skip them (unknown ids).
 
constexpr uint32_t kEditorHeightStateId = 0x45445348u
 

Enumeration Type Documentation

◆ Category

enum class dspark::plugin::Category
strong

Plugin category (reflected into each format's class metadata).

Fx processes audio in place (optionally keyed by a sidechain or driven by MIDI - a vocoder, a MIDI-gated effect). Instrument GENERATES audio: it has no main audio input in any format (VST3 instrument class, CLAP "instrument" feature, AU aumu music device) and almost always pairs with handleMidiEvent (see HasMidi). The wrapper clears the output buffers before calling an instrument's processBlock, so voices ADD into io without reading it.

Enumerator
Fx 

Audio effect (audio in -> audio out).

Instrument 

Audio generator (MIDI in -> audio out, no audio input).

Definition at line 100 of file DSParkPlugin.h.

◆ ChannelSupport

enum class dspark::plugin::ChannelSupport
strong

Bus widths a plugin offers to the host. The DSPark contract is channel-agnostic by construction (prepare() receives numChannels and processBlock honours io.numChannels()), so the DEFAULT is mono+stereo: the plugin appears on every track type. Declare static constexpr auto channels = dspark::plugin::ChannelSupport::...; only to restrict it (e.g. StereoOnly for M/S wideners). All buses of an instance run the same width - a sidechain follows the main pair.

Enumerator
MonoAndStereo 

Negotiates 1->1 or 2->2 with the host (default).

StereoOnly 

Strictly 2->2 (inherently stereo DSP).

MonoOnly 

Strictly 1->1 (rare; metering/utility plugins).

Definition at line 771 of file DSParkPlugin.h.

◆ EditorResize

enum class dspark::plugin::EditorResize
strong

How the host may resize the editor window. Declare static constexpr EditorResize editorResize = ...; in the plugin class; without it the window is Fixed (or Free if the simpler editorResizable = true shorthand is present).

Enumerator
Fixed 

The window is exactly editorSize; hosts cannot drag-resize it.

Free 

Drag-resizable between 0.5x and 3x the declared size.

KeepAspect 

Drag-resizable, locked to the declared width:height ratio.

Definition at line 1309 of file DSParkPlugin.h.

Function Documentation

◆ applyState()

template<typename P >
bool dspark::plugin::applyState ( P &  user,
const uint8_t *  data,
size_t  size,
double *  normalized,
int *  programIndex = nullptr,
int *  bypassState = nullptr,
EditorSize *  editorSize = nullptr 
)
inline

Parses a state blob; fills normalized (defaults pre-loaded by the caller, see loadDefaultNormalized), reports a persisted program index, bypass and editor size through programIndex, bypassState and editorSize (each left untouched when absent; the size only when both of its entries are present) and forwards the user section. Returns false on a foreign blob.

Definition at line 1751 of file DSParkPlugin.h.

◆ buildState()

template<typename P >
std::vector< uint8_t > dspark::plugin::buildState ( const P &  user,
const double *  normalized,
size_t  numParams,
int  programIndex = -1,
int  bypassState = -1,
const EditorSize *  editorSize = nullptr 
)
inline

Serialises the plugin state: every parameter (normalized), the active factory preset (programIndex, -1 for none), the host bypass (bypassState, -1 for none), the editor size the user left (editorSize, null for none) and the user's own getState() section.

Definition at line 1673 of file DSParkPlugin.h.

◆ channelSupportOf()

template<typename P >
constexpr ChannelSupport dspark::plugin::channelSupportOf ( )
constexprnoexcept

The declared channel support of P (default: mono+stereo).

Definition at line 785 of file DSParkPlugin.h.

◆ choice()

template<size_t N>
constexpr Param dspark::plugin::choice ( const char *  id,
const char *  name,
const char *const (&)  labels[N],
int  defaultIndex = 0 
)
constexprnoexcept

Named-choice helper: one position per label, plain values 0..N-1 (the label index), e.g.

static constexpr const char* kWaves[] = { "Sine", "Saw", "Square" };
static constexpr auto parameters = params(choice("wave", "Waveform", kWaves, 1));
constexpr std::array< Param, sizeof...(Ps)> params(Ps... ps) noexcept
Builds the parameter table (use inside static constexpr auto).
constexpr Param choice(const char *id, const char *name, const char *const (&labels)[N], int defaultIndex=0) noexcept
Named-choice helper: one position per label, plain values 0..N-1 (the label index),...

setParameter() receives the index as a float; hosts show and accept the labels. The label array must outlive the table (a static constexpr array).

Definition at line 186 of file DSParkPlugin.h.

◆ constrainEditorSize()

template<typename P >
constexpr void dspark::plugin::constrainEditorSize ( double &  width,
double &  height,
double  scale 
)
constexprnoexcept

Applies the resize policy of P to a size the host proposes: Fixed pins it, Free clamps each axis to the 0.5x..3x window, KeepAspect fits the declared ratio INSIDE the proposal - never exceeding it on either axis. That last property is essential: hosts size the plugin area inside a window the user controls, so answering "larger" on any axis pushes the plugin outside its own window (clipped bottom in REAPER).

Definition at line 1410 of file DSParkPlugin.h.

◆ defaultChannelCount()

template<typename P >
constexpr int dspark::plugin::defaultChannelCount ( )
constexprnoexcept

The width every backend starts in before the host negotiates.

Definition at line 805 of file DSParkPlugin.h.

◆ editorResizeOf()

template<typename P >
constexpr EditorResize dspark::plugin::editorResizeOf ( )
constexprnoexcept

The effective resize policy for plugin class P.

Definition at line 1355 of file DSParkPlugin.h.

◆ editorSizeOf()

template<typename P >
constexpr EditorSize dspark::plugin::editorSizeOf ( )
constexprnoexcept

The declared (logical) editor size, or the 480x320 default.

Definition at line 1332 of file DSParkPlugin.h.

◆ expressionBit()

constexpr uint32_t dspark::plugin::expressionBit ( MidiEvent::ExpressionType  type)
constexprnoexcept

The bit of one ExpressionType in a note-expression mask.

Definition at line 671 of file DSParkPlugin.h.

◆ expressions()

template<typename... Types>
constexpr uint32_t dspark::plugin::expressions ( Types...  types)
constexprnoexcept

Builds a note-expression mask for the noteExpressions declaration:

static constexpr uint32_t noteExpressions =
dspark::plugin::expressions(Expr::Volume, Expr::Tuning);
constexpr uint32_t expressions(Types... types) noexcept
Builds a note-expression mask for the noteExpressions declaration:
ExpressionType
The per-voice expressions of Type::NoteExpression.

Definition at line 689 of file DSParkPlugin.h.

◆ factoryPresetCountOf()

template<typename P >
constexpr int dspark::plugin::factoryPresetCountOf ( )
constexprnoexcept

Number of factory presets of P (0 when none declared).

Definition at line 859 of file DSParkPlugin.h.

◆ formatValue()

void dspark::plugin::formatValue ( const Param &  p,
double  plain,
char *  out,
int  outSize 
)
inlinenoexcept

Formats a plain value for host display ("3.5 dB", "On", "Saw", "4").

Definition at line 283 of file DSParkPlugin.h.

◆ hash32()

constexpr uint32_t dspark::plugin::hash32 ( const char *  s)
constexprnoexcept

FNV-1a 32-bit over a C string - the per-parameter host id.

Definition at line 378 of file DSParkPlugin.h.

◆ hash64()

constexpr uint64_t dspark::plugin::hash64 ( const char *  s,
uint64_t  salt 
)
constexprnoexcept

FNV-1a 64-bit with a salt (two runs build a 128-bit class UID).

Definition at line 390 of file DSParkPlugin.h.

◆ isToggle()

constexpr bool dspark::plugin::isToggle ( const Param &  p)
constexprnoexcept

True for an on/off parameter (two unnamed positions).

Definition at line 216 of file DSParkPlugin.h.

◆ loadDefaultNormalized()

template<typename P >
void dspark::plugin::loadDefaultNormalized ( double *  normalized)
inlinenoexcept

Fills normalized with every parameter's DEFAULT (normalized): what a state load starts from, so a parameter the blob does not carry (added in a later version) takes its default rather than whatever value the instance happened to hold.

Definition at line 1738 of file DSParkPlugin.h.

◆ makeUid()

constexpr std::array< uint8_t, 16 > dspark::plugin::makeUid ( const char *  productId,
uint64_t  salt 
)
constexprnoexcept

Deterministic 16-byte class UID from the stable productId. Each backend salts differently so VST3/CLAP/AU ids never collide.

Definition at line 470 of file DSParkPlugin.h.

◆ noteExpressionsOf()

template<typename P >
constexpr uint32_t dspark::plugin::noteExpressionsOf ( )
constexprnoexcept

The note expressions P receives: its declaration, else all.

Definition at line 710 of file DSParkPlugin.h.

◆ param()

constexpr Param dspark::plugin::param ( const char *  id,
const char *  name,
float  minValue,
float  maxValue,
float  defValue,
const char *  unit 
)
constexprnoexcept

Continuous parameter helper.

Definition at line 149 of file DSParkPlugin.h.

◆ paramIdsUnique()

template<typename P >
constexpr bool dspark::plugin::paramIdsUnique ( )
constexprnoexcept

Compile-time guarantee that every parameter id hashes uniquely and collides with no id the wrappers reserve: the state ids 'PRGM', 'BYPS', 'EDSW' and 'EDSH', and the 0x4D44xxxx range the VST3 backend uses for its hidden MIDI controller parameters. A collision would silently cross-wire automation and state, so the backends refuse to build: static_assert(paramIdsUnique<MyPlugin>());.

Definition at line 410 of file DSParkPlugin.h.

◆ paramIndexOf()

template<typename P >
constexpr int dspark::plugin::paramIndexOf ( uint32_t  id)
constexprnoexcept

Table index of the parameter whose host id is id, or -1.

Definition at line 438 of file DSParkPlugin.h.

◆ params()

template<typename... Ps>
constexpr std::array< Param, sizeof...(Ps)> dspark::plugin::params ( Ps...  ps)
constexprnoexcept

Builds the parameter table (use inside static constexpr auto).

Definition at line 223 of file DSParkPlugin.h.

◆ parseToggleText()

int dspark::plugin::parseToggleText ( const char *  text)
inlinenoexcept

Case-insensitive "On"/"Off" recognition - the inverse of the toggle display below. Returns 1 for On, 0 for Off, -1 for anything else. Hosts round-trip displayed strings through text-to-value (automation lanes, typed values), so toggles must parse their own output.

Definition at line 263 of file DSParkPlugin.h.

◆ parseValue()

bool dspark::plugin::parseValue ( const Param &  p,
const char *  text,
double &  plain 
)
inlinenoexcept

Host text -> plain value, the inverse of formatValue(): a choice's label (any case), "On"/"Off" for a toggle, or a number (a trailing unit is ignored). The result is clamped to the range and snapped for discrete parameters. Returns false, leaving plain untouched, for text that is none of these (hosts then keep the current value).

Definition at line 337 of file DSParkPlugin.h.

◆ perVoice()

constexpr Param dspark::plugin::perVoice ( Param  p)
constexprnoexcept

Marks a parameter as modulatable per voice: params(perVoice(param("cutoff", "Cutoff", 20.0f, 20000.0f, 1000.0f, "Hz")), ...).

A host that modulates parameters polyphonically (CLAP per-note, per-key, per-channel and per-port modulation) or automates them per note (CLAP per-note-id, per-key and per-channel automation) then targets single voices, and the plugin receives each voice's value as a MidiEvent of type NoteModulation (see MidiEvent). Requires handleMidiEvent - only a plugin with a note input has voices. Formats without per-voice parameters ignore the mark.

Definition at line 209 of file DSParkPlugin.h.

◆ perVoiceParamCount()

template<typename P >
constexpr size_t dspark::plugin::perVoiceParamCount ( )
constexprnoexcept

Number of parameters of P marked with perVoice().

Definition at line 447 of file DSParkPlugin.h.

◆ preset()

template<typename... Vs>
constexpr PresetDef< sizeof...(Vs)> dspark::plugin::preset ( const char *  name,
Vs...  values 
)
constexprnoexcept

Builds one factory preset: preset("Warm", 6.0f, 0.8f, ...) - one PLAIN value per parameter, in table order.

Definition at line 827 of file DSParkPlugin.h.

◆ presetNormalized()

template<typename P >
constexpr double dspark::plugin::presetNormalized ( int  presetIndex,
size_t  paramIndex 
)
constexprnoexcept

Normalized value of parameter paramIndex in factory preset presetIndex (bounds already validated by the caller).

Definition at line 875 of file DSParkPlugin.h.

◆ presets()

template<typename First , typename... Rest>
constexpr std::array< First, 1+sizeof...(Rest)> dspark::plugin::presets ( First  first,
Rest...  rest 
)
constexprnoexcept

Builds the factory preset table (all presets must cover the same parameter count - enforced here; matched against the parameter table by the backends). Declare as static constexpr auto factoryPresets = ....

Definition at line 836 of file DSParkPlugin.h.

◆ sampleAccurateOf()

template<typename P >
constexpr bool dspark::plugin::sampleAccurateOf ( )
constexprnoexcept

Definition at line 905 of file DSParkPlugin.h.

◆ sortBlockEvents()

void dspark::plugin::sortBlockEvents ( BlockEvent *  events,
int  count 
)
inlinenoexcept

Insertion sort by (offset, arrival order) - tiny N, allocation-free, audio-thread safe; equal offsets keep arrival order.

Definition at line 954 of file DSParkPlugin.h.

◆ stepIndex()

constexpr int dspark::plugin::stepIndex ( const Param &  p,
double  plain 
)
constexprnoexcept

Position index (0..steps) of a plain value of a discrete parameter.

Definition at line 274 of file DSParkPlugin.h.

◆ stepped()

constexpr Param dspark::plugin::stepped ( const char *  id,
const char *  name,
float  minValue,
float  maxValue,
float  defValue,
int  steps,
const char *  unit = "" 
)
constexprnoexcept

Discrete parameter helper: steps + 1 evenly spaced positions from minValue to maxValue, e.g. stepped("voices", "Voices", 1, 8, 4, 7) for 1..8 (hosts show whole numbers when the positions are integers).

Definition at line 167 of file DSParkPlugin.h.

◆ supportsChannelCount()

template<typename P >
constexpr bool dspark::plugin::supportsChannelCount ( int  numChannels)
constexprnoexcept

True when P accepts a bus width of numChannels (1 or 2).

Definition at line 795 of file DSParkPlugin.h.

◆ toBoundedInt()

constexpr int dspark::plugin::toBoundedInt ( double  value,
int  lo,
int  hi 
)
constexprnoexcept

A floating value from outside converted to an integer, with the range settled BEFORE the conversion.

Converting a floating value that does not fit the destination is undefined behaviour, not a wrap: the usual shape - convert, then clamp - has already lost by the time the clamp runs. Every value this layer converts comes from a host or from a project file, so the guard belongs ahead of the cast.

A NaN maps to lo. That is deliberate and it is the reason this is a function rather than a pair of ternaries at each site: NaN compares false against everything, so it sails straight through a clamp written the obvious way and reaches the conversion anyway.

Definition at line 1394 of file DSParkPlugin.h.

◆ toggle()

constexpr Param dspark::plugin::toggle ( const char *  id,
const char *  name,
bool  defaultOn 
)
constexprnoexcept

On/off parameter helper.

Definition at line 157 of file DSParkPlugin.h.

◆ toNormalized()

constexpr double dspark::plugin::toNormalized ( const Param &  p,
double  plain 
)
constexprnoexcept

Plain [min, max] -> normalized [0, 1] (steps snap on the way back).

Definition at line 231 of file DSParkPlugin.h.

◆ toPlain()

constexpr double dspark::plugin::toPlain ( const Param &  p,
double  normalized 
)
constexprnoexcept

Normalized [0, 1] -> plain [min, max], snapped for stepped params.

Definition at line 242 of file DSParkPlugin.h.

Variable Documentation

◆ kAllNoteExpressions

constexpr uint32_t dspark::plugin::kAllNoteExpressions
inlineconstexpr
Initial value:
=
(1u << (static_cast<uint32_t>(MidiEvent::ExpressionType::Pressure) + 1u)) - 1u

Every ExpressionType at once (the mask of a class that declares none).

Definition at line 677 of file DSParkPlugin.h.

◆ kAutomationQuantum

constexpr int dspark::plugin::kAutomationQuantum = 32
inlineconstexpr

Sub-block grain: automation/event splits snap to this many frames (bounds the per-call overhead; ~0.7 ms at 48 kHz is inaudible).

Definition at line 915 of file DSParkPlugin.h.

◆ kBypassStateId

constexpr uint32_t dspark::plugin::kBypassStateId = 0x42595053u
inlineconstexpr

Reserved entry id persisting the host bypass ('BYPS' - the same value every backend uses as the bypass ParamID). Hosts treat bypass as one more parameter, so it must survive a state round-trip like any other. Older builds skip it (unknown id).

Definition at line 1658 of file DSParkPlugin.h.

◆ kDryDelayMinCapacity

constexpr int dspark::plugin::kDryDelayMinCapacity = 8192
inlineconstexpr

Ring headroom of the bypass dry path: latencies up to this (or twice the latency at activation, if larger) stay sample-aligned when a plugin's lookahead grows while running.

Definition at line 1292 of file DSParkPlugin.h.

◆ kEditorHeightStateId

constexpr uint32_t dspark::plugin::kEditorHeightStateId = 0x45445348u
inlineconstexpr

Definition at line 1664 of file DSParkPlugin.h.

◆ kEditorMaxPixels

constexpr double dspark::plugin::kEditorMaxPixels = 32767.0
inlineconstexpr

Pixel ceiling for a negotiated editor size.

The window sizes below are products of a scale factor the host chooses, and every caller turns them into an integer. A host is free to hand over a scale that puts the product outside that integer's range, where the conversion is undefined, so the size is bounded before anyone converts it. No display is this large; the value is the largest a signed 16-bit coordinate can carry, which is the smallest window coordinate any of the supported formats uses.

Definition at line 1378 of file DSParkPlugin.h.

◆ kEditorMaxSizeFactor

constexpr double dspark::plugin::kEditorMaxSizeFactor = 3.0
inlineconstexpr

Definition at line 1367 of file DSParkPlugin.h.

◆ kEditorMinSizeFactor

constexpr double dspark::plugin::kEditorMinSizeFactor = 0.5
inlineconstexpr

Resize bounds: hosts may shrink to half and grow to 3x the declared size.

Definition at line 1366 of file DSParkPlugin.h.

◆ kEditorWidthStateId

constexpr uint32_t dspark::plugin::kEditorWidthStateId = 0x45445357u
inlineconstexpr

Reserved entry ids persisting the editor size the user left ('EDSW' / 'EDSH', logical pixels; see EditorSizeMemory). Older builds skip them (unknown ids).

Definition at line 1663 of file DSParkPlugin.h.

◆ kMaxBlockEvents

constexpr int dspark::plugin::kMaxBlockEvents = 256
inlineconstexpr

Capacity of the per-block event list. Past it the list merges rather than drops: an intermediate parameter point gives up its slot (the newest point of every parameter and every MIDI event are kept), so only a block carrying more than this many distinct parameters plus MIDI events loses anything. See BlockEventList.

Definition at line 922 of file DSParkPlugin.h.

◆ kMaxStateBytes

constexpr size_t dspark::plugin::kMaxStateBytes = size_t { 1 } << 30
inlineconstexpr

Largest state a backend reads back (1 GiB). It only bounds a hostile, endless host stream: getState() itself has no size limit, so any cap a real state could exceed would break the save/load round trip.

Definition at line 1648 of file DSParkPlugin.h.

◆ kProgramStateId

constexpr uint32_t dspark::plugin::kProgramStateId = 0x5052474Du
inlineconstexpr

Reserved entry id persisting the active factory-preset index ('PRGM'); never a user parameter. Older builds skip it (unknown id).

Definition at line 1652 of file DSParkPlugin.h.

◆ kStateMagic

constexpr uint32_t dspark::plugin::kStateMagic = 0x4453504Bu
inlineconstexpr

Definition at line 1642 of file DSParkPlugin.h.

◆ kStateVersion

constexpr uint32_t dspark::plugin::kStateVersion = 1u
inlineconstexpr

Definition at line 1643 of file DSParkPlugin.h.

◆ paramIdTable

template<typename P >
constexpr auto dspark::plugin::paramIdTable
inlineconstexpr
Initial value:
= [] {
std::array<uint32_t, P::parameters.size()> ids {};
for (size_t i = 0; i < P::parameters.size(); ++i)
ids[i] = hash32(P::parameters[i].id);
return ids;
}()
constexpr uint32_t hash32(const char *s) noexcept
FNV-1a 32-bit over a C string - the per-parameter host id.

The hash32 of every parameter id of P, computed at compile time (table order), so id lookups on the audio thread compare integers instead of re-hashing every id string for every event.

Definition at line 429 of file DSParkPlugin.h.

◆ perVoiceSlotTable

template<typename P >
constexpr auto dspark::plugin::perVoiceSlotTable
inlineconstexpr
Initial value:
= [] {
std::array<int, P::parameters.size()> slots {};
int next = 0;
for (size_t i = 0; i < P::parameters.size(); ++i)
slots[i] = P::parameters[i].perVoice ? next++ : -1;
return slots;
}()

For every parameter of P, its position among the perVoice() parameters (table order), or -1 for a parameter without the mark.

Definition at line 458 of file DSParkPlugin.h.