Class AudioBuffer
The Audio Buffer class.
Inherited Members
Namespace: Evergine.Common.Audio
Assembly: Evergine.Common.dll
Syntax
public abstract class AudioBuffer : ILoadable, IDisposable, IDependencyObject
Properties
Dependencies
Gets the dependency list.
Declaration
public Lazy<List<IDependencyLink>> Dependencies { get; }
Property Value
Type | Description |
---|---|
Lazy<List<IDependencyLink>> |
Duration
Gets the duration of this buffer data according to the Format.
Declaration
public TimeSpan Duration { get; }
Property Value
Type | Description |
---|---|
TimeSpan |
Format
Gets the wave format of this buffer.
Declaration
public WaveFormat Format { get; }
Property Value
Type | Description |
---|---|
WaveFormat |
Id
Gets or sets the asset Id.
Declaration
public Guid Id { get; set; }
Property Value
Type | Description |
---|---|
Guid | The asset path. |
Length
Gets the length of this buffer.
Declaration
public int Length { get; }
Property Value
Type | Description |
---|---|
int |
ReaderVersion
Gets the reader version.
Declaration
public Version ReaderVersion { get; }
Property Value
Type | Description |
---|---|
Version | The reader version. |
SampleCount
Gets the number of samples contained inside the buffer according to the Format.
Declaration
public int SampleCount { get; }
Property Value
Type | Description |
---|---|
int |
State
Gets the audio buffer State.
Declaration
public AudioBufferStates State { get; }
Property Value
Type | Description |
---|---|
AudioBufferStates |
Methods
Dispose()
Declaration
public virtual void Dispose()
Fill(Stream, int, WaveFormat)
Reads the bytes from the specified stream and writes them to audio buffer.
Declaration
public void Fill(Stream stream, int byteCount, WaveFormat format)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the contents will be copied. |
int | byteCount | Number of bytes to copy. |
WaveFormat | format | The format of the wave data. |
FillAsync(Stream, int, WaveFormat)
Asynchronously reads the bytes from the specified stream and writes them to audio buffer, using a specified buffer size.
Declaration
public Task FillAsync(Stream stream, int bufferSize, WaveFormat format)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The stream from which the contents will be copied. |
int | bufferSize | The size of the buffer. This value must be greater than zero. The default size is
|
WaveFormat | format | The format of the wave data. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous copy operation. |
Fill<TBuffer>(TBuffer[], int, int, WaveFormat)
Reads the data from the specified buffer and writes them to audio buffer.
Declaration
public void Fill<TBuffer>(TBuffer[] buffer, int offset, int count, WaveFormat format) where TBuffer : struct
Parameters
Type | Name | Description |
---|---|---|
TBuffer[] | buffer | The array of |
int | offset | The offset in the array to read from. |
int | count | The number of |
WaveFormat | format | The format of the wave data. |
Type Parameters
Name | Description |
---|---|
TBuffer | Type of a data to write. |
InternalFill(Stream, int)
Fills the audio buffer with a specific stream.
Declaration
protected abstract void InternalFill(Stream stream, int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The source stream. |
int | bufferSize | The buffer size. |
InternalFillAsync(Stream, int)
Fills the audio buffer with a specific stream.
Declaration
protected abstract Task InternalFillAsync(Stream stream, int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | The source stream. |
int | bufferSize | The buffer size. |
Returns
Type | Description |
---|---|
Task | Awaitable task of the operation. |
InternalFill<TBuffer>(TBuffer[], int, int)
Fills the audio buffer with a specific buffer.
Declaration
protected abstract void InternalFill<TBuffer>(TBuffer[] buffer, int offset, int count) where TBuffer : struct
Parameters
Type | Name | Description |
---|---|---|
TBuffer[] | buffer | The source buffer. |
int | offset | The source offset. |
int | count | The number of elements to be copied. |
Type Parameters
Name | Description |
---|---|
TBuffer | The type of the buffer data. |
Invalidate(ILoadable)
Invalidates this instance and raise the Invalidated event with the new ILoadable instance.
Declaration
public void Invalidate(ILoadable newInstance)
Parameters
Type | Name | Description |
---|---|---|
ILoadable | newInstance | The new ILoadable instance. |
ReleaseUnusedMemory()
Release unused memory.
Declaration
public void ReleaseUnusedMemory()
Events
Invalidated
Occurs when this instance has been invalidated and all references must be reloaded.
Declaration
public event EventHandler<ILoadable> Invalidated
Event Type
Type | Description |
---|---|
EventHandler<ILoadable> |