70 if (
typeid(T).name() == type_id) {
71 return static_cast<T*
>(
this);
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 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; }
327 [[nodiscard]] std::span<const float> get_gpu_data_buffer()
const;
368 virtual void reset_processed_state_internal();
378 double m_last_output { 0 };
387 bool m_gpu_compatible {};
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 };
483 std::atomic<uint32_t> m_active_channels_mask { 0 };
492 std::atomic<uint32_t> m_pending_reset_mask { 0 };
std::string type_id
Type identifier for runtime type checking.
virtual ~NodeContext()=default
double value
Current sample value.
NodeContext(double value, const std::string &type)
Protected constructor for NodeContext.
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.
virtual void save_state()=0
Saves the node's current state for later restoration Recursively cascades through all connected modul...
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.
virtual void restore_state()=0
Restores the node's state from the last save Recursively cascades through all connected modulator nod...
const std::atomic< uint32_t > & get_channel_mask() const
Retrieves the current bitmask of active channels using this node.
NodeContext & get_last_context()
Retrieves the last created context object.
virtual void notify_tick(double value)=0
Notifies all registered callbacks with the current context.
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.
virtual std::unique_ptr< NodeContext > create_context(double value)=0
Creates an appropriate context object for this node type.
std::unique_ptr< NodeContext > m_last_context
The last context object created for callbacks.
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.