MayaFlux 0.1.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches
InputAudioBuffer.hpp
Go to the documentation of this file.
1#pragma once
4
5namespace MayaFlux::Buffers {
6
7/**
8 * @class InputAudioBuffer
9 * @brief Specialized buffer for audio input with listener dispatch
10 *
11 * Simple, focused input buffer that:
12 * - Receives input data from audio interface
13 * - Dispatches data to registered listener buffers
14 * - Maintains clean, stable operation without complex features
15 */
16class MAYAFLUX_API InputAudioBuffer : public AudioBuffer {
17public:
18 /**
19 * @brief Constructor - only BufferManager can create
20 * @param channel_id Channel identifier
21 * @param num_samples Buffer size
22 */
23 InputAudioBuffer(uint32_t channel_id, uint32_t num_samples);
24
25 /**
26 * @brief Deleted copy constructor - input buffers are unique resources
27 */
30
31 /**
32 * @brief Move constructor for resource management
33 */
36
37 ~InputAudioBuffer() = default;
38
39 /**
40 * @brief Writes buffer data to a specific listener buffer
41 * @param buffer Target buffer to write to
42 */
43 void write_to(std::shared_ptr<AudioBuffer> buffer);
44
45 /**
46 * @brief Registers a buffer as a listener of this input
47 * @param buffer Buffer to receive input data
48 */
49 void register_listener(std::shared_ptr<AudioBuffer> buffer);
50
51 /**
52 * @brief Unregisters a listener buffer
53 * @param buffer Buffer to unregister
54 */
55 void unregister_listener(std::shared_ptr<AudioBuffer> buffer);
56
57 /**
58 * @brief Gets all registered listeners
59 * @return Vector of listener buffers
60 */
61 const std::vector<std::shared_ptr<AudioBuffer>>& get_listeners() const;
62
63 /**
64 * @brief Clears all registered listeners
65 */
66 void clear_listeners();
67};
68
69/**
70 * @class InputAccessProcessor
71 * @brief Simple processor for dispatching input data to listeners
72 *
73 * Handles the distribution of input data to registered listener buffers.
74 * No complex features - just clean, stable dispatch.
75 */
76class MAYAFLUX_API InputAccessProcessor : public BufferProcessor {
77public:
78 /**
79 * @brief Main processing function - dispatches data to listeners
80 * @param buffer Input buffer to process
81 */
82 void processing_function(std::shared_ptr<Buffer> buffer) override;
83
84 /**
85 * @brief Called when processor is attached to a buffer
86 * @param buffer Buffer being attached to
87 */
88 void on_attach(std::shared_ptr<Buffer> buffer) override;
89
90 /**
91 * @brief Checks compatibility with buffer type
92 * @param buffer Buffer to check
93 * @return True if compatible with InputAudioBuffer
94 */
95 bool is_compatible_with(std::shared_ptr<Buffer> buffer) const override;
96
97 /**
98 * @brief Adds a listener buffer
99 * @param buffer Listener buffer
100 */
101 void add_listener(std::shared_ptr<AudioBuffer> buffer);
102
103 /**
104 * @brief Removes a listener buffer
105 * @param buffer Listener buffer to remove
106 */
107 void remove_listener(std::shared_ptr<AudioBuffer> buffer);
108
109 /**
110 * @brief Gets the number of registered listeners
111 * @return Number of listeners
112 */
113 size_t get_listener_count() const { return m_listeners.size(); }
114
115 inline void clear_listeners() { m_listeners.clear(); }
116
117private:
118 std::vector<std::shared_ptr<AudioBuffer>> m_listeners;
119};
120}
Concrete audio implementation of the Buffer interface for double-precision audio data.
Central computational transformation interface for continuous buffer processing.
size_t get_listener_count() const
Gets the number of registered listeners.
std::vector< std::shared_ptr< AudioBuffer > > m_listeners
Simple processor for dispatching input data to listeners.
InputAudioBuffer & operator=(const InputAudioBuffer &)=delete
InputAudioBuffer & operator=(InputAudioBuffer &&)=delete
InputAudioBuffer(const InputAudioBuffer &)=delete
Deleted copy constructor - input buffers are unique resources.
const std::vector< std::shared_ptr< AudioBuffer > > & get_listeners() const
Gets all registered listeners.
InputAudioBuffer(InputAudioBuffer &&)=delete
Move constructor for resource management.
Specialized buffer for audio input with listener dispatch.