31#include "dsp/itransport.h"
32#include "utils/utf8_string.h"
36namespace zrythm::dsp::graph
81 units::sample_rate_t sample_rate,
86 [[gnu::hot]]
virtual void process_block (
106 return u8
"Initial Processor";
134 Z_DISABLE_COPY_MOVE (GraphNode)
135 ~GraphNode ()
noexcept =
default;
140 void print_node ()
const;
143 NodeId get_id ()
const {
return node_id_; }
160 nframes_t get_single_playback_latency ()
const
162 return processable_.get_single_playback_latency ();
174 void connect_to (GraphNode &target);
186 IProcessable &get_processable () {
return processable_; }
191 auto &
feeds ()
const {
return childnodes_; }
196 auto &
depends ()
const {
return parentnodes_; }
198 bool remove_feed (
const GraphNode &feed);
199 bool remove_depend (
const GraphNode &depend);
215 [[gnu::hot]]
void compensate_latency (
229 [[gnu::hot]]
void process_chunks_after_splitting_at_loop_points (
262 bool terminal_ =
false;
263 bool initial_ =
false;
274 std::vector<std::reference_wrapper<GraphNode>> parentnodes_;
281 std::vector<std::reference_wrapper<GraphNode>> childnodes_;
288 bool bypass_ =
false;
347 std::unique_ptr<InitialProcessor> initial_processor_;
Manages the collection of graph nodes.
void update_latencies()
Updates the latencies of all nodes.
nframes_t get_max_route_playback_latency() const
Returns the max playback latency of the trigger nodes.
void set_initial_and_terminal_nodes()
Updates the initial and terminal nodes based on graph_nodes_.
void finalize_nodes()
Sets the initial/terminal nodes.
std::vector< std::reference_wrapper< GraphNode > > trigger_nodes_
A subset of graph_nodes_ that are trigger nodes.
std::vector< std::reference_wrapper< GraphNode > > terminal_nodes_
A subset of graph_nodes_ that are terminal nodes.
std::vector< std::unique_ptr< GraphNode > > graph_nodes_
All nodes in the graph.
Represents a node in a DSP graph.
int init_refcount_
Initial incoming node count.
std::string print_node_to_str() const
For general debugging.
std::atomic< int > refcount_
Incoming node count.
nframes_t playback_latency_
The playback latency of the node, in samples.
auto & feeds() const
Read-only access to child nodes (outgoing connections).
void set_route_playback_latency(nframes_t dest_latency)
Sets the playback latency of the given node recursively.
auto & depends() const
Read-only access to parent nodes (incoming connections).
nframes_t capture_latency_
The capture latency of the node, in samples.
void process(EngineProcessTimeInfo time_nfo, nframes_t remaining_preroll_frames, const dsp::ITransport &transport) const
Processes the GraphNode.
void set_skip_processing(bool skip)
Sets whether processing should be skipped for this node.
nframes_t route_playback_latency_
The route's playback latency so far.
Interface for objects that can be processed in the DSP graph.
virtual nframes_t get_single_playback_latency() const
Returns the latency of only the given processable, without adding the previous/next latencies.
virtual void prepare_for_processing(const GraphNode *node, units::sample_rate_t sample_rate, nframes_t max_block_length)
Called to allocate resources required for processing.
virtual utils::Utf8String get_node_name() const =0
Returns a human friendly name of the node.
virtual void release_resources()
Called to release resources allocated by prepare_for_processing().
utils::Utf8String get_node_name() const override
Returns a human friendly name of the node.
Lightweight UTF-8 string wrapper with safe conversions.
uint32_t nframes_t
Frame count.
Common struct to pass around during processing to avoid repeating the data in function arguments.