MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
BufferInputControl.hpp
Go to the documentation of this file.
1#pragma once
2
3namespace MayaFlux::Buffers {
4
5class AudioBuffer;
6class InputAudioBuffer;
7
8/**
9 * @class BufferInputControl
10 * @brief Audio input buffer management and listener coordination
11 *
12 * Manages all operations related to audio input handling: input buffer creation,
13 * input data processing, and listener registration/unregistration.
14 *
15 * Design Principles:
16 * - Owns input buffers: Manages the lifecycle of input buffer storage
17 * - Listener coordination: Handles registration/unregistration of buffers listening to input
18 * - Single responsibility: Only handles input-specific operations
19 * - Extensible: Can be extended to handle other input types (MIDI, video capture, etc.)
20 *
21 * This class encapsulates all input-related logic that was previously scattered
22 * throughout BufferManager.
23 */
24class MAYAFLUX_API BufferInputControl {
25public:
26 /**
27 * @brief Creates a new input control handler
28 */
29 BufferInputControl() = default;
30
32
33 // =========================================================================
34 // Input Buffer Lifecycle
35 // =========================================================================
36
37 /**
38 * @brief Sets up audio input buffers
39 * @param num_channels Number of input channels to create
40 * @param buffer_size Size of each input buffer in samples
41 *
42 * Creates and initializes input buffers for each channel. This is typically
43 * called during BufferManager initialization or when input channels change.
44 */
45 void setup_audio_input_buffers(uint32_t num_channels, uint32_t buffer_size);
46
47 /**
48 * @brief Gets the number of audio input channels
49 * @return Number of input channels, or 0 if not set up
50 */
51 uint32_t get_audio_input_channel_count() const;
52
53 /**
54 * @brief Gets the buffer size for audio input buffers
55 * @return Buffer size in samples, or 0 if not set up
56 */
57 [[nodiscard]] std::shared_ptr<InputAudioBuffer> get_input_buffer(uint32_t channel) const;
58
59 // =========================================================================
60 // Input Data Processing
61 // =========================================================================
62
63 /**
64 * @brief Processes incoming audio input data into input buffers
65 * @param input_data Pointer to interleaved input data
66 * @param num_channels Number of channels in the input data
67 * @param num_frames Number of frames to process
68 *
69 * Takes interleaved input data and distributes it to the appropriate
70 * input buffers, then triggers default processing on each.
71 */
72 void process_audio_input(double* input_data, uint32_t num_channels, uint32_t num_frames);
73
74 // =========================================================================
75 // Listener Management
76 // =========================================================================
77
78 /**
79 * @brief Registers a buffer as a listener to an input channel
80 * @param buffer Buffer to register as listener
81 * @param channel Input channel to listen to
82 *
83 * The buffer will receive copies of input data from the specified channel
84 * whenever process_audio_input() is called.
85 */
86 void register_audio_input_listener(const std::shared_ptr<AudioBuffer>& buffer, uint32_t channel);
87
88 /**
89 * @brief Unregisters a buffer from an input channel
90 * @param buffer Buffer to unregister
91 * @param channel Input channel to stop listening to
92 */
93 void unregister_audio_input_listener(const std::shared_ptr<AudioBuffer>& buffer, uint32_t channel);
94
95private:
96 /// Input buffers for capturing audio input data
97 std::vector<std::shared_ptr<InputAudioBuffer>> m_audio_input_buffers;
98};
99
100} // namespace MayaFlux::Buffers
BufferInputControl()=default
Creates a new input control handler.
std::vector< std::shared_ptr< InputAudioBuffer > > m_audio_input_buffers
Input buffers for capturing audio input data.
Audio input buffer management and listener coordination.