Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
vst3_entry.hpp
Go to the documentation of this file.
1#pragma once
2
3// Generic VST3 entry point generator
4// Plugin developers include this and call PULP_VST3_PLUGIN() with their factory
5// function and a unique FUID. All VST3 boilerplate is generated automatically.
6//
7// Usage (in one .cpp file per plugin):
8// #include "my_processor.hpp"
9// #include <pulp/format/vst3_entry.hpp>
10//
11// // Unique ID — generate once, never change across versions
12// static const Steinberg::FUID kMyPluginUID(0x12345678, 0x9ABCDEF0, 0x00000001, 0x00000001);
13//
14// PULP_VST3_PLUGIN(kMyPluginUID, "My Plugin", "Fx", "My Company",
15// "1.0.0", "https://example.com",
16// my_namespace::create_my_processor)
17
20
21#include <public.sdk/source/main/pluginfactory.h>
22
23// Generate a VST3 factory with a single plugin class.
24// The plugin uses SingleComponentEffect (combined processor + controller).
25#define PULP_VST3_PLUGIN(uid, name, category, vendor, version, url, factory_fn) \
26 static Steinberg::FUnknown* _pulp_vst3_create(void*) { \
27 return static_cast<Steinberg::Vst::IAudioProcessor*>( \
28 new pulp::format::vst3::PulpVst3Processor(factory_fn)); \
29 } \
30 \
31 BEGIN_FACTORY_DEF(vendor, url, "mailto:info@example.com") \
32 DEF_CLASS2(INLINE_UID_FROM_FUID(uid), \
33 PClassInfo::kManyInstances, \
34 kVstAudioEffectClass, \
35 name, \
36 0, \
37 category, \
38 version, \
39 kVstVersionString, \
40 _pulp_vst3_create) \
41 END_FACTORY
42
43// ── Multi-plugin bundle: one VST3 binary, many plugins ───────────────────
44// VST3's factory natively lists multiple classes, so a bundle is structured
45// exactly like Steinberg's own multi-class factory: define each plugin's create
46// function at file scope with PULP_VST3_BUNDLE_PLUGIN, then list them between
47// PULP_VST3_FACTORY_BEGIN / _END. Each create function binds its OWN
48// ProcessorFactory lexically (PulpVst3Processor already takes it), so no global
49// lookup happens on any instantiation path — the same model as the AU bundle
50// macros. A keyed registry entry is also recorded per plugin for enumeration
51// and per-plugin editor-asset resolution (see registry.hpp).
52//
53// Usage:
54// PULP_VST3_BUNDLE_PLUGIN(Foo, create_foo, {.id="com.x.foo"})
55// PULP_VST3_BUNDLE_PLUGIN(Bar, create_bar, {.id="com.x.bar"})
56// PULP_VST3_FACTORY_BEGIN("My Co", "https://x.com", "mailto:info@x.com")
57// PULP_VST3_BUNDLE_CLASS(Foo, kFooUID, "Foo", "Fx", "1.0.0")
58// PULP_VST3_BUNDLE_CLASS(Bar, kBarUID, "Bar", "Fx", "1.0.0")
59// PULP_VST3_FACTORY_END
60//
61// `Ident` links a _PLUGIN to its _CLASS: the same token names the generated
62// create-function symbol, so a mismatch fails to COMPILE (undefined symbol) —
63// the pair cannot silently desync. factory_fn is the single source of truth,
64// force-assigned onto the keyed entry's `.factory`; do NOT set `.factory` in the
65// braced-init (ignored), same rule as the AU bundle macros. The trailing
66// PluginRegistration init is variadic so its brace commas survive the
67// preprocessor.
68
69// File-scope: generate `_pulp_vst3_create_<Ident>` bound to factory_fn, and
70// register the keyed entry. Place ABOVE the factory block, once per plugin.
71#define PULP_VST3_BUNDLE_PLUGIN(Ident, factory_fn, ...) \
72 static Steinberg::FUnknown* _pulp_vst3_create_##Ident(void*) { \
73 return static_cast<Steinberg::Vst::IAudioProcessor*>( \
74 new pulp::format::vst3::PulpVst3Processor(factory_fn)); \
75 } \
76 namespace { \
77 struct Ident##_Vst3Registrar { \
78 Ident##_Vst3Registrar() { \
79 ::pulp::format::PluginRegistration reg __VA_ARGS__; \
80 reg.factory = factory_fn; \
81 ::pulp::format::register_plugin(reg); \
82 } \
83 } Ident##_vst3_registrar_; \
84 }
85
86#define PULP_VST3_FACTORY_BEGIN(vendor, url, email) \
87 BEGIN_FACTORY_DEF(vendor, url, email)
88
89// Inside the factory block: list one class per plugin. `Ident` must match a
90// PULP_VST3_BUNDLE_PLUGIN above (same generated create symbol).
91#define PULP_VST3_BUNDLE_CLASS(Ident, uid, name, category, version) \
92 DEF_CLASS2(INLINE_UID_FROM_FUID(uid), \
93 PClassInfo::kManyInstances, \
94 kVstAudioEffectClass, \
95 name, \
96 0, \
97 category, \
98 version, \
99 kVstVersionString, \
100 _pulp_vst3_create_##Ident)
101
102#define PULP_VST3_FACTORY_END END_FACTORY