Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
plugin_descriptor.hpp
Go to the documentation of this file.
1#pragma once
2
3// Static plugin metadata: the descriptor a Processor returns once at
4// initialization, plus the bus, category, capability, and editor-size types it
5// is built from. processor.hpp includes this header, so existing consumers keep
6// compiling unchanged; new code should include it directly.
7
8#include <cstdint>
10#include <string>
11#include <vector>
12
13namespace pulp::format {
14
23
27struct ViewSize {
28 uint32_t preferred_width = 400;
29 uint32_t preferred_height = 300;
30 uint32_t min_width = 0;
31 uint32_t min_height = 0;
32 uint32_t max_width = 0;
33 uint32_t max_height = 0;
34
40 double aspect_ratio = 0.0;
41
46 uint32_t design_width = 0;
47 uint32_t design_height = 0;
48
52};
53
54constexpr uint32_t design_viewport_width(const ViewSize& hints) {
55 return hints.design_width > 0 ? hints.design_width : hints.preferred_width;
56}
57
58constexpr uint32_t design_viewport_height(const ViewSize& hints) {
59 return hints.design_height > 0 ? hints.design_height : hints.preferred_height;
60}
61
76constexpr ViewSize view_size_from_design(uint32_t preferred_width,
77 uint32_t preferred_height,
78 uint32_t min_width = 0,
79 uint32_t min_height = 0,
80 uint32_t max_width = 0,
81 uint32_t max_height = 0) {
82 return ViewSize{
83 preferred_width,
84 preferred_height,
85 min_width > 0 ? min_width : (preferred_width * 2) / 3,
86 min_height > 0 ? min_height : (preferred_height * 2) / 3,
87 max_width > 0 ? max_width : preferred_width * 2,
88 max_height > 0 ? max_height : preferred_height * 2,
89 preferred_height > 0
90 ? static_cast<double>(preferred_width) / static_cast<double>(preferred_height)
91 : 0.0,
92 };
93}
94
106constexpr bool should_pin_design_viewport(const ViewSize& hints) {
107 if (hints.viewport_policy == ViewportPolicy::Responsive) return false;
109 return design_viewport_width(hints) > 0 &&
110 design_viewport_height(hints) > 0;
111 }
112 const bool resizable = hints.min_width > 0 && hints.min_height > 0;
113 const bool free_resize = resizable && hints.aspect_ratio <= 0.0;
114 return hints.preferred_width > 0 && hints.preferred_height > 0 && !free_resize;
115}
116
120constexpr bool should_lock_view_aspect(const ViewSize& hints) {
121 return hints.aspect_ratio > 0.0;
122}
123
128constexpr double native_view_aspect_ratio(const ViewSize& hints) {
129 if (should_lock_view_aspect(hints)) return hints.aspect_ratio;
130 if (!should_pin_design_viewport(hints)) return 0.0;
131 const auto width = design_viewport_width(hints);
132 const auto height = design_viewport_height(hints);
133 return width > 0 && height > 0
134 ? static_cast<double>(width) / static_cast<double>(height)
135 : 0.0;
136}
137
141template <typename NativeHost>
142void configure_native_viewport(NativeHost& host, const ViewSize& hints) {
143 if (should_pin_design_viewport(hints)) {
144 host.set_design_viewport(
145 static_cast<float>(design_viewport_width(hints)),
146 static_cast<float>(design_viewport_height(hints)));
147 }
148 const double aspect_ratio = native_view_aspect_ratio(hints);
149 if (aspect_ratio > 0.0) {
150 host.set_fixed_aspect_ratio(static_cast<float>(aspect_ratio));
151 }
152}
153
160template <typename NativeHost>
162 const ViewSize& hints,
163 uint32_t width,
164 uint32_t height) {
165 if (should_pin_design_viewport(hints)) {
166 const bool has_authored_viewport =
167 hints.design_width > 0 && hints.design_height > 0;
168 host.set_design_viewport(
169 static_cast<float>(has_authored_viewport
170 ? design_viewport_width(hints) : width),
171 static_cast<float>(has_authored_viewport
172 ? design_viewport_height(hints) : height));
173 }
174 const double aspect_ratio = should_lock_view_aspect(hints)
175 ? hints.aspect_ratio
176 : (should_pin_design_viewport(hints) && height > 0
177 ? static_cast<double>(width) / static_cast<double>(height)
178 : 0.0);
179 if (aspect_ratio > 0.0) {
180 host.set_fixed_aspect_ratio(static_cast<float>(aspect_ratio));
181 }
182}
183
190
195struct BusInfo {
196 std::string name;
198 bool optional = false;
202};
203
209 std::vector<int> inputs;
210 std::vector<int> outputs;
211 std::string name;
212};
213
218 bool supports_mpe = false;
219 bool supports_ump = false;
220 bool supports_f64_audio = false;
227};
228
246 std::string name;
247 std::string manufacturer;
248 std::string bundle_id;
249 std::string version;
251
254 std::vector<BusInfo> input_buses = {{"Main In", 2, false}};
255 std::vector<BusInfo> output_buses = {{"Main Out", 2, false}};
256
257 bool accepts_midi = false;
258 bool produces_midi = false;
259
266 bool supports_mpe = false;
267
275 bool supports_ump = false;
276
288
292
297 std::string vendor_url;
298 std::string vendor_email;
299
304
312 bool supports_f64_audio = false;
313
318 std::vector<BusLayoutConfiguration> supported_bus_layouts;
319
332 std::uint32_t voice_count = 0;
333
335 return {
336 .supports_mpe = supports_mpe || node_capabilities.supports_mpe,
337 .supports_ump = supports_ump || node_capabilities.supports_ump,
338 .supports_f64_audio = supports_f64_audio || node_capabilities.supports_f64_audio,
339 .consumes_audio_rate_modulations = node_capabilities.consumes_audio_rate_modulations,
340 .writes_input_buffers = node_capabilities.writes_input_buffers,
341 };
342 }
343
346 return input_buses.empty() ? 0 : input_buses[0].default_channels;
347 }
348
350 return output_buses.empty() ? 0 : output_buses[0].default_channels;
351 }
352};
353
354} // namespace pulp::format
What the product grants a device: the quota table indexed by capability tier and live thermal state.
Definition aax_editor.hpp:31
constexpr double native_view_aspect_ratio(const ViewSize &hints)
Resolve the native host constraint while preserving the legacy fixed-editor contract.
Definition plugin_descriptor.hpp:128
void commit_editor_requested_viewport(NativeHost &host, const ViewSize &hints, uint32_t width, uint32_t height)
Commit viewport state after an editor-initiated host resize succeeds.
Definition plugin_descriptor.hpp:161
constexpr bool should_pin_design_viewport(const ViewSize &hints)
Editor-host resize contract shared by the format adapters (VST3 PulpPlugView, the AU v2 Cocoa view; m...
Definition plugin_descriptor.hpp:106
ViewportPolicy
Controls whether a host paints an editor through a fixed authored coordinate space or lets the root l...
Definition plugin_descriptor.hpp:18
@ Automatic
Definition plugin_descriptor.hpp:19
@ FixedDesign
Definition plugin_descriptor.hpp:20
@ Responsive
Definition plugin_descriptor.hpp:21
void configure_native_viewport(NativeHost &host, const ViewSize &hints)
Apply the declared viewport policy to a newly-created native host.
Definition plugin_descriptor.hpp:142
constexpr ViewSize view_size_from_design(uint32_t preferred_width, uint32_t preferred_height, uint32_t min_width=0, uint32_t min_height=0, uint32_t max_width=0, uint32_t max_height=0)
Build a ViewSize from a design-import preferred size with sensible derived bounds.
Definition plugin_descriptor.hpp:76
PluginCategory
Plugin category — determines bus layout expectations and DAW behavior.
Definition plugin_descriptor.hpp:185
@ Instrument
Synth/sampler (receives MIDI, produces audio).
Definition plugin_descriptor.hpp:187
@ MidiEffect
MIDI processor (receives MIDI, produces MIDI).
Definition plugin_descriptor.hpp:188
@ Effect
Audio effect (takes input, produces output).
Definition plugin_descriptor.hpp:186
constexpr uint32_t design_viewport_width(const ViewSize &hints)
Definition plugin_descriptor.hpp:54
BusRole
Semantic role of a declared audio bus.
Definition bus_role.hpp:9
@ Main
Definition bus_role.hpp:10
constexpr uint32_t design_viewport_height(const ViewSize &hints)
Definition plugin_descriptor.hpp:58
constexpr bool should_lock_view_aspect(const ViewSize &hints)
Aspect locking and viewport pinning are deliberately separate.
Definition plugin_descriptor.hpp:120
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
Audio bus description — for multi-bus plugins (sidechain, aux, etc.).
Definition plugin_descriptor.hpp:195
std::string name
Definition plugin_descriptor.hpp:196
BusRole role
Semantic role used by hosts and adapters when bus order is not enough.
Definition plugin_descriptor.hpp:201
int default_channels
Definition plugin_descriptor.hpp:197
bool optional
true for sidechain buses that can be deactivated
Definition plugin_descriptor.hpp:198
One complete host-selectable channel configuration.
Definition plugin_descriptor.hpp:208
std::vector< int > inputs
Definition plugin_descriptor.hpp:209
std::string name
Definition plugin_descriptor.hpp:211
std::vector< int > outputs
Definition plugin_descriptor.hpp:210
Capability sidecar for the node ABI.
Definition plugin_descriptor.hpp:217
bool writes_input_buffers
The processor may write into the input buffers it is handed (a native core passing them to a C ABI as...
Definition plugin_descriptor.hpp:226
bool supports_f64_audio
Definition plugin_descriptor.hpp:220
bool supports_mpe
Definition plugin_descriptor.hpp:218
bool consumes_audio_rate_modulations
Definition plugin_descriptor.hpp:221
bool supports_ump
Definition plugin_descriptor.hpp:219
Plugin metadata — declared once, immutable.
Definition plugin_descriptor.hpp:245
int default_input_channels() const
Channel count of the first (main) input bus.
Definition plugin_descriptor.hpp:345
std::string vendor_email
Definition plugin_descriptor.hpp:298
NodeCapabilities effective_capabilities() const
Definition plugin_descriptor.hpp:334
std::string bundle_id
Definition plugin_descriptor.hpp:248
std::string vendor_url
Optional contact info — appended here so existing positional aggregate initializers keep working.
Definition plugin_descriptor.hpp:297
bool supports_ump
Opt in to the native MIDI 2.0 UMP sidecar.
Definition plugin_descriptor.hpp:275
std::uint32_t voice_count
Number of simultaneously sounding voices this plugin allocates.
Definition plugin_descriptor.hpp:332
bool supports_mpe
Opt in to MPE (MIDI Polyphonic Expression).
Definition plugin_descriptor.hpp:266
bool produces_midi
true if plugin sends MIDI output
Definition plugin_descriptor.hpp:258
int default_output_channels() const
Channel count of the first (main) output bus.
Definition plugin_descriptor.hpp:349
std::vector< BusInfo > input_buses
Bus configuration — defaults to single stereo in/out for compatibility.
Definition plugin_descriptor.hpp:254
std::vector< BusInfo > output_buses
Definition plugin_descriptor.hpp:255
bool accepts_midi
true if plugin receives MIDI input
Definition plugin_descriptor.hpp:257
NodeCapabilities node_capabilities
Node ABI capability bits.
Definition plugin_descriptor.hpp:303
std::vector< BusLayoutConfiguration > supported_bus_layouts
Explicit host-selectable layouts.
Definition plugin_descriptor.hpp:318
std::string manufacturer
Definition plugin_descriptor.hpp:247
bool supports_f64_audio
Opt in to native double-precision audio processing.
Definition plugin_descriptor.hpp:312
std::string name
Definition plugin_descriptor.hpp:246
PluginCategory category
Definition plugin_descriptor.hpp:250
int tail_samples
Tail time in samples (0 = no tail, -1 = infinite).
Definition plugin_descriptor.hpp:291
std::string version
Semantic version string, e.g. "1.0.0".
Definition plugin_descriptor.hpp:249
bool ios_requires_background_audio
iOS-only: true when the plugin renders audio that must continue while the host app is backgrounded (l...
Definition plugin_descriptor.hpp:287
Editor size hints (in logical pixels).
Definition plugin_descriptor.hpp:27
double aspect_ratio
When > 0, the host should hold this aspect ratio (width/height) during interactive resize.
Definition plugin_descriptor.hpp:40
uint32_t design_height
Definition plugin_descriptor.hpp:47
ViewportPolicy viewport_policy
The viewport/layout policy is independent of aspect_ratio: a responsive editor may still ask the host...
Definition plugin_descriptor.hpp:51
uint32_t design_width
Optional authored coordinate space.
Definition plugin_descriptor.hpp:46
uint32_t max_width
0 = unbounded
Definition plugin_descriptor.hpp:32
uint32_t preferred_height
Definition plugin_descriptor.hpp:29
uint32_t preferred_width
Definition plugin_descriptor.hpp:28
uint32_t min_width
Definition plugin_descriptor.hpp:30
uint32_t min_height
Definition plugin_descriptor.hpp:31
uint32_t max_height
0 = unbounded
Definition plugin_descriptor.hpp:33