DSPark 1.6.1
Header-only audio DSP framework in pure C++20 — zero dependencies
Loading...
Searching...
No Matches
DSParkVst3.h File Reference

Native VST3 backend: a complete plugin from one DSPark plugin class. More...

#include "../DSParkPlugin.h"
#include "vst3_c_api.h"
#include <atomic>
#include <cstring>
#include <new>
Include dependency graph for DSParkVst3.h:

Go to the source code of this file.

Classes

struct  dspark::plugin::vst3::Plugin< P >
 
struct  dspark::plugin::vst3::Factory< P >
 

Namespaces

namespace  dspark
 Main namespace for the DSPark framework.
 
namespace  dspark::plugin
 
namespace  dspark::plugin::vst3
 

Macros

#define DSPARK_PLUGIN_VST3_INCLUDED   1
 
#define DSPARK_VST3_EXPORT   __attribute__((visibility("default")))
 
#define DSPARK_VST3_PLUGIN(PluginClass)
 Declares the VST3 module entry points for one plugin class. Place once in exactly one translation unit, after the class definition.
 

Functions

bool dspark::plugin::vst3::tuidEqual (const Steinberg_TUID a, const Steinberg_TUID b) noexcept
 
void dspark::plugin::vst3::asciiToString128 (const char *src, Steinberg_Vst_String128 dst) noexcept
 
void dspark::plugin::vst3::copyAscii (const char *src, char *dst, size_t cap) noexcept
 
bool dspark::plugin::vst3::streamRead (Steinberg_IBStream *s, void *dst, Steinberg_int32 bytes) noexcept
 Reads the full requested range from an IBStream (hosts may chunk).
 
bool dspark::plugin::vst3::streamWrite (Steinberg_IBStream *s, const void *src, Steinberg_int32 bytes) noexcept
 
constexpr bool dspark::plugin::vst3::isMidiProxyId (uint32_t id) noexcept
 
constexpr uint32_t dspark::plugin::vst3::midiProxyId (int channel, int controller) noexcept
 
MidiEvent dspark::plugin::vst3::midiProxyToEvent (uint32_t id, double normalized, int offset) noexcept
 Proxy parameter (normalized) -> the framework-neutral MidiEvent.
 

Variables

constexpr uint32_t dspark::plugin::vst3::kBypassParamId = 0x42595053u
 
constexpr uint32_t dspark::plugin::vst3::kProgramParamId = 0x5052474Du
 
constexpr int dspark::plugin::vst3::kBypassRampSamples = 256
 
constexpr Steinberg_int32 dspark::plugin::vst3::kPresetProgramListId = 1
 
constexpr uint32_t dspark::plugin::vst3::kMidiProxyBase = 0x4D440000u
 
constexpr int dspark::plugin::vst3::kMidiProxyControllers [4] = { 1, 64, 128, 129 }
 
constexpr int dspark::plugin::vst3::kNumMidiProxies = 16 * 4
 

Detailed Description

Native VST3 backend: a complete plugin from one DSPark plugin class.

Implements the VST3 COM ABI directly against Steinberg's official C API (vst3_c_api.h, vendored next to this header under Steinberg's permissive 2025 license) - no VST3 C++ SDK to download, no build system beyond your compiler:

struct MyPlugin { ... }; // see plugin/DSParkPlugin.h
Native VST3 backend: a complete plugin from one DSPark plugin class.
#define DSPARK_VST3_PLUGIN(PluginClass)
Declares the VST3 module entry points for one plugin class. Place once in exactly one translation uni...

cl /std:c++20 /O2 /LD myplugin.cpp /Fe:MyPlugin.vst3 (Windows) g++/clang++ -std=c++20 -O2 -fPIC -shared -o MyPlugin.so ... (Linux/macOS)

Design notes:

  • Single-component plugin: one object implements IComponent, IAudioProcessor and IEditController (the layout hosts use for the vast majority of plugins); the COM "lenses" are consecutive vtable pointers and queryInterface hands out the right one. IUnitInfo (factory presets) and IMidiMapping (MIDI plugins) ride two more lenses, surfaced only when the plugin class declares the matching capability.
  • Parameters: host ParamIDs are FNV-1a hashes of the stable text ids (never indices: reordering parameters between versions must not break automation). A wrapper-owned Bypass parameter (kIsBypass) is always appended and applied as a short crossfade against the dry input.
  • Automation is sample-accurate by default: every queue point becomes a timestamped event and processing splits at kAutomationQuantum boundaries (plugins may opt out, see DSParkPlugin.h). DSPark setters still smooth internally, so both modes are click-free.
  • Buses: mono and stereo are negotiated through setBusArrangements per the declared ChannelSupport; a sidechain aux input follows the main width. Category::Instrument drops the audio inputs entirely and HasMidi adds an event input bus (notes natively; pitch bend / mod / sustain / channel pressure through IMidiMapping proxy parameters, the VST3 scheme for MIDI controllers).
  • Transport: when the class implements setTransport, the wrapper declares its needs through IProcessContextRequirements and forwards the host ProcessContext once per block.
  • Latency is re-read after parameter changes; a change notifies the host through restartComponent(kLatencyChanged).
  • State uses the format-agnostic container of DSParkPlugin.h, so presets are byte-identical across the VST3/CLAP/AU backends. Factory presets publish as a program list with a program-change parameter.
  • Threading: setParamNormalized arrives from the UI thread and process() from the audio thread; both funnel into the user's setParameter, which DSPark's contract requires to be atomic-based. process() runs under a DenormalGuard (FTZ/DAZ) so user DSP outside DSPark's own classes is covered in hosts that do not set it.
  • Editor: when plugin/webview/DSParkWebViewEditor.h is included before this header and the class declares hasEditor = true, createView returns an IPlugView embedding the WebView editor (with content-scale support); otherwise hosts show their generic parameter UI.

Definition in file DSParkVst3.h.

Macro Definition Documentation

◆ DSPARK_PLUGIN_VST3_INCLUDED

#define DSPARK_PLUGIN_VST3_INCLUDED   1

Definition at line 63 of file DSParkVst3.h.

◆ DSPARK_VST3_EXPORT

#define DSPARK_VST3_EXPORT   __attribute__((visibility("default")))

Definition at line 2036 of file DSParkVst3.h.

◆ DSPARK_VST3_PLUGIN

#define DSPARK_VST3_PLUGIN (   PluginClass)
Value:
static dspark::plugin::vst3::Factory<PluginClass> gDsparkVst3Factory; \
extern "C" { \
DSPARK_VST3_EXPORT Steinberg_IPluginFactory* SMTG_STDMETHODCALLTYPE \
GetPluginFactory() \
{ \
return reinterpret_cast<Steinberg_IPluginFactory*>(&gDsparkVst3Factory); \
} \
DSPARK_VST3_EXPORT bool InitDll() { return true; } \
DSPARK_VST3_EXPORT bool ExitDll() { return true; } \
DSPARK_VST3_EXPORT bool ModuleEntry(void*) { return true; } \
DSPARK_VST3_EXPORT bool ModuleExit() { return true; } \
DSPARK_VST3_EXPORT bool bundleEntry(void*) { return true; } \
DSPARK_VST3_EXPORT bool bundleExit() { return true; } \
}
#define DSPARK_VST3_EXPORT

Declares the VST3 module entry points for one plugin class. Place once in exactly one translation unit, after the class definition.

Definition at line 2043 of file DSParkVst3.h.