MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
NodeSpec.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Nodes {
4
5inline constexpr uint32_t MAX_CHANNEL_COUNT = 32; ///< Hard limit imposed by uint32_t channel mask width
6
7/**
8 * @enum NodeChainSemantics
9 * @brief Defines how to handle existing nodes when creating a new chain
10 */
11enum NodeChainSemantics : uint8_t {
12 REPLACE_TARGET, ///< Unregister the target and register with the new chain node
13 PRESERVE_BOTH, ///< Preserve both nodes in the chain, add new chain node to root, i.e doubling the target signal
14 ONLY_CHAIN ///< Only keep the new chain node, unregistering the source and target
15};
16
17/**
18 * @enum NodeMixSemantics
19 * @brief Defines how to handle existing nodes when creating a new mix
20 */
21enum NodeBinaryOpSemantics : uint8_t {
22 REPLACE, ///< Unregister both nodes and register with the new binary op node
23 KEEP ///< Preserve both nodes in the binary op, add new binary op node to root, i.e doubling the signal
24};
25
26/**
27 * @brief Configuration settings for individual audio nodes
28 */
29struct NodeConfig {
30 size_t channel_cache_size { 256 }; ///< Number of cached channels for oprations
31 uint32_t max_channels { MAX_CHANNEL_COUNT }; ///< Cannot exceed MAX_CHANNEL_COUNT
32 size_t callback_cache_size { 64 };
34
37};
38
39/**
40 * @enum NodeState
41 * @brief Represents the processing state of a node in the audio graph
42 */
43enum NodeState : uint32_t {
44 INACTIVE = 0x00, ///< Engine is not processing this node
45 ACTIVE = 0x01, ///< Engine is processing this node
46 PENDING_REMOVAL = 0x02, ///< Node is marked for removal
47
48 OUTPUT_EXCLUDED = 0x04, ///< Node is processed but its output is left out of the graph
49 PROCESSED = 0x08, ///< Node has been processed this cycle
50
51 ENGINE_PROCESSED = ACTIVE | PROCESSED, ///< Engine has processed this node
52 EXTERMAL_PROCESSED = INACTIVE | PROCESSED, ///< External source has processed this node
53 ENGINE_OUTPUT_EXCLUDED_PROCESSED = ACTIVE | OUTPUT_EXCLUDED | PROCESSED, ///< Engine has processed this node with its output excluded
54
55 MOCK_PROCESS [[deprecated("use OUTPUT_EXCLUDED")]] = OUTPUT_EXCLUDED,
56 ENGINE_MOCK_PROCESSED [[deprecated("use ENGINE_OUTPUT_EXCLUDED_PROCESSED")]] = ENGINE_OUTPUT_EXCLUDED_PROCESSED,
57 OUTPUT_HIDDEN [[deprecated("use OUTPUT_EXCLUDED")]] = OUTPUT_EXCLUDED,
58 ENGINE_OUTPUT_HIDDEN_PROCESSED [[deprecated("use ENGINE_OUTPUT_EXCLUDED_PROCESSED")]] = ENGINE_OUTPUT_EXCLUDED_PROCESSED,
59};
60
61/**
62 * @struct RoutingState
63 * @brief Represents the state of routing transitions for a node
64 *
65 * This structure tracks the state of routing changes, including fade-in and fade-out phases,
66 * channel counts, and elapsed cycles. It's used to manage smooth transitions when routing
67 * changes occur, ensuring seamless audio output during dynamic reconfigurations of the processing graph.
68 */
70 double amount[32];
71 uint32_t cycles_elapsed {};
72 uint32_t from_channels {};
73 uint32_t to_channels {};
74 uint32_t fade_cycles {};
75
76 /**
77 * @enum Phase
78 * @brief Represents the current phase of a routing transition
79 *
80 * This enum defines the different phases of a routing transition, such as fade-out and fade-in.
81 * It allows the audio engine to manage the transition process effectively, ensuring that audio
82 * output remains seamless during dynamic changes in the processing graph.
83 */
84 enum Phase : uint8_t {
85 NONE = 0x00, ///< No routing transition is currently active
86 ACTIVE = 0x01, ///< Currently in the fade-out phase of a routing transition
87 COMPLETED = 0x02 ///< Routing transition has completed
88 } phase { Phase::NONE };
89};
90
91/**
92 * @enum NodeCapability
93 * @brief Bitmask flags declaring what data shapes a node's context can produce.
94 *
95 * SCALAR is guaranteed by the Node interface itself (process_sample always returns double).
96 * All other flags are opt-in: a node sets them when its NodeContext also derives from
97 * the corresponding GpuContext mixin (GpuVectorData, GpuMatrixData, GpuStructuredData).
98 *
99 * Flags are combinable; a node may expose multiple shapes simultaneously.
100 *
101 * Example:
102 * @code
103 * // Node whose context derives from GpuVectorData:
104 * uint32_t node_capabilities() const override {
105 * return NodeCapability::SCALAR | NodeCapability::VECTOR;
106 * }
107 * @endcode
108 */
109enum NodeCapability : uint8_t {
110 SCALAR = 1U << 0, ///< Single double from process_sample — always present
111 VECTOR = 1U << 1, ///< Context also implements GpuVectorData
112 MATRIX = 1U << 2, ///< Context also implements GpuMatrixData
113 STRUCTURED = 1U << 3, ///< Context also implements GpuStructuredData
114};
115
116}
NodeState
Represents the processing state of a node in the audio graph.
Definition NodeSpec.hpp:43
@ ENGINE_OUTPUT_EXCLUDED_PROCESSED
Engine has processed this node with its output excluded.
Definition NodeSpec.hpp:53
@ PROCESSED
Node has been processed this cycle.
Definition NodeSpec.hpp:49
@ ACTIVE
Engine is processing this node.
Definition NodeSpec.hpp:45
@ EXTERMAL_PROCESSED
External source has processed this node.
Definition NodeSpec.hpp:52
@ INACTIVE
Engine is not processing this node.
Definition NodeSpec.hpp:44
@ PENDING_REMOVAL
Node is marked for removal.
Definition NodeSpec.hpp:46
@ ENGINE_OUTPUT_HIDDEN_PROCESSED
Definition NodeSpec.hpp:58
@ ENGINE_PROCESSED
Engine has processed this node.
Definition NodeSpec.hpp:51
@ OUTPUT_EXCLUDED
Node is processed but its output is left out of the graph.
Definition NodeSpec.hpp:48
constexpr uint32_t MAX_CHANNEL_COUNT
Hard limit imposed by uint32_t channel mask width.
Definition NodeSpec.hpp:5
NodeCapability
Bitmask flags declaring what data shapes a node's context can produce.
Definition NodeSpec.hpp:109
@ VECTOR
Context also implements GpuVectorData.
Definition NodeSpec.hpp:111
@ STRUCTURED
Context also implements GpuStructuredData.
Definition NodeSpec.hpp:113
@ MATRIX
Context also implements GpuMatrixData.
Definition NodeSpec.hpp:112
@ SCALAR
Single double from process_sample — always present.
Definition NodeSpec.hpp:110
@ KEEP
Preserve both nodes in the binary op, add new binary op node to root, i.e doubling the signal.
Definition NodeSpec.hpp:23
@ REPLACE
Unregister both nodes and register with the new binary op node.
Definition NodeSpec.hpp:22
NodeChainSemantics
Defines how to handle existing nodes when creating a new chain.
Definition NodeSpec.hpp:11
@ PRESERVE_BOTH
Preserve both nodes in the chain, add new chain node to root, i.e doubling the target signal.
Definition NodeSpec.hpp:13
@ ONLY_CHAIN
Only keep the new chain node, unregistering the source and target.
Definition NodeSpec.hpp:14
@ REPLACE_TARGET
Unregister the target and register with the new chain node.
Definition NodeSpec.hpp:12
Contains the node-based computational processing system components.
Definition Chronie.hpp:14
uint32_t max_channels
Cannot exceed MAX_CHANNEL_COUNT.
Definition NodeSpec.hpp:31
size_t channel_cache_size
Number of cached channels for oprations.
Definition NodeSpec.hpp:30
NodeBinaryOpSemantics binary_op_semantics
Definition NodeSpec.hpp:36
NodeChainSemantics chain_semantics
Definition NodeSpec.hpp:35
Configuration settings for individual audio nodes.
Definition NodeSpec.hpp:29
enum MayaFlux::Nodes::RoutingState::Phase NONE
Phase
Represents the current phase of a routing transition.
Definition NodeSpec.hpp:84
@ COMPLETED
Routing transition has completed.
Definition NodeSpec.hpp:87
@ NONE
No routing transition is currently active.
Definition NodeSpec.hpp:85
@ ACTIVE
Currently in the fade-out phase of a routing transition.
Definition NodeSpec.hpp:86
Represents the state of routing transitions for a node.
Definition NodeSpec.hpp:69