Appearance
modules.audio.streaming.utils
Classes Diagram
Classes
MultiChannelQueue
MultiChannelQueue for synchronizing data across channels.
Methods of this class are thread safe.
Constructor
MultiChannelQueue(self, num_channels: int = None)
Members
_ready
num_channels
_channel_queues
Methods
set_channels_count(self, num_channels: int)
Configure the number of channels for the queue.
Args:
num_channels (int): Number of audio/data channels to manage.
put(self, channel_id: int, data)
Insert data into the specified channel queue.
When all channel queues contain at least one item,
a complete frame is assembled and added to the ready queue.
Args:
channel_id (int): Index of the channel.
data: Data sample to insert.
get(self, block: bool = True, timeout: int = None)
Retrieve the next completed multi-channel frame.
Args:
block (bool, optional): Whether to block until a frame is available. Defaults to True.
timeout (int, optional): Timeout in seconds when blocking. Defaults to None.
Returns:
list: A list containing one data sample per channel.
clear(self)
Clear all channel queues and the ready queue.
Thread-safe.
has_data(self)
Functions
bytes_to_audio(raw_bytes)
Convert float 32 LE raw bytes to a normalized NumPy float32 array.
Args:
raw_bytes (bytes): Raw 32 LE float audio data.
Returns:
np.ndarray: 1D array of float32 samples in range [-1.0, 1.0].