70 if (
typeid(T).name() == type_id) {
71 return static_cast<T*
>(
this);
87 , type_id(
std::move(type))
163 virtual void on_tick(
const NodeHook& callback);
200 virtual bool remove_hook(
const NodeHook& callback);
214 virtual bool remove_conditional_hook(
const NodeCondition& callback);
226 virtual void remove_all_hooks();
236 virtual void reset_processed_state();
262 void register_channel_usage(uint32_t channel_id);
268 void unregister_channel_usage(uint32_t channel_id);
274 [[nodiscard]]
bool is_used_by_channel(uint32_t channel_id)
const;
285 void request_reset_from_channel(uint32_t channel_id);
296 [[nodiscard]]
const inline std::atomic<uint32_t>&
get_channel_mask()
const {
return m_active_channels_mask; }
338 [[nodiscard]] std::span<const float> get_gpu_data_buffer()
const;
364 virtual void reset_processed_state_internal();
374 double m_last_output { 0 };
383 bool m_gpu_compatible {};
421 bool m_networked_node {};
426 bool m_state_saved {};
448 bool m_fire_events_during_snapshot =
false;
463 std::atomic<Utils::NodeState> m_state { Utils::NodeState::INACTIVE };
477 std::atomic<uint32_t> m_modulator_count { 0 };
488 bool try_claim_snapshot_context(uint64_t context_id);
498 [[nodiscard]]
bool is_in_snapshot_context(uint64_t context_id)
const;
507 void release_snapshot_context(uint64_t context_id);
513 [[nodiscard]]
bool has_active_snapshot()
const;
521 return m_snapshot_context_id.load(std::memory_order_acquire);
529 void add_buffer_reference();
536 void remove_buffer_reference();
546 bool mark_buffer_processed();
555 void request_buffer_reset();
563 return m_buffer_processed.load(std::memory_order_acquire);
574 [[nodiscard]]
inline bool is_in_network()
const {
return m_networked_node; }
590 std::atomic<uint32_t> m_active_channels_mask { 0 };
599 std::atomic<uint32_t> m_pending_reset_mask { 0 };
610 std::atomic<uint64_t> m_snapshot_context_id { 0 };
618 std::atomic<uint32_t> m_buffer_count { 0 };
625 std::atomic<bool> m_buffer_processed {
false };
634 std::atomic<uint32_t> m_buffer_reset_count { 0 };
std::string type_id
Type identifier for runtime type checking.
virtual ~NodeContext()=default
NodeContext(double value, std::string type)
Protected constructor for NodeContext.
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.
void set_gpu_compatible(bool compatible)
Sets whether the node is compatible with GPU processing.
std::vector< NodeHook > m_callbacks
Collection of standard callback functions.
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.
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 is_gpu_compatible() const
Checks if the node supports GPU processing.
std::vector< std::pair< NodeHook, NodeCondition > > m_conditional_callbacks
Collection of conditional callback functions with their predicates.
virtual ~Node()=default
Virtual destructor for proper cleanup of derived classes.
std::vector< float > m_gpu_data_buffer
GPU data buffer for context objects.
Base interface for all computational processing nodes.
std::function< void(NodeContext &)> NodeHook
Callback function type for node processing events.
std::function< bool(NodeContext &)> NodeCondition
Predicate function type for conditional callbacks.
Contains the node-based computational processing system components.