AudioDevice
class NatML.Devices.AudioDevice : IMediaDevice<AudioBuffer>
This class provides an abstraction for hardware microphones.
Identifying the Device
Audio devices can be identified either with a unique ID or with a device name.
Unique Identifier
Refer to the Identifying the Device section of the IMediaDevice
interface for more information.
Device Name
Refer to the Identifying the Device section of the IMediaDevice
interface for more information.
Device Location
Refer to the Identifying the Device section of the IMediaDevice
interface for more information.
Default Device
Refer to the Identifying the Device section of the IMediaDevice
interface for more information.
Specifying Echo Cancellation
Some audio devices support adaptive echo cancellation, which removes sound that originates from the device itself. This is useful for voice call applications for removing any audio feedback from the speakers.
Echo cancellation usually attenuates the volume, so the audio might be quieter than when AEC is disabled.
Echo Cancellation Support
Audio devices also report whether they support echo cancellation:
Specifying the Audio Format
Audio devices allow for inspecting the audio format that will be used to stream audio data. This format is defined by the sample rate and channel count.
Sample Rate
The device sample rate is specified in Hertz (Hz).
Audio devices do not support arbitrary sample rates. It is recommended to use one of 8000Hz, 16000Hz, 22050Hz, 24000Hz, 44100Hz, or 48000Hz.
Channel Count
The audio channel count. This will always be a non-negative number, typically 1 (mono) or 2 (stereo).
Audio devices are always guaranteed to support mono audio. No other channel count is guaranteed.
Checking the Device State
Refer to the Checking the Device State section of the IMediaDevice
interface for more information.
Streaming Audio Buffers
Audio devices stream sample buffers to the specified delegate as they are reported by the hardware microphone. The audio buffers will always contain single-precision floating-point (float
) linear PCM data, interleaved by channel (when channelCount
is greater than 1).
The provided handler
is always invoked on a dedicated audio recording thread, separate from the Unity main thread.
Stopping the Stream
Refer to the Stopping the Stream section of the IMediaDevice
interface for more information.
Handling Device Disconnection
Refer to the Handling Device Disconnection section of the IMediaDevice
interface for more information.
This event is not guaranteed to be raised on the Unity main thread.
Last updated