31#include "dsp/itransport.h"
32#include "dsp/tempo_map.h"
33#include "utils/units.h"
42namespace zrythm::dsp::graph
56 units::sample_u64_t transport_position,
57 units::sample_u32_t nframes)
60 .transport_position_ = transport_position,
61 .buffer_offset_ = units::samples (0),
66 [[gnu::hot]]
constexpr units::sample_u64_t end_position ()
const noexcept
114 return units::samples (0);
127 units::sample_rate_t sample_rate,
128 units::sample_u32_t max_block_length)
132 [[gnu::hot]]
virtual void process_block (
135 const dsp::TempoMap &tempo_map)
noexcept [[clang::nonblocking]] { };
178 GraphNode (
const GraphNode &) =
delete;
179 GraphNode &operator= (
const GraphNode &) =
delete;
180 GraphNode (GraphNode &&) =
delete;
181 GraphNode &operator= (GraphNode &&) =
delete;
182 ~GraphNode ()
noexcept =
default;
188 NodeId get_id ()
const {
return node_id_; }
202 units::sample_u64_t remaining_preroll_frames,
204 const dsp::TempoMap &tempo_map)
const;
206 units::sample_u32_t get_single_playback_latency ()
const
208 return processable_.get_single_playback_latency ();
220 void connect_to (GraphNode &target);
232 IProcessable &get_processable () {
return processable_; }
237 auto &
feeds ()
const {
return childnodes_; }
242 auto &
depends ()
const {
return parentnodes_; }
244 bool remove_feed (
const GraphNode &feed);
245 bool remove_depend (
const GraphNode &depend);
261 [[gnu::hot]]
void compensate_latency (
263 units::sample_u32_t remaining_preroll_frames,
265 const dsp::TempoMap &tempo_map)
const;
276 [[gnu::hot]]
void process_chunks_after_splitting_at_loop_points (
279 const dsp::TempoMap &tempo_map)
const;
310 bool terminal_{
false };
311 bool initial_{
false };
322 std::vector<std::reference_wrapper<GraphNode>> parentnodes_;
329 std::vector<std::reference_wrapper<GraphNode>> childnodes_;
331 IProcessable &processable_;
336 bool bypass_ =
false;
395 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::ProcessBlockInfo 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_u32_t buffer_offset_
Offset in the current processing cycle's audio buffer, between 0 and the number of frames in AudioEng...
units::sample_u32_t nframes_
Number of frames to process in this call, starting from the offset.
units::sample_u64_t transport_position_
Transport (timeline) position at the start of this chunk (already taking into account the offset).