31#include "dsp/itransport.h"
32#include "dsp/tempo_map.h"
33#include "utils/units.h"
42namespace zrythm::dsp::graph
101 return units::samples (0);
114 units::sample_rate_t sample_rate,
115 units::sample_u32_t max_block_length)
119 [[gnu::hot]]
virtual void process_block (
122 const dsp::TempoMap &tempo_map)
noexcept [[clang::nonblocking]] { };
165 GraphNode (
const GraphNode &) =
delete;
166 GraphNode &operator= (
const GraphNode &) =
delete;
167 GraphNode (GraphNode &&) =
delete;
168 GraphNode &operator= (GraphNode &&) =
delete;
169 ~GraphNode ()
noexcept =
default;
175 NodeId get_id ()
const {
return node_id_; }
189 units::sample_u64_t remaining_preroll_frames,
191 const dsp::TempoMap &tempo_map)
const;
193 units::sample_u32_t get_single_playback_latency ()
const
195 return processable_.get_single_playback_latency ();
207 void connect_to (GraphNode &target);
219 IProcessable &get_processable () {
return processable_; }
224 auto &
feeds ()
const {
return childnodes_; }
229 auto &
depends ()
const {
return parentnodes_; }
231 bool remove_feed (
const GraphNode &feed);
232 bool remove_depend (
const GraphNode &depend);
248 [[gnu::hot]]
void compensate_latency (
250 units::sample_u32_t remaining_preroll_frames,
252 const dsp::TempoMap &tempo_map)
const;
263 [[gnu::hot]]
void process_chunks_after_splitting_at_loop_points (
266 const dsp::TempoMap &tempo_map)
const;
297 bool terminal_{
false };
298 bool initial_{
false };
309 std::vector<std::reference_wrapper<GraphNode>> parentnodes_;
316 std::vector<std::reference_wrapper<GraphNode>> childnodes_;
318 IProcessable &processable_;
323 bool bypass_ =
false;
382 std::unique_ptr<InitialProcessor> initial_processor_;
Manages the collection of graph nodes.
void update_latencies()
Updates the latencies of all 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.
units::sample_u32_t get_max_route_playback_latency() const
Returns the max playback latency of the trigger 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.
units::sample_u32_t capture_latency_
The capture latency of the node, in samples.
std::atomic< int > refcount_
Incoming node count.
auto & feeds() const
Read-only access to child nodes (outgoing connections).
units::sample_u32_t playback_latency_
The playback latency of the node, in samples.
void set_route_playback_latency(units::sample_u32_t dest_latency)
Sets the playback latency of the given node recursively.
units::sample_u32_t route_playback_latency_
The route's playback latency so far.
auto & depends() const
Read-only access to parent nodes (incoming connections).
void process(dsp::graph::EngineProcessTimeInfo time_nfo, units::sample_u64_t remaining_preroll_frames, const dsp::ITransport &transport, const dsp::TempoMap &tempo_map) const
Processes the GraphNode.
void set_skip_processing(bool skip)
Sets whether processing should be skipped for this node.
Interface for objects that can be processed in the DSP graph.
virtual void prepare_for_processing(const GraphNode *node, units::sample_rate_t sample_rate, units::sample_u32_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().
virtual units::sample_u32_t get_single_playback_latency() const
Returns the latency of only the given processable, without adding the previous/next latencies (zero l...
utils::Utf8String get_node_name() const override
Returns a human friendly name of the node.
Lightweight UTF-8 string wrapper with safe conversions.
Common struct to pass around during processing to avoid repeating the data in function arguments.
units::sample_u64_t g_start_frame_
Global position at the start of the processing cycle (no offset added).
units::sample_u32_t nframes_
Number of frames to process in this call, starting from the offset.
units::sample_u32_t local_offset_
Offset in the current processing cycle, between 0 and the number of frames in AudioEngine....
units::sample_u64_t g_start_frame_w_offset_
Global position with dsp::graph::EngineProcessTimeInfo.local_offset added, for convenience.