MayaFlux 0.2.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 // Input Data Processing
55 // =========================================================================
56
57 /**
58 * @brief Processes incoming audio input data into input buffers
59 * @param input_data Pointer to interleaved input data
60 * @param num_channels Number of channels in the input data
61 * @param num_frames Number of frames to process
62 *
63 * Takes interleaved input data and distributes it to the appropriate
64 * input buffers, then triggers default processing on each.
65 */
66 void process_audio_input(double* input_data, uint32_t num_channels, uint32_t num_frames);
67
68 // =========================================================================
69 // Listener Management
70 // =========================================================================
71
72 /**
73 * @brief Registers a buffer as a listener to an input channel
74 * @param buffer Buffer to register as listener
75 * @param channel Input channel to listen to
76 *
77 * The buffer will receive copies of input data from the specified channel
78 * whenever process_audio_input() is called.
79 */
80 void register_audio_input_listener(const std::shared_ptr<AudioBuffer>& buffer, uint32_t channel);
81
82 /**
83 * @brief Unregisters a buffer from an input channel
84 * @param buffer Buffer to unregister
85 * @param channel Input channel to stop listening to
86 */
87 void unregister_audio_input_listener(const std::shared_ptr<AudioBuffer>& buffer, uint32_t channel);
88
89private:
90 /// Input buffers for capturing audio input data
91 std::vector<std::shared_ptr<InputAudioBuffer>> m_audio_input_buffers;
92};
93
94} // 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.