Class AudioBuffer
The AudioBuffer class.
Namespace: Evergine.Common.Audio
Assembly: Evergine.Common.dll
Syntax
public abstract class AudioBuffer : ILoadable, IDependencyObject
Properties
Dependencies
Gets the list of dependencies.
Declaration
public Lazy<List<IDependencyLink>> Dependencies { get; }
Property Value
Type | Description |
---|---|
Lazy<List<IDependencyLink>> |
Duration
Gets the duration of this buffer's 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 in 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()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
Declaration
public virtual void Dispose()
Fill(Stream, int, WaveFormat)
Reads the bytes from the specified stream and writes them to the 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 | The 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 an 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 it to an 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 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 size of the buffer. |
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 | An awaitable task of the operation. |
InternalFill<TBuffer>(TBuffer[], int, int)
Fills the audio buffer with a specified 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 copy. |
Type Parameters
Name | Description |
---|---|
TBuffer | The type of the buffer data. |
Invalidate(ILoadable)
Invalidates this instance and raises 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()
Releases unused memory.
Declaration
public void ReleaseUnusedMemory()
Events
Invalidated
Occurs when this instance is invalidated and all references must be reloaded.
Declaration
public event EventHandler<ILoadable> Invalidated
Event Type
Type | Description |
---|---|
EventHandler<ILoadable> |