MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
Graph.hpp
Go to the documentation of this file.
1#pragma once
2
5
6namespace MayaFlux {
7
8namespace Nodes {
9 class Node;
10 class NodeGraphManager;
11 class RootNode;
12 namespace Network {
13 class NodeNetwork;
14 }
15}
16
17namespace Buffers {
18 class Buffer;
19 class AudioBuffer;
20 class VKBuffer;
21 class RootAudioBuffer;
22 class BufferManager;
23 class BufferProcessor;
24 class BufferProcessingChain;
25}
26
27namespace internal {
28 std::shared_ptr<Buffers::BufferProcessor> attach_quick_process_audio(Buffers::AudioProcessingFunction processor, const std::shared_ptr<Buffers::AudioBuffer>& buffer);
29 std::shared_ptr<Buffers::BufferProcessor> attach_quick_process_graphics(Buffers::GraphicsProcessingFunction processor, const std::shared_ptr<Buffers::VKBuffer>& buffer);
30}
31
32//-------------------------------------------------------------------------
33// Node Graph Management
34//-------------------------------------------------------------------------
35
36/**
37 * @brief Gets the node graph manager from the default engine
38 * @return Shared pointer to the centrally managed NodeGraphManager
39 *
40 * Returns the node graph manager that's managed by the default engine instance.
41 * All node operations using the convenience functions will use this manager.
42 */
43MAYAFLUX_API std::shared_ptr<Nodes::NodeGraphManager> get_node_graph_manager();
44
45/**
46 * @brief Adds a node to the root node of a specific channel
47 * @param node Node to add
48 * @param channel Channel index
49 *
50 * Adds the node as a child of the root node for the specified channel.
51 * Uses the default engine's node graph manager.
52 */
53MAYAFLUX_API void register_audio_node(const std::shared_ptr<Nodes::Node>& node, uint32_t channel = 0);
54
55/**
56 * @brief Adds a node to the root node of specified channels
57 * @param node Node to add
58 * @param channels Vector of channel indices
59 *
60 * Adds the node as a child of the root node for the specified channels.
61 * Uses the default engine's node graph manager.
62 */
63MAYAFLUX_API void register_audio_node(const std::shared_ptr<Nodes::Node>& node, const std::vector<uint32_t>& channels);
64
65MAYAFLUX_API void register_node(
66 const std::shared_ptr<Nodes::Node>& node,
67 const Nodes::ProcessingToken& token,
68 uint32_t channel = 0);
69
70/**
71 * @breif Moves the node from its current channel(s) to the specified channel(s) with an optional fade time
72 * @param node Node to route
73 * @param channels Vector of channel indices to route the node to
74 * @param seconds_to_fade Time in seconds to fade the routing (optional, default is 1 second)
75 * @param token Processing domain to route within (default is AUDIO_RATE)
76 *
77 * This method adds the specified node to the root nodes of the target channels
78 * within the given processing domain. If seconds_to_fade is greater than 0, the routing
79 * will be smoothly faded in over that time period.
80 */
81MAYAFLUX_API void route_node(
82 const std::shared_ptr<Nodes::Node>& node,
83 const std::vector<uint32_t>& channels,
84 double seconds_to_fade = 1.F,
86
87/**
88 * @breif Moves the node from its current channel(s) to the specified channel(s) with an optional fade time
89 * @param node Node to route
90 * @param channels Vector of channel indices to route the node to
91 * @param num_samples Number of samples to fade the routing over (optional, default is 48000 samples for 1 second at 48kHz)
92 * @param token Processing domain to route within (default is AUDIO_RATE)
93 *
94 * This method adds the specified node to the root nodes of the target channels
95 * within the given processing domain. If num_samples is greater than 0, the routing
96 * will be smoothly faded in over that many samples.
97 */
98MAYAFLUX_API void route_node(
99 const std::shared_ptr<Nodes::Node>& node,
100 const std::vector<uint32_t>& channels,
101 uint32_t num_samples,
103
104/**
105 * @brief Removes a node from the root node of a specific channel
106 * @param node Node to remove
107 * @param channel Channel index
108 *
109 * Removes the node from being a child of the root node for the specified channel.
110 * Uses the default engine's node graph manager.
111 */
112MAYAFLUX_API void unregister_audio_node(const std::shared_ptr<Nodes::Node>& node, uint32_t channel = 0);
113
114/**
115 * @brief Removes a node from the root node of specified channels
116 * @param node Node to remove
117 * @param channels Vector of channel indices
118 *
119 * Removes the node from being a child of the root node for the specified channels.
120 * Uses the default engine's node graph manager.
121 */
122MAYAFLUX_API void unregister_node(
123 const std::shared_ptr<Nodes::Node>& node,
124 const Nodes::ProcessingToken& token,
125 uint32_t channel = 0);
126
127/**
128 * @brief Removes a node from the root node from list of channels
129 * @param node Node to remove
130 * @param channels Channel indices
131 *
132 * Removes the node from being a child of the root node for the list of channels
133 * Uses the default engine's node graph manager.
134 */
135MAYAFLUX_API void unregister_audio_node(const std::shared_ptr<Nodes::Node>& node, const std::vector<uint32_t>& channels);
136
137/**
138 * @brief Gets the root node for a specific channel
139 * @param channel Channel index
140 * @return The root node for the specified channel
141 *
142 * The root node is the top-level node in the processing hierarchy for a channel.
143 * Uses the default engine's node graph manager.
144 */
145MAYAFLUX_API Nodes::RootNode& get_audio_channel_root(uint32_t channel = 0);
146
147template <typename NodeType, typename... Args>
148 requires std::derived_from<NodeType, Nodes::Node>
149auto create_node(Args&&... args) -> std::shared_ptr<NodeType>
150{
151 auto node = std::make_shared<NodeType>(std::forward<Args>(args)...);
153 return node;
154}
155
156//-------------------------------------------------------------------------
157// Node Network Management
158//-------------------------------------------------------------------------
159
160/**
161 * @brief Registers a node network with the default engine's node graph manager
162 * @param network NodeNetwork to register
163 *
164 * Adds the node network to the default engine's node graph manager.
165 * The network can then be used to manage nodes and their connections.
166 */
167MAYAFLUX_API void register_node_network(const std::shared_ptr<Nodes::Network::NodeNetwork>& network, const Nodes::ProcessingToken& token = Nodes::ProcessingToken::AUDIO_RATE);
168
169/**
170 * @brief Unregisters a node network from the default engine's node graph manager
171 * @param network NodeNetwork to unregister
172 *
173 * Removes the node network from the default engine's node graph manager.
174 * The network will no longer be available for managing nodes and their connections.
175 */
176MAYAFLUX_API void unregister_node_network(const std::shared_ptr<Nodes::Network::NodeNetwork>& network, const Nodes::ProcessingToken& token = Nodes::ProcessingToken::AUDIO_RATE);
177
178/**
179 * @breif Moves the network from its current channel(s) to the specified channel(s) with an optional fade time
180 * @param network NodeNetwork to route
181 * @param channels Vector of channel indices to route the network to
182 * @param seconds_to_fade Time in seconds to fade the routing (optional, default is 1 second)
183 * @param token Processing domain to route within (default is AUDIO_RATE)
184 *
185 * This method adds the specified network to the target channels
186 * within the given processing domain. If seconds_to_fade is greater than 0, the routing
187 * will be smoothly faded in over that time period.
188 */
189MAYAFLUX_API void route_network(
190 const std::shared_ptr<Nodes::Network::NodeNetwork>& network,
191 const std::vector<uint32_t>& channels,
192 double seconds_to_fade = 1.F,
194
195/**
196 * @breif Moves the node from its current channel(s) to the specified channel(s) with an optional fade time
197 * @param network NodeNetwork to route
198 * @param channels Vector of channel indices to route the node to
199 * @param num_samples Number of samples to fade the routing over (optional, default is 48000 samples for 1 second at 48kHz)
200 * @param token Processing domain to route within (default is AUDIO_RATE)
201 *
202 * This method adds the specified network to the target channels
203 * within the given processing domain. If num_samples is greater than 0, the routing
204 * will be smoothly faded in over that many samples.
205 */
206MAYAFLUX_API void route_network(
207 const std::shared_ptr<Nodes::Network::NodeNetwork>& network,
208 const std::vector<uint32_t>& channels,
209 uint32_t num_samples,
211
212/**
213 * @brief Creates a new node network
214 * @return Shared pointer to the created NodeNetwork
215 *
216 * This function creates a new node network that can be used to manage
217 * complex node graphs with multiple channels and processing domains.
218 */
219
220template <typename NodeNetworkType, typename... Args>
221 requires std::derived_from<NodeNetworkType, Nodes::Network::NodeNetwork>
222auto create_node_network(Args&&... args) -> std::shared_ptr<NodeNetworkType>
223{
224 auto network = std::make_shared<NodeNetworkType>(std::forward<Args>(args)...);
225 register_node_network(network);
226 return network;
227}
228
229//-------------------------------------------------------------------------
230// Buffer Management
231//-------------------------------------------------------------------------
232
233/**
234 * @brief Gets the buffer manager from the default engine
235 * @return Shared pointer to the centrally managed BufferManager
236 *
237 * Returns the buffer manager that's managed by the default engine instance.
238 * All buffer operations using the convenience functions will use this manager.
239 */
240MAYAFLUX_API std::shared_ptr<Buffers::BufferManager> get_buffer_manager();
241
242/**
243 * @brief Adds a processor to a specific buffer
244 * @param processor Processor to add
245 * @param buffer Buffer to add the processor to
246 *
247 * Adds the processor to the specified buffer's processing chain.
248 * Uses the default engine's buffer manager.
249 */
250MAYAFLUX_API void add_processor(const std::shared_ptr<Buffers::BufferProcessor>& processor, const std::shared_ptr<Buffers::Buffer>& buffer, Buffers::ProcessingToken token = Buffers::ProcessingToken::AUDIO_BACKEND);
251
252/**
253 * @brief Adds a processor to all buffers in a specific channel
254 * @param processor Processor to add
255 * @param token Processing domain
256 * @param channel Channel index
257 *
258 * Adds the processor to all buffers associated with the specified channel
259 * in the given processing domain.
260 * Uses the default engine's buffer manager.
261 */
262MAYAFLUX_API void add_processor(const std::shared_ptr<Buffers::BufferProcessor>& processor, Buffers::ProcessingToken token, uint32_t channel);
263
264/**
265 * @brief Adds a processor to all buffers in a processing domain
266 * @param processor Processor to add
267 * @param token Processing domain
268 *
269 * Adds the processor to all buffers associated with the given processing domain.
270 * Uses the default engine's buffer manager.
271 */
272MAYAFLUX_API void add_processor(const std::shared_ptr<Buffers::BufferProcessor>& processor, Buffers::ProcessingToken token = Buffers::ProcessingToken::AUDIO_BACKEND);
273
274/**
275 * @brief Registers an AudioBuffer with the default engine's buffer manager
276 * @param buffer AudioBuffer to register
277 * @param channel Channel index to associate with the buffer (default: 0)
278 *
279 * Adds the buffer to the default engine's buffer management system, enabling
280 * it to participate in the audio processing pipeline. The buffer will be
281 * processed during each audio cycle according to its configuration.
282 * Multiple buffers can be registered to the same channel for layered processing.
283 */
284MAYAFLUX_API void register_audio_buffer(const std::shared_ptr<Buffers::AudioBuffer>& buffer, uint32_t channel = 0);
285
286/**
287 * @brief Unregisters an AudioBuffer from the default engine's buffer manager
288 * @param buffer AudioBuffer to unregister
289 * @param channel Channel index the buffer was associated with (default: 0)
290 *
291 * Removes the buffer from the default engine's buffer management system.
292 * The buffer will no longer participate in audio processing cycles.
293 * This is essential for clean shutdown and preventing processing of
294 * destroyed or invalid buffers.
295 */
296MAYAFLUX_API void unregister_audio_buffer(const std::shared_ptr<Buffers::AudioBuffer>& buffer, uint32_t channel = 0);
297
298/**
299 * @brief creates a new buffer of the specified type and registers it
300 * @tparam BufferType Type of buffer to create (must be derived from AudioBuffer)
301 * @tparam Args Constructor argument types
302 * @param channel Channel index to create the buffer for
303 * @param buffer_size Size of the buffer in processing units
304 */
305template <typename BufferType, typename... Args>
306 requires std::derived_from<BufferType, Buffers::AudioBuffer>
307auto create_buffer(uint32_t channel, uint32_t buffer_size, Args&&... args) -> std::shared_ptr<BufferType>
308{
309 auto buffer = std::make_shared<BufferType>(channel, buffer_size, std::forward<Args>(args)...);
310 register_audio_buffer(buffer, channel);
311 return buffer;
312}
313
314/**
315 * @brief Registers a VKBuffer with the default engine's buffer manager
316 * @param buffer VKBuffer to register
317 *
318 * Adds the buffer to the default engine's buffer management system, enabling
319 * it to participate in the graphics processing pipeline.
320 */
321MAYAFLUX_API void register_graphics_buffer(const std::shared_ptr<Buffers::VKBuffer>& buffer, Buffers::ProcessingToken token = Buffers::ProcessingToken::GRAPHICS_BACKEND);
322
323/**
324 * @brief Unregisters a VKBuffer from the default engine's buffer manager
325 * @param buffer VKBuffer to unregister
326 *
327 * Removes the buffer from the default engine's buffer management system.
328 * The buffer will no longer participate in graphics processing cycles.
329 */
330MAYAFLUX_API void unregister_graphics_buffer(const std::shared_ptr<Buffers::VKBuffer>& buffer);
331
332/**
333 * @brief creates a new graphics buffer of the specified type and registers it
334 * @tparam BufferType Type of buffer to create (must be derived from VKBuffer)
335 * @tparam Args Constructor argument types
336 * @param args Constructor arguments for the buffer
337 * @return Shared pointer to the created buffer
338 */
339template <typename BufferType, typename... Args>
340 requires std::derived_from<BufferType, Buffers::VKBuffer>
341auto create_buffer(Args&&... args) -> std::shared_ptr<BufferType>
342{
343 auto buffer = std::make_shared<BufferType>(std::forward<Args>(args)...);
345 return buffer;
346}
347
348/**
349 * @brief Creates a new processor and adds it to a buffer
350 * @tparam ProcessorType Type of processor to create (must be derived from BufferProcessor)
351 * @tparam Args Constructor argument types
352 * @param buffer Buffer to add the processor to
353 * @param args Constructor arguments for the processor
354 * @return Shared pointer to the created processor
355 *
356 * This function creates a new processor of the specified type, initializes it with the provided arguments,
357 * and adds it to the specified buffer's processing chain.
358 */
359template <typename ProcessorType, typename... Args>
360 requires std::derived_from<ProcessorType, Buffers::BufferProcessor>
361auto create_processor(const std::shared_ptr<Buffers::AudioBuffer> buffer, Args&&... args) -> std::shared_ptr<ProcessorType>
362{
363 auto processor = std::make_shared<ProcessorType>(std::forward<Args>(args)...);
364 add_processor(processor, buffer);
365 return processor;
366}
367
368template <typename ProcessorType, typename... Args>
369 requires std::derived_from<ProcessorType, Buffers::BufferProcessor>
370auto create_processor(const std::shared_ptr<Buffers::VKBuffer> buffer, Args&&... args) -> std::shared_ptr<ProcessorType>
371{
372 auto processor = std::make_shared<ProcessorType>(std::forward<Args>(args)...);
374 return processor;
375}
376
377/**
378 * @brief Creates a new processing chain for the default engine
379 * @return Shared pointer to the created BufferProcessingChain
380 *
381 * This function creates a new processing chain that can be used to manage
382 * audio processing for buffers. The chain can be customized with various
383 * processors and is managed by the default engine's buffer manager.
384 */
385MAYAFLUX_API std::shared_ptr<Buffers::BufferProcessingChain> create_processing_chain();
386
387/**
388 * @brief Gets the audio buffer for a specific channel
389 * @param channel Channel index
390 * @return Reference to the channel's AudioBuffer
391 *
392 * Returns the buffer from the default engine's buffer manager.
393 */
394MAYAFLUX_API Buffers::RootAudioBuffer& get_root_audio_buffer(uint32_t channel);
395
396/**
397 * @brief Connects a node to a specific output channel
398 * @param node Node to connect
399 * @param channel_index Channel index to connect to
400 * @param mix Mix level (0.0 to 1.0) for blending node output with existing channel content
401 * @param clear_before Whether to clear the channel buffer before adding node output
402 *
403 * Uses the default engine's buffer manager and node graph manager.
404 */
405MAYAFLUX_API void connect_node_to_channel(const std::shared_ptr<Nodes::Node>& node, uint32_t channel_index = 0, float mix = 0.5F, bool clear_before = false);
406
407/**
408 * @brief Connects a node to a specific buffer
409 * @param node Node to connect
410 * @param buffer Buffer to connect to
411 * @param mix Mix level (0.0 to 1.0) for blending node output with existing buffer content
412 * @param clear_before Whether to clear the buffer before adding node output
413 *
414 * Uses the default engine's node graph manager.
415 */
416MAYAFLUX_API void connect_node_to_buffer(const std::shared_ptr<Nodes::Node>& node, const std::shared_ptr<Buffers::AudioBuffer>& buffer, float mix = 0.5F, bool clear_before = true);
417
418//-------------------------------------------------------------------------
419// Audio Processing
420//-------------------------------------------------------------------------
421
422/**
423 * @brief Attaches a processing function to a specific channel
424 * @param processor Function to process the buffer
425 * @param channel_id Channel index to process
426 *
427 * The processor will be called during the default engine's audio processing cycle
428 * and will operate on the specified output channel buffer.
429 */
430MAYAFLUX_API std::shared_ptr<Buffers::BufferProcessor> attach_quick_process(Buffers::AudioProcessingFunction processor, unsigned int channel_id = 0);
431
432// Template overloads for auto lambdas
433template <typename F>
434std::shared_ptr<Buffers::BufferProcessor> attach_quick_process(
435 F&& processor,
436 const std::shared_ptr<Buffers::AudioBuffer>& buffer)
437{
439 Buffers::AudioProcessingFunction { std::forward<F>(processor) },
440 buffer);
441}
442
443template <typename F>
444std::shared_ptr<Buffers::BufferProcessor> attach_quick_process(
445 F&& processor,
446 const std::shared_ptr<Buffers::VKBuffer>& buffer)
447{
449 Buffers::GraphicsProcessingFunction { std::forward<F>(processor) },
450 buffer);
451}
452
453/**
454 * @brief Reads audio data from the default input source into a buffer
455 * @param buffer Buffer to read audio data into
456 * @param channel Channel index to read from (default: 0)
457 *
458 * Reads audio data from the default input source (e.g., microphone)
459 * and fills the provided AudioBuffer with the captured audio samples.
460 * This function is typically used to capture live audio input for processing.
461 */
462MAYAFLUX_API void read_from_audio_input(const std::shared_ptr<Buffers::AudioBuffer>& buffer, uint32_t channel = 0);
463
464/**
465 * @brief Stops reading audio data from the default input source
466 * @param buffer Buffer to stop reading audio data from
467 * @param channel Channel index to stop reading from (default: 0)
468 */
469MAYAFLUX_API void detach_from_audio_input(const std::shared_ptr<Buffers::AudioBuffer>& buffer, uint32_t channel = 0);
470
471/**
472 * @brief Creates a new AudioBuffer for input listening
473 * @param channel Channel index to create the buffer for (default: 0)
474 * @param add_to_output Whether to add this buffer to the output channel (default: false)
475 * @return Shared pointer to the created AudioBuffer
476 *
477 * This function creates a new AudioBuffer that can be used to listen to audio input.
478 * If `add_to_output` is true, the buffer will be automatically added to the output channel
479 * for processing.
480 */
481MAYAFLUX_API std::shared_ptr<Buffers::AudioBuffer> create_input_listener_buffer(uint32_t channel = 0, bool add_to_output = false);
482
483/**
484 * @brief Clones a buffer to multiple channels
485 * @param buffer Buffer to clone
486 * @param channels Vector of channel indices to clone to
487 *
488 * Creates independent copies of the buffer for each specified channel.
489 * Each clone maintains the same data, processors, and processing chain,
490 * but operates independently on its assigned channel.
491 * Uses the default engine's buffer manager.
492 */
493MAYAFLUX_API std::vector<std::shared_ptr<Buffers::AudioBuffer>> clone_buffer_to_channels(const std::shared_ptr<Buffers::AudioBuffer>& buffer,
494 const std::vector<uint32_t>& channels);
495
496MAYAFLUX_API std::vector<std::shared_ptr<Buffers::AudioBuffer>> clone_buffer_to_channels(
497 const std::shared_ptr<Buffers::AudioBuffer>& buffer,
498 const std::vector<uint32_t>& channels,
499 const Buffers::ProcessingToken& token);
500/**
501 * @brief Supplies a buffer to a single channel with mixing
502 * @param buffer Source buffer to supply
503 * @param channel Target channel index
504 * @param mix Mix level (default: 1.0)
505 *
506 * Convenience wrapper for single-channel buffer supply operations.
507 */
508MAYAFLUX_API void supply_buffer_to_channel(const std::shared_ptr<Buffers::AudioBuffer>& buffer,
509 uint32_t channel,
510 double mix = 1.0);
511
512/**
513 * @brief Supplies a buffer to multiple channels with mixing
514 * @param buffer Source buffer to supply
515 * @param channels Vector of channel indices to supply to
516 * @param mix Mix level for each channel (default: 1.0)
517 *
518 * Efficiently routes a single buffer's output to multiple channels using
519 * the MixProcessor system. This is ideal for sending the same signal to
520 * multiple outputs without duplicating processing.
521 */
522MAYAFLUX_API void supply_buffer_to_channels(const std::shared_ptr<Buffers::AudioBuffer>& buffer,
523 const std::vector<uint32_t>& channels,
524 double mix = 1.0);
525
526/**
527 * @brief Removes a supplied buffer from multiple channels
528 * @param buffer Buffer to remove from supply chains
529 * @param channels channel index to remove from
530 *
531 * Efficiently removes a buffer from channel mix processor.
532 */
533MAYAFLUX_API void remove_supplied_buffer_from_channel(const std::shared_ptr<Buffers::AudioBuffer>& buffer,
534 const uint32_t channel);
535
536/**
537 * @brief Removes a supplied buffer from multiple channels
538 * @param buffer Buffer to remove from supply chains
539 * @param channels Vector of channel indices to remove from
540 *
541 * Efficiently removes a buffer from multiple channel mix processors.
542 */
543MAYAFLUX_API void remove_supplied_buffer_from_channels(const std::shared_ptr<Buffers::AudioBuffer>& buffer,
544 const std::vector<uint32_t>& channels);
545
546/**
547 * @brief Routes a buffer from its current channel to a target channel with fade
548 * @param buffer Buffer to route
549 * @param target_channel Destination channel
550 * @param seconds_to_fade Crossfade duration in seconds
551 * @param token Processing domain
552 */
553MAYAFLUX_API void route_buffer(
554 const std::shared_ptr<Buffers::AudioBuffer>& buffer,
555 uint32_t target_channel,
556 double seconds_to_fade = 1.0,
558
559/**
560 * @brief Routes a buffer from its current channel to a target channel with fade
561 * @param buffer Buffer to route
562 * @param target_channel Destination channel
563 * @param num_blocks Crossfade duration in processing blocks
564 * @param token Processing domain
565 *
566 * NOTE: num_blocks is in processing blocks, not samples. The actual time duration will depend on the block size and sample rate.
567 */
568MAYAFLUX_API void route_buffer(
569 const std::shared_ptr<Buffers::AudioBuffer>& buffer,
570 uint32_t target_channel,
571 uint32_t num_blocks,
573
574/**
575 * @brief Connects two nodes in series (pipeline operator)
576 * @param lhs Source node (may already be a ChainNode)
577 * @param rhs Target node (may already be a ChainNode)
578 * @return A ChainNode containing the flattened sequence
579 *
580 * If lhs is already a ChainNode, rhs is appended to its sequence
581 * rather than creating a nested chain.
582 *
583 * Uses the default engine's NodeGraphManager for registration.
584 * For manual construction without registration, create ChainNode directly
585 * with no manager argument.
586 *
587 * ```cpp
588 * auto chain = generator >> transformer >> output;
589 * ```
590 */
591MAYAFLUX_API std::shared_ptr<Nodes::Node> operator>>(const std::shared_ptr<Nodes::Node>& lhs, const std::shared_ptr<Nodes::Node>& rhs);
592
593/**
594 * @brief Combines two nodes in parallel (addition)
595 * @param lhs First node
596 * @param rhs Second node
597 * @return A BinaryOpNode that sums both outputs
598 *
599 * Creates a new node that processes both input nodes and sums their outputs.
600 * This allows for mixing multiple data sources or transformations:
601 *
602 * ```cpp
603 * auto combined = primary_source + secondary_source;
604 * ```
605 *
606 * The resulting node takes an input, passes it to both source nodes,
607 * and returns the sum of their outputs.
608 */
609MAYAFLUX_API std::shared_ptr<Nodes::Node> operator+(const std::shared_ptr<Nodes::Node>& lhs, const std::shared_ptr<Nodes::Node>& rhs);
610
611/**
612 * @brief Combines two nodes in parallel (multiplication)
613 * @param lhs First node
614 * @param rhs Second node
615 * @return A BinaryOpNode that multiplies both outputs
616 *
617 * Creates a new node that processes both input nodes and multiplies their outputs.
618 * This is useful for amplitude modulation, scaling operations, and other
619 * multiplicative transformations:
620 *
621 * ```cpp
622 * auto modulated = carrier * modulator;
623 * ```
624 *
625 * The resulting node takes an input, passes it to both source nodes,
626 * and returns the product of their outputs.
627 */
628MAYAFLUX_API std::shared_ptr<Nodes::Node> operator*(const std::shared_ptr<Nodes::Node>& lhs, const std::shared_ptr<Nodes::Node>& rhs);
629
630}
Abstract base class for structured collections of nodes with defined relationships.
std::function< void(const std::shared_ptr< AudioBuffer > &)> AudioProcessingFunction
Audio processing function - receives correctly-typed AudioBuffer.
ProcessingToken
Bitfield enum defining processing characteristics and backend requirements for buffer operations.
@ AUDIO_BACKEND
Standard audio processing backend configuration.
@ GRAPHICS_BACKEND
Standard graphics processing backend configuration.
std::function< void(const std::shared_ptr< VKBuffer > &)> GraphicsProcessingFunction
Graphics processing function - receives correctly-typed VKBuffer.
@ Nodes
DSP Generator and Filter Nodes, graph pipeline, node management.
ProcessingToken
Enumerates the different processing domains for nodes.
@ AUDIO_RATE
Nodes that process at the audio sample rate.
std::shared_ptr< Buffers::BufferProcessor > attach_quick_process_audio(Buffers::AudioProcessingFunction processor, const std::shared_ptr< Buffers::AudioBuffer > &buffer)
Definition Graph.cpp:20
std::shared_ptr< Buffers::BufferProcessor > attach_quick_process_graphics(Buffers::GraphicsProcessingFunction processor, const std::shared_ptr< Buffers::VKBuffer > &buffer)
Definition Graph.cpp:25
void connect_node_to_buffer(const std::shared_ptr< Nodes::Node > &node, const std::shared_ptr< Buffers::AudioBuffer > &buffer, float mix, bool clear_before)
Connects a node to a specific buffer.
Definition Graph.cpp:169
std::shared_ptr< Nodes::Node > operator*(const std::shared_ptr< Nodes::Node > &lhs, const std::shared_ptr< Nodes::Node > &rhs)
Combines two nodes in parallel (multiplication)
Definition Graph.cpp:371
std::shared_ptr< Buffers::AudioBuffer > create_input_listener_buffer(uint32_t channel, bool add_to_output)
Creates a new AudioBuffer for input listening.
Definition Graph.cpp:245
void register_node(const std::shared_ptr< Nodes::Node > &node, const Nodes::ProcessingToken &token, uint32_t channel)
Definition Graph.cpp:124
std::shared_ptr< Buffers::BufferProcessingChain > create_processing_chain()
Creates a new processing chain for the default engine.
Definition Graph.cpp:153
void unregister_node(const std::shared_ptr< Nodes::Node > &node, const Nodes::ProcessingToken &token, uint32_t channel)
Removes a node from the root node of specified channels.
Definition Graph.cpp:85
auto create_processor(const std::shared_ptr< Buffers::AudioBuffer > buffer, Args &&... args) -> std::shared_ptr< ProcessorType >
Creates a new processor and adds it to a buffer.
Definition Graph.hpp:361
void unregister_graphics_buffer(const std::shared_ptr< Buffers::VKBuffer > &buffer)
Unregisters a VKBuffer from the default engine's buffer manager.
Definition Graph.cpp:230
void add_processor(const std::shared_ptr< Buffers::BufferProcessor > &processor, const std::shared_ptr< Buffers::Buffer > &buffer, Buffers::ProcessingToken token)
Adds a processor to a specific buffer.
Definition Graph.cpp:138
void route_node(const std::shared_ptr< Nodes::Node > &node, const std::vector< uint32_t > &channels, uint32_t num_samples, const Nodes::ProcessingToken &token)
@breif Moves the node from its current channel(s) to the specified channel(s) with an optional fade t...
Definition Graph.cpp:101
std::shared_ptr< Nodes::NodeGraphManager > get_node_graph_manager()
Gets the node graph manager from the default engine.
Definition Graph.cpp:35
std::shared_ptr< Buffers::BufferProcessor > attach_quick_process(Buffers::AudioProcessingFunction processor, unsigned int channel_id)
Attaches a processing function to a specific channel.
Definition Graph.cpp:210
std::shared_ptr< Nodes::Node > operator>>(const std::shared_ptr< Nodes::Node > &lhs, const std::shared_ptr< Nodes::Node > &rhs)
Connects two nodes in series (pipeline operator)
Definition Graph.cpp:328
Buffers::RootAudioBuffer & get_root_audio_buffer(uint32_t channel)
Gets the audio buffer for a specific channel.
Definition Graph.cpp:158
auto create_node_network(Args &&... args) -> std::shared_ptr< NodeNetworkType >
Creates a new node network.
Definition Graph.hpp:222
void register_node_network(const std::shared_ptr< Nodes::Network::NodeNetwork > &network, const Nodes::ProcessingToken &token)
Registers a node network with the default engine's node graph manager.
Definition Graph.cpp:178
std::shared_ptr< Nodes::Node > operator+(const std::shared_ptr< Nodes::Node > &lhs, const std::shared_ptr< Nodes::Node > &rhs)
Combines two nodes in parallel (addition)
Definition Graph.cpp:362
void remove_supplied_buffer_from_channels(const std::shared_ptr< Buffers::AudioBuffer > &buffer, const std::vector< uint32_t > &channels)
Removes a supplied buffer from multiple channels.
Definition Graph.cpp:301
std::vector< std::shared_ptr< Buffers::AudioBuffer > > clone_buffer_to_channels(const std::shared_ptr< Buffers::AudioBuffer > &buffer, const std::vector< uint32_t > &channels)
Clones a buffer to multiple channels.
Definition Graph.cpp:257
void unregister_audio_buffer(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t channel)
Unregisters an AudioBuffer from the default engine's buffer manager.
Definition Graph.cpp:220
void supply_buffer_to_channels(const std::shared_ptr< Buffers::AudioBuffer > &buffer, const std::vector< uint32_t > &channels, double mix)
Supplies a buffer to multiple channels with mixing.
Definition Graph.cpp:282
void supply_buffer_to_channel(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t channel, double mix)
Supplies a buffer to a single channel with mixing.
Definition Graph.cpp:268
void route_buffer(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t target_channel, double seconds_to_fade, const Buffers::ProcessingToken &token)
Routes a buffer from its current channel to a target channel with fade.
Definition Graph.cpp:309
void register_audio_buffer(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t channel)
Registers an AudioBuffer with the default engine's buffer manager.
Definition Graph.cpp:215
void detach_from_audio_input(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t channel)
Stops reading audio data from the default input source.
Definition Graph.cpp:240
void route_network(const std::shared_ptr< Nodes::Network::NodeNetwork > &network, const std::vector< uint32_t > &channels, uint32_t num_samples, const Nodes::ProcessingToken &token)
@breif Moves the node from its current channel(s) to the specified channel(s) with an optional fade t...
Definition Graph.cpp:188
void register_audio_node(const std::shared_ptr< Nodes::Node > &node, uint32_t channel)
Adds a node to the root node of a specific channel.
Definition Graph.cpp:40
void unregister_node_network(const std::shared_ptr< Nodes::Network::NodeNetwork > &network, const Nodes::ProcessingToken &token)
Unregisters a node network from the default engine's node graph manager.
Definition Graph.cpp:183
void unregister_audio_node(const std::shared_ptr< Nodes::Node > &node, uint32_t channel)
Removes a node from the root node of a specific channel.
Definition Graph.cpp:62
auto create_node(Args &&... args) -> std::shared_ptr< NodeType >
Definition Graph.hpp:149
std::shared_ptr< Buffers::BufferManager > get_buffer_manager()
Gets the buffer manager from the default engine.
Definition Graph.cpp:133
void register_graphics_buffer(const std::shared_ptr< Buffers::VKBuffer > &buffer, Buffers::ProcessingToken token)
Registers a VKBuffer with the default engine's buffer manager.
Definition Graph.cpp:225
auto create_buffer(uint32_t channel, uint32_t buffer_size, Args &&... args) -> std::shared_ptr< BufferType >
creates a new buffer of the specified type and registers it
Definition Graph.hpp:307
Nodes::RootNode & get_audio_channel_root(uint32_t channel)
Gets the root node for a specific channel.
Definition Graph.cpp:119
std::vector< double > mix(const std::vector< std::vector< double > > &streams)
Mix multiple data streams with equal weighting.
Definition Yantra.cpp:1021
void read_from_audio_input(const std::shared_ptr< Buffers::AudioBuffer > &buffer, uint32_t channel)
Reads audio data from the default input source into a buffer.
Definition Graph.cpp:235
void connect_node_to_channel(const std::shared_ptr< Nodes::Node > &node, uint32_t channel_index, float mix, bool clear_before)
Connects a node to a specific output channel.
Definition Graph.cpp:163
void remove_supplied_buffer_from_channel(const std::shared_ptr< Buffers::AudioBuffer > &buffer, const uint32_t channel)
Removes a supplied buffer from multiple channels.
Definition Graph.cpp:291
Main namespace for the Maya Flux audio engine.
Definition LiveAid.hpp:6