Pulp 1.88.0
Cross-platform audio plugin framework
Loading...
Searching...
No Matches
offline_signal_graph_host.hpp
Go to the documentation of this file.
1#pragma once
2
3// Offline render host for pulp::host::SignalGraph.
4//
5// OfflineSignalGraphHost is a control-thread/test harness layered ON TOP of the
6// public SignalGraph API — it never touches SignalGraph internals. It owns the
7// staging + output buffers and steps a fixed block size across a frame range,
8// feeding each block through SignalGraph::process(). Its purpose is to render a
9// graph the same way a real-time host would, but deterministically and without
10// a live audio device, so the same graph can be rendered at different block
11// partitionings and compared.
12//
13// Scope note (invariant "offline equals online"): this host drives the
14// no-transport SignalGraph::process() overload, so no node receives host
15// transport here regardless of whether it opts in (routed nodes can consume
16// transport via the transport-bearing overload, but this host never supplies
17// one). The only thing that distinguishes an "online" (live, block-by-block)
18// render from an "offline" one here is therefore the block partitioning. For
19// DETERMINISTIC nodes whose output depends only on the current block's samples,
20// rendering the same input at any block size must produce the same result.
21// This host makes that comparison cheap to set up.
22//
23// Usage:
24// SignalGraph graph;
25// ... build + connect nodes ...
26// OfflineSignalGraphHost host(graph);
27// OfflineSignalGraphConfig cfg; cfg.block_frames = 128;
28// host.prepare(cfg);
29// OfflineSignalGraphOptions opt; opt.frame_count = 4096; opt.input = in_view;
30// auto result = host.render(opt); // result.audio holds the rendered output
31
32#include <pulp/audio/buffer.hpp>
33
34#include <cstdint>
35#include <vector>
36
37namespace pulp::host {
38
39class SignalGraph;
40
43 double sample_rate = 48000.0;
44 int block_frames = 512;
47};
48
56
64
69public:
71
78
79 bool prepared() const noexcept { return prepared_; }
80 const OfflineSignalGraphConfig& config() const noexcept { return config_; }
81
86
87private:
88 SignalGraph& graph_;
90 bool prepared_ = false;
91
92 audio::Buffer<float> input_block_;
93 audio::Buffer<float> output_block_;
94 // Channel-pointer arrays over the staging buffers, rebuilt in prepare() so
95 // render() can construct BufferViews without per-block allocation. Held as
96 // float* (writable) and converted to const for the input view.
97 std::vector<float*> input_ptrs_;
98 std::vector<float*> output_ptrs_;
99};
100
101} // namespace pulp::host
Non-owning view over multi-channel audio sample data.
Definition buffer.hpp:30
Owning multi-channel audio buffer with contiguous storage.
Definition buffer.hpp:119
OfflineSignalGraphResult render(const OfflineSignalGraphOptions &options)
Render options.frame_count frames in config().block_frames steps.
OfflineSignalGraphHost(SignalGraph &graph)
bool prepare(const OfflineSignalGraphConfig &config)
Prepare the graph for config.block_frames blocks and pre-size the staging buffers so render() never a...
bool prepared() const noexcept
Definition offline_signal_graph_host.hpp:79
const OfflineSignalGraphConfig & config() const noexcept
Definition offline_signal_graph_host.hpp:80
Definition signal_graph_runtime.hpp:83
Definition graph_runtime_buffer_assignment.hpp:8
Bounded event contracts shared by host ingress and graph-authored nodes.
Definition anticipation_eligibility.hpp:9
Prepare-time configuration for an offline SignalGraph render.
Definition offline_signal_graph_host.hpp:42
int output_channels
Definition offline_signal_graph_host.hpp:46
double sample_rate
Definition offline_signal_graph_host.hpp:43
int block_frames
Definition offline_signal_graph_host.hpp:44
int input_channels
Definition offline_signal_graph_host.hpp:45
Per-render inputs.
Definition offline_signal_graph_host.hpp:52
std::uint64_t frame_count
Definition offline_signal_graph_host.hpp:53
audio::BufferView< const float > input
Definition offline_signal_graph_host.hpp:54
Result of an offline render.
Definition offline_signal_graph_host.hpp:59
bool ok
Definition offline_signal_graph_host.hpp:60
int blocks_rendered
Definition offline_signal_graph_host.hpp:62
audio::Buffer< float > audio
Definition offline_signal_graph_host.hpp:61