Class BufferedWaveProvider
Provides a buffered store of samples. Read method will return queued samples or fill buffer with zeroes. Backed by a circular buffer.
public class BufferedWaveProvider : IWaveProvider
- Inheritance
-
BufferedWaveProvider
- Implements
- Inherited Members
- Extension Methods
Constructors
BufferedWaveProvider(WaveFormat, TimeSpan?)
Creates a new buffered WaveProvider
public BufferedWaveProvider(WaveFormat waveFormat, TimeSpan? bufferDuration = null)
Parameters
waveFormatWaveFormatWaveFormat
bufferDurationTimeSpan?Buffer duration (defaults to 5 seconds)
Properties
BufferDuration
Buffer duration
public TimeSpan BufferDuration { get; }
Property Value
BufferLength
Buffer length in bytes
public int BufferLength { get; }
Property Value
BufferedBytes
The number of buffered bytes
public int BufferedBytes { get; }
Property Value
BufferedDuration
Buffered Duration
public TimeSpan BufferedDuration { get; }
Property Value
DiscardOnBufferOverflow
If true, when the buffer is full, start throwing away data. If false, AddSamples will throw an exception when buffer is full.
public bool DiscardOnBufferOverflow { get; set; }
Property Value
ReadFully
If true, always read the amount of data requested, padding with zeroes if necessary. By default is set to true.
public bool ReadFully { get; set; }
Property Value
WaveFormat
Gets the WaveFormat
public WaveFormat WaveFormat { get; }
Property Value
Methods
AddSamples(byte[], int, int)
Adds samples. Takes a copy of buffer, so that buffer can be reused if necessary.
public void AddSamples(byte[] buffer, int offset, int count)
Parameters
AddSamples(ReadOnlySpan<byte>)
Adds samples from a span. Takes a copy of the data.
public void AddSamples(ReadOnlySpan<byte> data)
Parameters
dataReadOnlySpan<byte>
ClearBuffer()
Discards all audio from the buffer
public void ClearBuffer()
Read(Span<byte>)
Reads from this audio source. Will always return the full span if ReadFully is set, zero-filling if not enough data available.
public int Read(Span<byte> buffer)