Table of Contents

Class WaveBuffer

Namespace
NAudio.Wave
Assembly
NAudio.Core.dll

WaveBuffer class use to store wave datas. Data can be manipulated with arrays (ByteBuffer,FloatBuffer,ShortBuffer,IntBuffer ) that are pointing to the same memory buffer. Use the associated Count property based on the type of buffer to get the number of data in the buffer. Implicit casting is now supported to float[], byte[], int[], short[]. You must not use Length on returned arrays.

n.b. FieldOffset is 8 now to allow it to work natively on 64 bit

public class WaveBuffer : IWaveBuffer
Inheritance
WaveBuffer
Implements
Inherited Members

Constructors

WaveBuffer(byte[])

Initializes a new instance of the WaveBuffer class binded to a specific byte buffer.

public WaveBuffer(byte[] bufferToBoundTo)

Parameters

bufferToBoundTo byte[]

A byte buffer to bound the WaveBuffer to.

WaveBuffer(int)

Initializes a new instance of the WaveBuffer class.

public WaveBuffer(int sizeToAllocateInBytes)

Parameters

sizeToAllocateInBytes int

The number of bytes. The size of the final buffer will be aligned on 4 Bytes (upper bound)

Fields

numberOfBytes

Number of Bytes

public int numberOfBytes

Field Value

int

Properties

ByteBuffer

Gets the byte buffer.

public byte[] ByteBuffer { get; }

Property Value

byte[]

The byte buffer.

ByteBufferCount

Gets or sets the byte buffer count.

public int ByteBufferCount { get; set; }

Property Value

int

The byte buffer count.

FloatBuffer

Gets the float buffer.

public float[] FloatBuffer { get; }

Property Value

float[]

The float buffer.

FloatBufferCount

Gets or sets the float buffer count.

public int FloatBufferCount { get; set; }

Property Value

int

The float buffer count.

IntBuffer

Gets the int buffer.

public int[] IntBuffer { get; }

Property Value

int[]

The int buffer.

IntBufferCount

Gets or sets the int buffer count.

public int IntBufferCount { get; set; }

Property Value

int

The int buffer count.

MaxSize

Gets the max size in bytes of the byte buffer..

public int MaxSize { get; }

Property Value

int

Maximum number of bytes in the buffer.

ShortBuffer

Gets the short buffer.

public short[] ShortBuffer { get; }

Property Value

short[]

The short buffer.

ShortBufferCount

Gets or sets the short buffer count.

public int ShortBufferCount { get; set; }

Property Value

int

The short buffer count.

Methods

BindTo(byte[])

Binds this WaveBuffer instance to a specific byte buffer.

public void BindTo(byte[] bufferToBoundTo)

Parameters

bufferToBoundTo byte[]

A byte buffer to bound the WaveBuffer to.

Clear()

Clears the associated buffer.

public void Clear()

Copy(Array)

Copy this WaveBuffer to a destination buffer up to ByteBufferCount bytes.

public void Copy(Array destinationArray)

Parameters

destinationArray Array

Operators

implicit operator byte[](WaveBuffer)

Performs an implicit conversion from WaveBuffer to byte.

public static implicit operator byte[](WaveBuffer waveBuffer)

Parameters

waveBuffer WaveBuffer

The wave buffer.

Returns

byte[]

The result of the conversion.

implicit operator short[](WaveBuffer)

Performs an implicit conversion from WaveBuffer to short.

public static implicit operator short[](WaveBuffer waveBuffer)

Parameters

waveBuffer WaveBuffer

The wave buffer.

Returns

short[]

The result of the conversion.

implicit operator int[](WaveBuffer)

Performs an implicit conversion from WaveBuffer to int.

public static implicit operator int[](WaveBuffer waveBuffer)

Parameters

waveBuffer WaveBuffer

The wave buffer.

Returns

int[]

The result of the conversion.

implicit operator float[](WaveBuffer)

Performs an implicit conversion from WaveBuffer to float.

public static implicit operator float[](WaveBuffer waveBuffer)

Parameters

waveBuffer WaveBuffer

The wave buffer.

Returns

float[]

The result of the conversion.