Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
processor_node_adapter.hpp
Go to the documentation of this file.
1#pragma once
2
9
10#include <memory>
11#include <array>
12#include <span>
13#include <string>
14#include <vector>
15
16namespace pulp::format {
17
37public:
40 explicit ProcessorNode(Processor& processor) noexcept
41 : processor_(&processor) {}
42
48 bool prepare(const PrepareContext& context);
49 bool release() noexcept;
50
56 input_provider_ = provider;
57 }
58
61 GraphRuntimeNodeBinding binding(graph::NodeId node_id, bool required = true) noexcept;
62
70 static bool process_binding(ProcessBlock& block,
72 void* user_data) noexcept;
73
74 Processor& processor() noexcept { return *processor_; }
75 const Processor& processor() const noexcept { return *processor_; }
76
77 private:
78 // The routed block for a node with one main input and one main output and
79 // no dense modulation: the views and context are prepared, so a block only
80 // points them at this block's buffers (see process_binding).
81 bool process_main_bus_block(const ProcessBlock& block,
82 const GraphRuntimeNodeProcessContext& ctx) noexcept;
83
84 Processor* processor_;
85 // Caller-owned MIDI/parameter fallback storage for the block bridge. Sized
86 // once in prepare() and reused across blocks; never resized on the RT path.
88 // The block's bus set, rebuilt per block by clear() and add_*(). Reusing it
89 // avoids constructing all kMaxBuses entries for the one to three buses a
90 // node uses.
91 BusBufferSet buses_;
92 // Chosen at prepare(): true when the node has at most one (main) input bus
93 // and no dense modulation, so process_binding takes process_main_bus_block.
94 bool main_bus_fast_path_ = false;
95 // The context handed to the processor when the block carries no complete
96 // transport; only sample_rate and num_samples change per block.
97 ProcessContext block_context_{};
98 bool block_context_from_transport_ = false;
99 NodeCapabilities capabilities_{};
100 AudioInputBusProvider input_provider_{};
101 std::array<BusRole, BusBufferSet::kMaxBuses> input_roles_{};
102 std::array<int, BusBufferSet::kMaxBuses> input_channels_{};
103 std::array<bool, BusBufferSet::kMaxBuses> input_optional_{};
104 // Descriptor-owned names are copied during prepare() so the routed block
105 // can publish stable, non-owning string_views without allocating on RT.
106 std::array<std::string, BusBufferSet::kMaxBuses> input_names_{};
107 std::size_t input_bus_count_ = 0;
108 bool prepared_ = false;
109};
110
115 public:
116 static std::shared_ptr<ProcessorNodeInstance>
117 create(std::unique_ptr<Processor> processor) noexcept;
118
122
123 bool prepare(const PrepareContext& context) noexcept;
124 bool release() noexcept;
126 adapter_.set_audio_input_provider(provider);
127 }
128 GraphRuntimeNodeBinding binding(graph::NodeId node_id, bool required = true) noexcept {
129 return adapter_.binding(node_id, required);
130 }
131
132 const PluginDescriptor& descriptor() const noexcept {
133 return descriptor_;
134 }
135 int graph_type_version() const noexcept {
136 return graph_type_version_;
137 }
138 void set_graph_type_version(int version) noexcept {
139 graph_type_version_ = version;
140 }
141 std::string_view graph_type_id() const noexcept {
142 return graph_type_id_;
143 }
144 void set_graph_type_id(std::string id) {
145 graph_type_id_ = std::move(id);
146 }
147 int graph_state_schema_version() const noexcept {
148 return graph_state_schema_version_;
149 }
150 void set_graph_state_schema_version(int version) noexcept {
151 graph_state_schema_version_ = version;
152 }
153 std::span<const state::ParamInfo> parameter_catalog() const noexcept {
154 return parameter_catalog_;
155 }
156 const state::ParamInfo* parameter(state::ParamID id) const noexcept;
158 return state_store_;
159 }
160 const state::StateStore& state_store() const noexcept {
161 return state_store_;
162 }
163 Processor& processor() noexcept {
164 return *processor_;
165 }
166 const Processor& processor() const noexcept {
167 return *processor_;
168 }
169
170 private:
171 explicit ProcessorNodeInstance(std::unique_ptr<Processor> processor)
172 : processor_(std::move(processor)), adapter_(*processor_) {}
173
174 state::StateStore state_store_;
175 // Declared after the store so Processor destruction runs first while its
176 // StateStore pointer is still valid.
177 std::unique_ptr<Processor> processor_;
178 PluginDescriptor descriptor_;
179 std::vector<state::ParamInfo> parameter_catalog_;
180 int graph_type_version_ = 1;
181 std::string graph_type_id_;
182 int graph_state_schema_version_ = 1;
183 ProcessorNode adapter_;
184 bool prepared_ = false;
185};
186
187} // namespace pulp::format
Fixed-capacity, non-owning set of block-local bus views.
Definition process_block.hpp:146
void set_graph_type_id(std::string id)
Definition processor_node_adapter.hpp:144
int graph_type_version() const noexcept
Definition processor_node_adapter.hpp:135
Processor & processor() noexcept
Definition processor_node_adapter.hpp:163
state::StateStore & state_store() noexcept
Definition processor_node_adapter.hpp:157
void set_audio_input_provider(AudioInputBusProvider provider) noexcept
Definition processor_node_adapter.hpp:125
const PluginDescriptor & descriptor() const noexcept
Definition processor_node_adapter.hpp:132
void set_graph_type_version(int version) noexcept
Definition processor_node_adapter.hpp:138
ProcessorNodeInstance & operator=(const ProcessorNodeInstance &)=delete
int graph_state_schema_version() const noexcept
Definition processor_node_adapter.hpp:147
const state::ParamInfo * parameter(state::ParamID id) const noexcept
GraphRuntimeNodeBinding binding(graph::NodeId node_id, bool required=true) noexcept
Definition processor_node_adapter.hpp:128
void set_graph_state_schema_version(int version) noexcept
Definition processor_node_adapter.hpp:150
static std::shared_ptr< ProcessorNodeInstance > create(std::unique_ptr< Processor > processor) noexcept
bool prepare(const PrepareContext &context) noexcept
std::span< const state::ParamInfo > parameter_catalog() const noexcept
Definition processor_node_adapter.hpp:153
std::string_view graph_type_id() const noexcept
Definition processor_node_adapter.hpp:141
const Processor & processor() const noexcept
Definition processor_node_adapter.hpp:166
const state::StateStore & state_store() const noexcept
Definition processor_node_adapter.hpp:160
ProcessorNodeInstance(const ProcessorNodeInstance &)=delete
void set_audio_input_provider(AudioInputBusProvider provider) noexcept
Install a host-owned route provider before prepare().
Definition processor_node_adapter.hpp:55
GraphRuntimeNodeBinding binding(graph::NodeId node_id, bool required=true) noexcept
Build the only valid graph binding for this adapter.
bool prepare(const PrepareContext &context)
Off-RT preparation: prepares the wrapped processor for the given audio configuration and sizes the bl...
ProcessorNode(Processor &processor) noexcept
Wrap a non-owning processor.
Definition processor_node_adapter.hpp:40
Processor & processor() noexcept
Definition processor_node_adapter.hpp:74
static bool process_binding(ProcessBlock &block, const GraphRuntimeNodeProcessContext &ctx, void *user_data) noexcept
Routed node binding entry point.
const Processor & processor() const noexcept
Definition processor_node_adapter.hpp:75
Definition processor.hpp:174
Centralized parameter storage with lock-free value access.
Definition store.hpp:164
What the product grants a device: the quota table indexed by capability tier and live thermal state.
Definition aax_editor.hpp:31
std::uint32_t NodeId
Definition graph_types.hpp:7
uint32_t ParamID
Unique parameter identifier, stable across plugin versions.
Definition parameter.hpp:55
STL namespace.
A host-owned, realtime-safe view provider for declared processor input buses.
Definition audio_input_provider.hpp:17
Definition graph_runtime_executor.hpp:130
Definition graph_runtime_executor.hpp:70
Plugin metadata — declared once, immutable.
Definition plugin_descriptor.hpp:245
Definition prepare_resources.hpp:102
Additive block-scoped process contract.
Definition process_block.hpp:517
Process context — passed every audio callback with transport state.
Definition process_context.hpp:89
Caller-owned fallback storage for process_processor_block().
Definition processor_block_adapter.hpp:17
Immutable parameter metadata, registered once at plugin initialization.
Definition parameter.hpp:316