36 std::shared_ptr<Node>
node;
85 return dynamic_cast<T*
>(
this);
91 return dynamic_cast<const T*
>(
this);
246 virtual void remove_all_hooks();
253 virtual bool unhook(
HookId id);
263 virtual void reset_processed_state();
288 virtual void exclude_output_from_graph(
bool excluded =
true);
291 [[nodiscard]]
virtual bool is_output_excluded_from_graph()
const;
296 exclude_output_from_graph(mock_process);
302 return is_output_excluded_from_graph();
315 void register_channel_usage(uint32_t channel_id);
321 void unregister_channel_usage(uint32_t channel_id);
327 [[nodiscard]]
bool is_used_by_channel(uint32_t channel_id)
const;
338 void request_reset_from_channel(uint32_t channel_id);
349 [[nodiscard]]
const inline std::atomic<uint32_t>&
get_channel_mask()
const {
return m_active_channels_mask; }
378 m_gpu_compatible = compatible;
380 m_timing_rate = m_frame_rate;
382 m_timing_rate = m_sample_rate;
399 [[nodiscard]] std::span<const float> get_gpu_data_buffer()
const;
431 virtual void reset_processed_state_internal();
441 double m_last_output { 0 };
450 bool m_gpu_compatible {};
470 std::atomic<HookId> m_next_hook_id { 1 };
493 bool m_networked_node {};
498 bool m_state_saved {};
500 uint32_t m_sample_rate { 48000 };
502 uint32_t m_frame_rate { 60 };
504 uint32_t m_timing_rate { m_sample_rate };
506 uint8_t m_node_capability { NodeCapability::SCALAR };
528 bool m_fire_events_during_snapshot =
false;
543 std::atomic<NodeState> m_state { NodeState::INACTIVE };
557 std::atomic<uint32_t> m_modulator_count { 0 };
568 bool try_claim_snapshot_context(uint64_t context_id);
578 [[nodiscard]]
bool is_in_snapshot_context(uint64_t context_id)
const;
587 void release_snapshot_context(uint64_t context_id);
593 [[nodiscard]]
bool has_active_snapshot()
const;
601 return m_snapshot_context_id.load(std::memory_order_acquire);
609 void add_buffer_reference();
616 void remove_buffer_reference();
626 bool mark_buffer_processed();
635 void request_buffer_reset();
643 return m_buffer_processed.load(std::memory_order_acquire);
654 [[nodiscard]]
inline bool is_in_network()
const {
return m_networked_node; }
694 return m_routing_state.phase & (RoutingState::ACTIVE | RoutingState::COMPLETED);
716 return (m_node_capability & cap) != 0U;
726 [[nodiscard]]
virtual std::vector<std::pair<ModulatorRole, std::shared_ptr<Node>>>
738 std::vector<ModulatorTree> result;
739 for (
auto& [role, node] : get_modulators()) {
743 entry.
modulators = node->get_modulator_tree();
744 result.push_back(std::move(entry));
753 std::atomic<uint32_t> m_active_channels_mask { 0 };
762 std::atomic<uint32_t> m_pending_reset_mask { 0 };
773 std::atomic<uint64_t> m_snapshot_context_id { 0 };
781 std::atomic<uint32_t> m_buffer_count { 0 };
788 std::atomic<bool> m_buffer_processed {
false };
797 std::atomic<uint32_t> m_buffer_reset_count { 0 };
Core::GlobalInputConfig input
Stores, fires and clears the hooks of one node channel.
NodeContext(double value)
Protected constructor for NodeContext.
virtual ~NodeContext()=default
double value
Current sample value.
T * as()
Safely cast to a derived context type.
Base context class for node callbacks.
virtual double process_sample(double input=0.)=0
Processes a single data sample.
virtual double get_last_output()
Retrieves the most recent output value produced by the node.
virtual std::vector< double > process_batch(unsigned int num_samples)=0
Processes multiple samples at once.
bool is_buffer_processed() const
Checks if the buffer has been processed.
virtual void save_state()=0
Saves the node's current state for later restoration Recursively cascades through all connected modul...
bool is_in_network() const
Sets whether the node is part of a NodeNetwork.
uint32_t get_frame_rate() const
void set_in_network(bool networked)
Marks the node as being part of a NodeNetwork.
virtual void restore_state()=0
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
uint64_t get_active_snapshot_context() const
Get the active snapshot context ID.
const std::atomic< uint32_t > & get_channel_mask() const
Retrieves the current bitmask of active channels using this node.
bool needs_channel_routing() const
Checks if the network is currently in a routing transition phase.
void enable_mock_process(bool mock_process)
Old name of exclude_output_from_graph().
virtual NodeContext & get_last_context()=0
Retrieves the last created context object.
virtual void notify_tick(double value)=0
Notifies all registered callbacks with the current context.
virtual void update_context(double value)=0
Updates the context object with the current node state.
bool should_mock_process() const
Old name of is_output_excluded_from_graph().
virtual void set_gpu_compatible(bool compatible)
Sets whether the node is compatible with GPU processing.
void set_sample_rate(uint32_t sample_rate)
bool is_gpu_compatible() const
Checks if the node supports GPU processing.
virtual ~Node()=default
Virtual destructor for proper cleanup of derived classes.
uint32_t get_sample_rate() const
RoutingState & get_routing_state()
Retrieves the current routing state of the network (non-const)
bool has_capability(NodeCapability cap) const
Query a single capability.
std::vector< ModulatorTree > get_modulator_tree() const
Returns the full modulator tree rooted at this node.
void set_frame_rate(uint32_t frame_rate)
virtual std::vector< std::pair< ModulatorRole, std::shared_ptr< Node > > > get_modulators() const
Returns direct modulator nodes and their roles.
void register_hook_list(HookList &list)
std::vector< float > m_gpu_data_buffer
GPU data buffer for context objects.
RoutingState m_routing_state
Internal state tracking for routing transitions.
std::vector< HookList * > m_hook_lists
virtual uint8_t node_capabilities() const
Declare which data shapes this node's context can produce.
const RoutingState & get_routing_state() const
Retrieves the current routing state of the network.
Base interface for all computational processing nodes.
TypedHook<> NodeHook
Alias for TypedHook<NodeContext>.
ModulatorRole
Describes the role a modulator node plays relative to its owner.
uint64_t HookId
Identifies one registration inside a HookList.
NodeCapability
Bitmask flags declaring what data shapes a node's context can produce.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
Contains the node-based computational processing system components.
std::vector< ModulatorTree > modulators
std::shared_ptr< Node > node
Recursive tree node describing a modulator and all of its own modulators.
Represents the state of routing transitions for a node.