Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
forge_param_descriptor.hpp
Go to the documentation of this file.
1#pragma once
2
3// Semantic descriptors for Forge-exposed catalog parameters.
4//
5// CustomNodeBakedParam carries the numeric contract an audio graph needs: id,
6// range, default. An agent choosing a node needs more than that — what the
7// parameter is called, what it is measured in, whether it steps between named
8// states, and what it does. That vocabulary lived downstream and had to be kept
9// in sync by hand; a descriptor moves it next to the DSP it describes.
10//
11// Descriptors deliberately carry NO range or default. Those come from the baked
12// node at export time, so a descriptor cannot drift out of agreement with the
13// DSP it annotates — there is only ever one copy of a number.
14
16
17#include <string>
18#include <string_view>
19#include <utility>
20#include <vector>
21
22namespace pulp::host {
23
26
30
34 std::string_view token;
35 std::string_view label;
36 float value = 0.0f;
39 std::vector<std::string_view> realization_modes;
40
41 ForgeParamChoice() = default;
42 ForgeParamChoice(std::string_view token_in, std::string_view label_in, float value_in,
43 std::vector<std::string_view> modes_in = {})
44 : token(token_in), label(label_in), value(value_in),
45 realization_modes(std::move(modes_in)) {}
46};
47
53 std::string_view token;
54 std::string_view label;
55 float value = 0.0f;
56};
57
61 std::string_view key;
65 std::string_view label;
67 std::string_view unit;
68 std::string_view description;
72 std::vector<ForgeParamChoice> choices;
78 std::vector<std::string_view> realization_modes;
79
81 ForgeParamDescriptor(std::string_view key_in, state::ParamID id_in, std::string_view label_in,
82 std::string_view unit_in, std::string_view description_in,
83 ForgeParamKind kind_in, ForgeParamCurve curve_in,
84 std::vector<ForgeParamChoice> choices_in = {},
85 std::vector<std::string_view> modes_in = {})
86 : key(key_in), id(id_in), label(label_in), unit(unit_in), description(description_in),
87 kind(kind_in), curve(curve_in), choices(std::move(choices_in)),
88 realization_modes(std::move(modes_in)) {}
89};
90
95 std::string_view key;
96 std::string_view label;
97 std::string_view description;
98 std::vector<ForgeAxisValue> values;
99};
100
107 std::string_view axis;
108 std::string_view value;
109};
110
115 std::string mode;
117 std::string type_id;
119 std::vector<ForgeRealizationSetting> settings;
120
121 ForgeRealization() = default;
122 ForgeRealization(std::string_view mode_in, std::string_view type_id_in,
123 std::vector<ForgeRealizationSetting> settings_in = {})
124 : mode(mode_in), type_id(type_id_in), settings(std::move(settings_in)) {}
125};
126
129 std::string_view key;
130 std::string_view label;
133 std::string_view description;
134 std::vector<ForgeRealizationAxis> axes;
135 std::vector<ForgeRealization> realizations;
136 std::vector<ForgeParamDescriptor> params;
137};
138
143 std::string_view key) noexcept {
144 for (const auto& param : node.params)
145 if (param.key == key)
146 return &param;
147 return nullptr;
148}
149
151inline bool param_applies(const ForgeParamDescriptor& param, std::string_view mode) noexcept {
152 if (param.realization_modes.empty())
153 return true;
154 for (const auto& allowed : param.realization_modes)
155 if (allowed == mode)
156 return true;
157 return false;
158}
159
160inline bool choice_applies(const ForgeParamChoice& choice, std::string_view mode) noexcept {
161 if (choice.realization_modes.empty())
162 return true;
163 for (const auto& allowed : choice.realization_modes)
164 if (allowed == mode)
165 return true;
166 return false;
167}
168
169} // namespace pulp::host
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
ForgeParamKind
Whether a parameter sweeps continuously or selects among named states.
Definition forge_param_descriptor.hpp:25
@ stepped
Definition forge_param_descriptor.hpp:25
@ continuous
Definition forge_param_descriptor.hpp:25
ForgeParamCurve
How a value maps to its control travel.
Definition forge_param_descriptor.hpp:29
@ logarithmic
Definition forge_param_descriptor.hpp:29
@ linear
Definition forge_param_descriptor.hpp:29
bool choice_applies(const ForgeParamChoice &choice, std::string_view mode) noexcept
Definition forge_param_descriptor.hpp:160
bool param_applies(const ForgeParamDescriptor &param, std::string_view mode) noexcept
True when param applies to the named realization mode.
Definition forge_param_descriptor.hpp:151
const ForgeParamDescriptor * find_param(const ForgeNodeDescriptor &node, std::string_view key) noexcept
Look up a parameter descriptor by its stable key.
Definition forge_param_descriptor.hpp:142
uint32_t ParamID
Unique parameter identifier, stable across plugin versions.
Definition parameter.hpp:55
STL namespace.
One value of a compile-time realization axis.
Definition forge_param_descriptor.hpp:52
std::string_view label
Definition forge_param_descriptor.hpp:54
std::string_view token
Definition forge_param_descriptor.hpp:53
float value
Definition forge_param_descriptor.hpp:55
Definition forge_param_descriptor.hpp:127
std::string_view label
Definition forge_param_descriptor.hpp:130
std::string_view description
One or two sentences: what this node is for, in the vocabulary someone choosing it would use.
Definition forge_param_descriptor.hpp:133
std::vector< ForgeParamDescriptor > params
Definition forge_param_descriptor.hpp:136
std::string_view key
Stable family key, e.g. "fuzz".
Definition forge_param_descriptor.hpp:129
std::vector< ForgeRealization > realizations
Definition forge_param_descriptor.hpp:135
std::vector< ForgeRealizationAxis > axes
Definition forge_param_descriptor.hpp:134
One named state of a stepped parameter.
Definition forge_param_descriptor.hpp:33
std::string_view label
Definition forge_param_descriptor.hpp:35
std::vector< std::string_view > realization_modes
Empty means the choice is valid wherever its parameter is valid.
Definition forge_param_descriptor.hpp:39
ForgeParamChoice(std::string_view token_in, std::string_view label_in, float value_in, std::vector< std::string_view > modes_in={})
Definition forge_param_descriptor.hpp:42
float value
Definition forge_param_descriptor.hpp:36
std::string_view token
Definition forge_param_descriptor.hpp:34
Definition forge_param_descriptor.hpp:58
std::string_view unit
Unit symbol as displayed ("dB", "Hz", "ms", "%"). Empty when unitless.
Definition forge_param_descriptor.hpp:67
ForgeParamDescriptor(std::string_view key_in, state::ParamID id_in, std::string_view label_in, std::string_view unit_in, std::string_view description_in, ForgeParamKind kind_in, ForgeParamCurve curve_in, std::vector< ForgeParamChoice > choices_in={}, std::vector< std::string_view > modes_in={})
Definition forge_param_descriptor.hpp:81
std::vector< ForgeParamChoice > choices
Required and non-empty when kind is stepped; empty otherwise.
Definition forge_param_descriptor.hpp:72
std::string_view label
Definition forge_param_descriptor.hpp:65
ForgeParamCurve curve
Definition forge_param_descriptor.hpp:70
state::ParamID id
The baked parameter this describes.
Definition forge_param_descriptor.hpp:64
std::vector< std::string_view > realization_modes
Empty means the parameter exists on every realization.
Definition forge_param_descriptor.hpp:78
ForgeParamKind kind
Definition forge_param_descriptor.hpp:69
std::string_view description
Definition forge_param_descriptor.hpp:68
std::string_view key
Stable machine key, snake_case, unique within its node.
Definition forge_param_descriptor.hpp:61
A compile-time construction axis — a choice made when the node is built rather than automated afterwa...
Definition forge_param_descriptor.hpp:94
std::vector< ForgeAxisValue > values
Definition forge_param_descriptor.hpp:98
std::string_view description
Definition forge_param_descriptor.hpp:97
std::string_view label
Definition forge_param_descriptor.hpp:96
std::string_view key
Definition forge_param_descriptor.hpp:95
One axis/value selection used to construct a concrete realization.
Definition forge_param_descriptor.hpp:106
std::string_view value
Definition forge_param_descriptor.hpp:108
std::string_view axis
Definition forge_param_descriptor.hpp:107
std::string mode
Stable mode key, e.g. "silicon_x4".
Definition forge_param_descriptor.hpp:115
ForgeRealization(std::string_view mode_in, std::string_view type_id_in, std::vector< ForgeRealizationSetting > settings_in={})
Definition forge_param_descriptor.hpp:122
std::vector< ForgeRealizationSetting > settings
Exactly one selection for each declared realization axis.
Definition forge_param_descriptor.hpp:119
std::string type_id
The node type id registered with the graph.
Definition forge_param_descriptor.hpp:117