Class AudioTrackReadBuffer
High level interface for consuming WebRTC audio tracks. Enqueues audio frames for a RemoteAudioTrack in an internal buffer as they arrive. Users should call Read(Int32, Int32, Single[], out Int32, out Boolean, AudioTrackReadBuffer.PadBehavior) to read samples from the buffer when needed.
Namespace: Microsoft.MixedReality.WebRTC
Assembly: Microsoft.MixedReality.WebRTC.dll
Syntax
public class AudioTrackReadBuffer : IDisposable
Methods
| Improve this Doc View SourceDispose()
Release the buffer.
Declaration
public void Dispose()
Read(Int32, Int32, Single[], AudioTrackReadBuffer.PadBehavior)
Fill samplesOut
with samples from the internal buffer.
See Read(Int32, Int32, Single[], out Int32, out Boolean, AudioTrackReadBuffer.PadBehavior).
Declaration
public void Read(int sampleRate, int channels, float[] samplesOut, AudioTrackReadBuffer.PadBehavior padBehavior = default(AudioTrackReadBuffer.PadBehavior))
Parameters
Type | Name | Description |
---|---|---|
Int32 | sampleRate | |
Int32 | channels | |
Single[] | samplesOut | |
AudioTrackReadBuffer.PadBehavior | padBehavior |
Read(Int32, Int32, Single[], out Int32, out Boolean, AudioTrackReadBuffer.PadBehavior)
Fill samplesOut
with samples from the internal buffer.
Declaration
public void Read(int sampleRate, int numChannels, float[] samplesOut, out int numSamplesRead, out bool hasOverrun, AudioTrackReadBuffer.PadBehavior padBehavior = default(AudioTrackReadBuffer.PadBehavior))
Parameters
Type | Name | Description |
---|---|---|
Int32 | sampleRate | Desired sample rate. Data in the buffer is resampled if this is different from the native track rate. |
Int32 | numChannels | Desired number of channels. Should be 1 or 2. Data in the buffer is split/averaged if this is different from the native track channels number. |
Single[] | samplesOut | Will be filled with the samples read from the internal buffer. The function will try to fill the entire length of the array. |
Int32 | numSamplesRead | Set to the effective number of samples read.
This will be generally equal to the length of |
Boolean | hasOverrun | Set to |
AudioTrackReadBuffer.PadBehavior | padBehavior | Controls how |
Remarks
This method reads the internal buffer starting from the oldest data.
If the internal buffer is exhausted (underrun), samplesOut
is padded according to the value of padBehavior
.
This method should be called regularly to consume the audio data as it is received. Note that the internal buffer can overrun (and some frames can be dropped) if this is not called frequently enough.