Constructs an instance of the RxAudio class.
Configuration options for the audio handler.
Asynchronous queue for processed audio data chunks. Each chunk is an Int8Array or Int16Array, or null to signal the end of a stream/clip.
Attaches this RxAudio instance to a FrameMsg object to receive audio data. It initializes the audio queue and registers a handler for incoming data.
The FrameMsg instance to attach to.
A Promise that resolves to the AsyncQueue where audio chunks will be placed.
Detaches this RxAudio instance from a FrameMsg object. It unregisters the data handler and clears the audio queue.
The FrameMsg instance to detach from.
Handles incoming raw audio data chunks.
This method is typically called by a FrameMsg instance when new audio data is received.
It processes the data based on the configured mode (streaming or clip) and bit depth,
then places the processed audio chunk (Int8Array or Int16Array) onto the queue.
A null is placed on the queue to signal the end of a stream or clip.
A Uint8Array containing the raw audio data, prefixed with a msgCode byte.
Staticpcm16Converts signed 16-bit PCM data (provided as a Uint8Array) to a Float32Array. The samples are scaled to the range [-1.0, 1.0]. Note: Assumes input Uint8Array contains little-endian signed 16-bit samples. Samples are scaled by 1/16384 (instead of 1/32768) and clamped to [-1.0, 1.0] to account for typical microphone dynamic range usage.
The Uint8Array containing signed 16-bit PCM data (little-endian).
A Float32Array with samples scaled to [-1.0, 1.0].
Staticpcm8Converts signed 8-bit PCM data (provided as a Uint8Array) to a Float32Array. The samples are scaled to the range [-1.0, 1.0]. Note: Assumes input samples are signed bytes. Reinterprets Uint8Array as Int8Array. Samples are scaled by 1/64 (instead of 1/128) and clamped to [-1.0, 1.0] to account for typical microphone dynamic range usage.
The Uint8Array containing signed 8-bit PCM data.
A Float32Array with samples scaled to [-1.0, 1.0].
StatictoConverts raw PCM audio data to WAV file format (as a Uint8Array).
The raw PCM data. For 8-bit, assumes signed samples that will be converted to unsigned for WAV.
The sample rate of the audio (e.g., 8000 Hz). Defaults to 8000.
The number of bits per sample (e.g., 8 or 16). Defaults to 8.
The number of audio channels (e.g., 1 for mono). Defaults to 1.
A Uint8Array containing the WAV file data.
RxAudio class handles audio data streaming and processing. It can operate in two modes: streaming and single-clip mode. In streaming mode, it processes audio data in real-time. In single-clip mode, it accumulates audio data until a final chunk is received. The class provides methods to attach and detach from a FrameMsg instance, and to convert PCM data to WAV format. Depending on how it is constructed, it will return samples as either signed 8 or signed 16 bit integers, and the source bit depth in Lua should match.