Show / Hide Table of Contents

Class AudioFifo

Represents a managed wrapper around FFmpeg's AVAudioFifo for audio buffering.

Inheritance
object
AudioFifo
Implements
IDisposable
Inherited Members
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.Audio
Assembly: FFmpeg.dll
Syntax
public class AudioFifo : IDisposable
Remarks

This class provides safe, high-level methods to write and read audio data into and from an underlying AVAudioFifo buffer. It supports multiple input formats and channel configurations, and can handle packed ↔ planar (interleaved/unpacked) data internally.

Important: AudioFifo does not convert between sample formats (for example, float ↔ int16). The data is always stored internally according to the Format specified when the FIFO was created.

To avoid unnecessary copying and conversion overhead, it is recommended to provide data in the same planar/packed layout as the FIFO’s Format. If the input layout differs, the FIFO will perform planar ↔ packed conversions internally, which may allocate temporary buffers.

The FIFO maintains an internal buffer for audio samples, allowing for flexible processing pipelines in multi-channel or multi-format audio applications.

Constructors

View Source

AudioFifo(SampleFormat, int)

Initializes a new instance of the AudioFifo class with the specified sample format and channel count.

Declaration
public AudioFifo(SampleFormat format, int channels)
Parameters
Type Name Description
SampleFormat format

The SampleFormat representing the audio sample type and layout.

int channels

The number of channels in the audio stream.

Remarks

Allocates a new AVAudioFifo with default initial capacity (0).
Use this constructor when you do not need to preallocate a specific buffer size.

View Source

AudioFifo(SampleFormat, int, int)

Initializes a new instance of the AudioFifo class with the specified sample format, channel count, and initial capacity.

Declaration
public AudioFifo(SampleFormat format, int channels, int capacity)
Parameters
Type Name Description
SampleFormat format

The SampleFormat representing the audio sample type and layout.

int channels

The number of channels in the audio stream.

int capacity

The initial capacity of the FIFO, in number of samples per channel.

Remarks

Allocates a new AVAudioFifo with the specified initial capacity.
Use this constructor when you want to preallocate a buffer to reduce runtime allocations.

Properties

View Source

Capacity

Gets the total capacity of the audio FIFO in samples, including both used and available space.

Declaration
public int Capacity { get; }
Property Value
Type Description
int
Remarks

Calculated as the sum of the currently available space (FFmpeg.AutoGen.ffmpeg.av_audio_fifo_space(FFmpeg.AutoGen._AVAudioFifo*)) and the number of samples currently in the FIFO (FFmpeg.AutoGen.ffmpeg.av_audio_fifo_size(FFmpeg.AutoGen._AVAudioFifo*)).

View Source

Channels

Gets the number of channels in the audio data handled by this FIFO.

Declaration
public int Channels { get; }
Property Value
Type Description
int
View Source

Count

Gets the number of audio samples currently stored in the FIFO.

Declaration
public int Count { get; }
Property Value
Type Description
int
Remarks

This corresponds to the value returned by FFmpeg.AutoGen.ffmpeg.av_audio_fifo_size(FFmpeg.AutoGen._AVAudioFifo*) and represents the number of samples available for reading.

View Source

Format

Gets the audio sample format used by this FIFO.

Declaration
public SampleFormat Format { get; }
Property Value
Type Description
SampleFormat

Methods

View Source

Clear()

Clears all samples from the FIFO buffer, resetting it to an empty state.

Declaration
public void Clear()
Remarks

After calling this method, the FIFO will contain zero samples.
This does not change the capacity of the FIFO, only the number of stored samples.

View Source

Dispose()

Releases all resources used by the AudioFifo.

Declaration
public void Dispose()
Remarks

This method frees the underlying FFmpeg.AutoGen.ffmpeg.av_audio_fifo_free(FFmpeg.AutoGen._AVAudioFifo*) and suppresses finalization.
Always call Dispose() when finishedReading using an AudioFifo instance to free unmanaged memory.

View Source

Dispose(bool)

Releases the resources used by the AudioFifo.

Declaration
protected virtual void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

View Source

Drop(int)

Drops (removes) a specified number of samples from the start of the FIFO buffer.

Declaration
public AVResult32 Drop(int samples)
Parameters
Type Name Description
int samples

The number of samples to drop from the FIFO.

Returns
Type Description
AVResult32

Returns 0 on success, or a negative error code if the operation fails.

Remarks

This method reduces the number of available samples in the FIFO by samples.
Dropping more samples than are currently available in the FIFO will result in an error.

View Source

Drop(TimeSpan, int)

Drops (removes) audio samples corresponding to the specified duration from the beginning of the FIFO buffer.

Declaration
public AVResult32 Drop(TimeSpan duration, int sampleRate)
Parameters
Type Name Description
TimeSpan duration

The duration of audio to remove from the FIFO.

int sampleRate

The sample rate, in samples per second, used to convert the duration into a sample count.

Returns
Type Description
AVResult32

0 if the samples were successfully removed; otherwise, a negative error code.

Remarks

The specified duration is converted to a sample count using sampleRate. Attempting to remove more samples than are currently stored in the FIFO results in an error.

View Source

~AudioFifo()

Finalizer to ensure unmanaged resources are freed if Dispose() was not called.

Declaration
protected ~AudioFifo()
View Source

Peek(AVFrame)

Peeks audio data from the AudioFifo buffer into an AVFrame.

Declaration
public AVResult32 Peek(AVFrame frame)
Parameters
Type Name Description
AVFrame frame

The AVFrame to receive audio samples.
If the frame has no buffer, its channel layout, sample format, and sample count can be automatically initialized:

  • If .Channels is 0, it is set to the default layout for the FIFO’s Channels.
  • If SampleFormat is None, it is set to the FIFO’s Format.
  • If SampleCount is less than 1, it is set to the current Count (peek all available samples).

If the frame alpeeky has a buffer and any of these properties are unset, an exception is thrown.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek from the FIFO (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The AudioFifo stores all audio data according to the Format specified when the FIFO was created. This method does not convert between sample types (e.g., float ↔ int16); doing so must be handled by the caller.

Planar ↔ packed conversions are handled automatically:

  • If the frame's format exactly matches the FIFO format, the data is peek directly using ffmpeg.av_audio_fifo_peek.
  • If the FIFO stores planar but the frame is packed, the data is converted from planar to packed.
  • If the FIFO stores packed but the frame is planar, the data is converted from packed to planar.

To avoid unnecessary copying, it is recommended to provide frames in the same planar/packed layout as the FIFO’s Format.

Exceptions
Type Condition
ArgumentException

Thrown if the frame alpeeky has a buffer allocated and some properties would need to be set,
or if, after initialization, the frame’s channel count or planar/packed layout does not match the FIFO.

View Source

Peek(AVFrame, int)

Peeks audio data from the AudioFifo buffer into an AVFrame, starting at the specified sample offset within the FIFO.

Declaration
public AVResult32 Peek(AVFrame frame, int offset)
Parameters
Type Name Description
AVFrame frame

The AVFrame to receive audio samples.
If the frame has no buffer, its channel layout, sample format, and sample count can be automatically initialized:

  • If ChannelLayout is 0, it is set to the default layout for the FIFO’s Channels.
  • If SampleFormat is None, it is set to the FIFO’s Format.
  • If SampleCount is less than 1, it is set to the current Count (peek all available samples from the offset).

If the frame already has a buffer and any of these properties are unset, an exception is thrown.

int offset

The sample index within the FIFO at which to begin peeking.
Must be non-negative and less than Count.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked from the FIFO (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The AudioFifo stores all audio data according to the Format specified when the FIFO was created. This method does not convert between sample types (e.g., float ↔ int16); doing so must be handled by the caller.

Planar ↔ packed conversions are handled automatically:

  • If the frame's format exactly matches the FIFO format, the data is peeked directly using ffmpeg.av_audio_fifo_peek.
  • If the FIFO stores planar but the frame is packed, the data is converted from planar to packed.
  • If the FIFO stores packed but the frame is planar, the data is converted from packed to planar.

To avoid unnecessary copying, it is recommended to provide frames in the same planar/packed layout as the FIFO’s Format.

Exceptions
Type Condition
ArgumentNullException

Thrown if frame is null.

ArgumentException

Thrown if the frame already has a buffer allocated and some properties would need to be set,
or if, after initialization, the frame’s channel count or planar/packed layout does not match the FIFO.

ArgumentOutOfRangeException

Thrown if offset is negative or exceeds the number of available samples in the FIFO.

View Source

Peek(byte[,])

Peeks multi-channel audio data into a two-dimensional byte array.

Declaration
public AVResult32 Peek(byte[,] data)
Parameters
Type Name Description
byte[,] data

A two-dimensional byte array where the first dimension is the channel index and the second is the byte index.

Returns
Type Description
AVResult32

The number of samples peek.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels.

View Source

Peek(byte[,], int)

Peeks multi-channel audio data into a two-dimensional byte array.

Declaration
public AVResult32 Peek(byte[,] data, int offset)
Parameters
Type Name Description
byte[,] data

A two-dimensional byte array where the first dimension is the channel index and the second is the byte index.

int offset

The sample offset from which to start peeking. Each unit corresponds to one multi-channel sample.

Returns
Type Description
AVResult32

The number of samples successfully peeked.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels.

View Source

Peek(byte[])

Peeks audio data into a single byte array without advancing the read position.

Declaration
public AVResult32 Peek(byte[] data)
Parameters
Type Name Description
byte[] data

A byte array to receive interleaved audio samples.
The data layout depends on the audio Format and the number of Channels.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of bytes successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

This method allows inspecting audio data without consuming it.
It simply wraps Peek(Span<byte>) for convenience and reads interleaved (packed) samples directly into data.

View Source

Peek(byte[], int)

Peeks audio data into a single byte array starting at a specific sample offset,
without advancing the current read position.

Declaration
public AVResult32 Peek(byte[] data, int offset)
Parameters
Type Name Description
byte[] data

A writable byte array to receive interleaved audio samples.
The data layout depends on the audio Format and the number of Channels.

int offset

The sample offset (in frames) from which to start peeking.
A value of 0 peeks from the beginning of the available buffered data.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of bytes successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

This method allows inspecting buffered audio starting at a specific position without consuming it.
It simply wraps Peek(Span<byte>, int) for convenience and reads interleaved (packed) samples directly into data.

View Source

Peek(params byte[][])

Peeks multi-channel audio data into an array of channel buffers.

Declaration
public AVResult32 Peek(params byte[][] data)
Parameters
Type Name Description
byte[][] data

An array of byte arrays, where each element represents one channel’s audio samples.
The number of elements must match Channels.

Returns
Type Description
AVResult32

The number of samples peek.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Peek(byte[][], int)

Peeks multi-channel audio data into an array of channel buffers.

Declaration
public AVResult32 Peek(byte[][] data, int offset)
Parameters
Type Name Description
byte[][] data

An array of byte arrays, where each element represents one channel’s audio samples. The number of elements must match Channels.

int offset

The sample offset from which to start peeking. Each unit corresponds to one multi-channel sample.

Returns
Type Description
AVResult32

The number of samples successfully peeked.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Peek(Span<byte>)

Peeks packed multi-channel audio data from the AudioFifo into a single contiguous buffer.

Declaration
public AVResult32 Peek(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The number of channels is determined from the current audio stream's Channels property.
The total number of samples is calculated as buffer.Length / Format.GetBytesPerSample(). Planar ↔ packed conversions are handled automatically:

  • If the FIFO stores packed data, samples are peek directly using FFmpeg.Audio.AudioFifo.PeekPackedToPacked(System.Byte*,System.Int32).
  • If the FIFO stores planar data, samples are deinterleaved from planar into the packed buffer using FFmpeg.Audio.AudioFifo.PeekPlanarToPacked(System.Byte*,System.Int32).
View Source

Peek(Span<byte>, int)

Peeks packed multi-channel audio data from the AudioFifo into a single contiguous buffer.

Declaration
public AVResult32 Peek(Span<byte> buffer, int offset = 0)
Parameters
Type Name Description
Span<byte> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one multi-channel sample (i.e., one sample per channel).

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The number of channels is determined from the current audio stream's Channels property.
The total number of samples is calculated as buffer.Length / Format.GetBytesPerSample().
Planar ↔ packed conversions are handled automatically:

  • If the FIFO stores packed data, samples are peeked directly using FFmpeg.Audio.AudioFifo.PeekPackedToPacked(System.Byte*,System.Int32,System.Int32).
  • If the FIFO stores planar data, samples are deinterleaved from planar into the packed buffer using FFmpeg.Audio.AudioFifo.PeekPlanarToPacked(System.Byte*,System.Int32,System.Int32).
View Source

Peek(Span<byte>, Span<byte>)

Peeks stereo (two-channel) audio data into separate left and right channel buffers.

Declaration
public AVResult32 Peek(Span<byte> left, Span<byte> right)
Parameters
Type Name Description
Span<byte> left

A writable span to receive audio samples for the left channel.

Span<byte> right

A writable span to receive audio samples for the right channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Peek(Span<byte>, Span<byte>, int)

Peeks stereo (two-channel) audio data into separate left and right channel buffers.

Declaration
public AVResult32 Peek(Span<byte> left, Span<byte> right, int offset = 0)
Parameters
Type Name Description
Span<byte> left

A writable span to receive audio samples for the left channel.

Span<byte> right

A writable span to receive audio samples for the right channel.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one stereo sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>)

Peeks 3-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3)
Parameters
Type Name Description
Span<byte> ch1
Span<byte> ch2
Span<byte> ch3
Returns
Type Description
AVResult32
View Source

Peek(Span<byte>, Span<byte>, Span<byte>, int)

Peeks 3-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span for channel 1 samples.

Span<byte> ch2

A writable span for channel 2 samples.

Span<byte> ch3

A writable span for channel 3 samples.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one 3-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly three channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 4-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4)
Parameters
Type Name Description
Span<byte> ch1
Span<byte> ch2
Span<byte> ch3
Span<byte> ch4
Returns
Type Description
AVResult32
View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 4-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one 4-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly four channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 5-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly five channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 5-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

Span<byte> ch5

A writable span to receive audio samples for the fifth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 5-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly five channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 6-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly six channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 6-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

Span<byte> ch5

A writable span to receive audio samples for the fifth channel.

Span<byte> ch6

A writable span to receive audio samples for the sixth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 6-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly six channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 7-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly seven channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 7-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

Span<byte> ch5

A writable span to receive audio samples for the fifth channel.

Span<byte> ch6

A writable span to receive audio samples for the sixth channel.

Span<byte> ch7

A writable span to receive audio samples for the seventh channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 7-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly seven channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 8-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Span<byte> ch8

A span to receive samples for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly eight channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 8-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

Span<byte> ch5

A writable span to receive audio samples for the fifth channel.

Span<byte> ch6

A writable span to receive audio samples for the sixth channel.

Span<byte> ch7

A writable span to receive audio samples for the seventh channel.

Span<byte> ch8

A writable span to receive audio samples for the eighth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 8-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly eight channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Peeks 9-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8, Span<byte> ch9)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Span<byte> ch8

A span to receive samples for the eighth channel.

Span<byte> ch9

A span to receive samples for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly nine channels.

View Source

Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int)

Peeks 9-channel audio data into separate channel buffers.

Declaration
public AVResult32 Peek(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8, Span<byte> ch9, int offset = 0)
Parameters
Type Name Description
Span<byte> ch1

A writable span to receive audio samples for the first channel.

Span<byte> ch2

A writable span to receive audio samples for the second channel.

Span<byte> ch3

A writable span to receive audio samples for the third channel.

Span<byte> ch4

A writable span to receive audio samples for the fourth channel.

Span<byte> ch5

A writable span to receive audio samples for the fifth channel.

Span<byte> ch6

A writable span to receive audio samples for the sixth channel.

Span<byte> ch7

A writable span to receive audio samples for the seventh channel.

Span<byte> ch8

A writable span to receive audio samples for the eighth channel.

Span<byte> ch9

A writable span to receive audio samples for the ninth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 9-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

Planar ↔ packed conversions are handled automatically.

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly nine channels.

View Source

Peek<T>(Span<T>)

Peeks packed multi-channel audio data from the AudioFifo into a span of typed samples.

Declaration
public AVResult32 Peek<T>(Span<T> buffer) where T : unmanaged
Parameters
Type Name Description
Span<T> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
Its size must match GetBytesPerSample(SampleFormat).

Remarks

The number of channels is determined from the current audio stream's Channels property.
This method simply reinterprets the T span as bytes and calls Peek(Span<byte>).

View Source

Peek<T>(Span<T>, int)

Peeks packed multi-channel audio data from the AudioFifo into a span of typed samples.

Declaration
public AVResult32 Peek<T>(Span<T> buffer, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one multi-channel sample (i.e., one sample per channel).

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
Its size must match GetBytesPerSample(SampleFormat).

Remarks

This method simply reinterprets the T span as bytes and calls Peek(Span<byte>, int).

View Source

Peek<T>(Span<T>, Span<T>)

Peeks stereo (two-channel) audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> left, Span<T> right) where T : unmanaged
Parameters
Type Name Description
Span<T> left

A writable span for left-channel samples.

Span<T> right

A writable span for right-channel samples.

Returns
Type Description
AVResult32

The number of samples peek or an error code.

Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Peek<T>(Span<T>, Span<T>, int)

Peeks stereo (two-channel) audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> left, Span<T> right, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> left

A writable span to receive left-channel samples.

Span<T> right

A writable span to receive right-channel samples.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one stereo sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either the number of samples peeked or an error code.

Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>)

Peeks 3-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1
Span<T> ch2
Span<T> ch3
Returns
Type Description
AVResult32
Type Parameters
Name Description
T
View Source

Peek<T>(Span<T>, Span<T>, Span<T>, int)

Peeks 3-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span for channel 1 samples.

Span<T> ch2

A writable span for channel 2 samples.

Span<T> ch3

A writable span for channel 3 samples.

int offset

The sample offset from which to start peeking.
Each unit corresponds to one 3-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either the number of samples peeked or an error code.

Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly three channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 4-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly four channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 4-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span to receive samples for the first channel.

Span<T> ch2

A writable span to receive samples for the second channel.

Span<T> ch3

A writable span to receive samples for the third channel.

Span<T> ch4

A writable span to receive samples for the fourth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 4-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets the T spans as bytes and calls Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, int).

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly four channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 5-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly five channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 5-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1
Span<T> ch2
Span<T> ch3
Span<T> ch4
Span<T> ch5
int offset
Returns
Type Description
AVResult32
Type Parameters
Name Description
T
View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 6-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly six channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 6-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span to receive samples for the first channel.

Span<T> ch2

A writable span to receive samples for the second channel.

Span<T> ch3

A writable span to receive samples for the third channel.

Span<T> ch4

A writable span to receive samples for the fourth channel.

Span<T> ch5

A writable span to receive samples for the fifth channel.

Span<T> ch6

A writable span to receive samples for the sixth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 6-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets the T spans as bytes and calls Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int).

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly six channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 7-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly seven channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 7-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span to receive samples for the first channel.

Span<T> ch2

A writable span to receive samples for the second channel.

Span<T> ch3

A writable span to receive samples for the third channel.

Span<T> ch4

A writable span to receive samples for the fourth channel.

Span<T> ch5

A writable span to receive samples for the fifth channel.

Span<T> ch6

A writable span to receive samples for the sixth channel.

Span<T> ch7

A writable span to receive samples for the seventh channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 7-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets the T spans as bytes and calls Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int).

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly seven channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 8-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Span<T> ch8

A span to receive samples for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly eight channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 8-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span to receive samples for the first channel.

Span<T> ch2

A writable span to receive samples for the second channel.

Span<T> ch3

A writable span to receive samples for the third channel.

Span<T> ch4

A writable span to receive samples for the fourth channel.

Span<T> ch5

A writable span to receive samples for the fifth channel.

Span<T> ch6

A writable span to receive samples for the sixth channel.

Span<T> ch7

A writable span to receive samples for the seventh channel.

Span<T> ch8

A writable span to receive samples for the eighth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 8-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets the T spans as bytes and calls Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int).

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly eight channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Peeks 9-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8, Span<T> ch9) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Span<T> ch8

A span to receive samples for the eighth channel.

Span<T> ch9

A span to receive samples for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peek (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly nine channels.

View Source

Peek<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, int)

Peeks 9-channel audio data into typed sample buffers.

Declaration
public AVResult32 Peek<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8, Span<T> ch9, int offset = 0) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A writable span to receive samples for the first channel.

Span<T> ch2

A writable span to receive samples for the second channel.

Span<T> ch3

A writable span to receive samples for the third channel.

Span<T> ch4

A writable span to receive samples for the fourth channel.

Span<T> ch5

A writable span to receive samples for the fifth channel.

Span<T> ch6

A writable span to receive samples for the sixth channel.

Span<T> ch7

A writable span to receive samples for the seventh channel.

Span<T> ch8

A writable span to receive samples for the eighth channel.

Span<T> ch9

A writable span to receive samples for the ninth channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one 9-channel sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets the T spans as bytes and calls Peek(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, int).

Exceptions
Type Condition
NotSupportedException

Thrown when the audio stream does not have exactly nine channels.

View Source

Peek<T>(T[,])

Peeks multi-channel audio data into a two-dimensional typed array.

Declaration
public AVResult32 Peek<T>(T[,] data) where T : unmanaged
Parameters
Type Name Description
T[,] data

A two-dimensional T array where the first dimension is the channel index and the second is the sample index.

Returns
Type Description
AVResult32

The number of samples peek.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels or when sizeof(T) does not match Format.GetBytesPerSample().

View Source

Peek<T>(T[,], int)

Peeks multi-channel audio data into a two-dimensional typed array.

Declaration
public AVResult32 Peek<T>(T[,] data, int offset) where T : unmanaged
Parameters
Type Name Description
T[,] data

A two-dimensional T array where the first dimension is the channel index and the second is the sample index.

int offset

The sample offset from which to start peeking. Each unit corresponds to one multi-channel sample.

Returns
Type Description
AVResult32

The number of samples successfully peeked.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Remarks

This method simply reinterprets the T array as bytes and calls Peek(byte[,], int).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels or when sizeof(T) does not match GetBytesPerSample(SampleFormat).

View Source

Peek<T>(T[])

Peeks typed audio samples into a single buffer without advancing the read position.

Declaration
public AVResult32 Peek<T>(T[] data) where T : unmanaged
Parameters
Type Name Description
T[] data

A buffer to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each frame.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of frames successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
The size of T must match the sample size of the current audio Format.

Remarks

This method reinterprets data as a Span<T> and calls Peek(Span<byte>) internally.
Like all Peek methods, it does not advance the internal read position.

View Source

Peek<T>(T[], int)

Peeks typed audio samples into a single buffer starting at a specific sample offset,
without advancing the current read position.

Declaration
public AVResult32 Peek<T>(T[] data, int offset) where T : unmanaged
Parameters
Type Name Description
T[] data

A writable buffer to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each frame.

int offset

The sample offset (in frames) from which to start peeking.
A value of 0 peeks from the beginning of the available buffered data.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of frames successfully peeked (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
The size of T must match the sample size of the current audio Format.

Remarks

This method reinterprets data as a Span<T> and calls Peek(Span<byte>, int) internally.
Like all Peek methods, it does not advance the internal read position.

View Source

Peek<T>(params T[][])

Peeks multi-channel audio data into an array of typed sample buffers.

Declaration
public AVResult32 Peek<T>(params T[][] data) where T : unmanaged
Parameters
Type Name Description
T[][] data

An array of T arrays, one per channel.

Returns
Type Description
AVResult32

The number of samples peek.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Peek<T>(T[][], int)

Peeks multi-channel audio data into an array of typed sample buffers.

Declaration
public AVResult32 Peek<T>(T[][] data, int offset) where T : unmanaged
Parameters
Type Name Description
T[][] data

An array of T arrays, one per channel.

int offset

The sample offset from which to start peeking. Each unit corresponds to one multi-channel sample.

Returns
Type Description
AVResult32

The number of samples successfully peeked.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Remarks

This method simply reinterprets the T arrays as bytes and calls Peek(byte[][], int).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Read(AVFrame)

Reads audio data from the AudioFifo buffer into an AVFrame.

Declaration
public AVResult32 Read(AVFrame frame)
Parameters
Type Name Description
AVFrame frame

The AVFrame to receive audio samples.
If the frame has no buffer, its channel layout, sample format, and sample count can be automatically initialized:

  • If ChannelLayout.Channels is 0, it is set to the default layout for the FIFO’s Channels.
  • If SampleFormat is None, it is set to the FIFO’s Format.
  • If SampleCount is less than 1, it is set to the current Count (read all available samples).

If the frame already has a buffer and any of these properties are unset, an exception is thrown.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read from the FIFO (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The AudioFifo stores all audio data according to the Format specified when the FIFO was created. This method does not convert between sample types (e.g., float ↔ int16); doing so must be handled by the caller.

Planar ↔ packed conversions are handled automatically:

  • If the frame's format exactly matches the FIFO format, the data is read directly using ffmpeg.av_audio_fifo_read.
  • If the FIFO stores planar but the frame is packed, the data is converted from planar to packed using FFmpeg.Audio.AudioFifo.ReadPlanarToPacked(System.Byte*,System.Int32).
  • If the FIFO stores packed but the frame is planar, the data is converted from packed to planar using FFmpeg.Audio.AudioFifo.ReadPackedToPlanar(System.Byte**,System.Int32).

To avoid unnecessary copying, it is recommended to provide frames in the same planar/packed layout as the FIFO’s Format.

Exceptions
Type Condition
ArgumentException

Thrown if the frame already has a buffer allocated and some properties would need to be set,
or if, after initialization, the frame’s channel count or planar/packed layout does not match the FIFO.

View Source

Read(byte[,])

Reads multi-channel audio data into a two-dimensional byte array.

Declaration
public AVResult32 Read(byte[,] data)
Parameters
Type Name Description
byte[,] data

A two-dimensional byte array where the first dimension is the channel index and the second is the byte index.

Returns
Type Description
AVResult32

The number of samples read.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels.

View Source

Read(byte[])

Reads audio data into a single byte array.

Declaration
public AVResult32 Read(byte[] data)
Parameters
Type Name Description
byte[] data

A byte array to receive interleaved audio samples.
The data layout depends on the audio Format and the number of Channels.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of bytes successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

This method simply wraps Read(Span<byte>) for convenience.
It reads interleaved (packed) audio samples directly into data.

View Source

Read(params byte[][])

Reads multi-channel audio data into an array of channel buffers.

Declaration
public AVResult32 Read(params byte[][] data)
Parameters
Type Name Description
byte[][] data

An array of byte arrays, where each element represents one channel’s audio samples.
The number of elements must match Channels.

Returns
Type Description
AVResult32

The number of samples read.

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Read(Span<byte>)

Reads packed multi-channel audio data from the AudioFifo into a single contiguous buffer.

Declaration
public AVResult32 Read(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The number of channels is determined from the current audio stream's Channels property.
The total number of samples is calculated as buffer.Length / Format.GetBytesPerSample(). Planar ↔ packed conversions are handled automatically:

  • If the FIFO stores packed data, samples are read directly using FFmpeg.Audio.AudioFifo.ReadPackedToPacked(System.Byte*,System.Int32).
  • If the FIFO stores planar data, samples are deinterleaved from planar into the packed buffer using FFmpeg.Audio.AudioFifo.ReadPlanarToPacked(System.Byte*,System.Int32).
View Source

Read(Span<byte>, Span<byte>)

Reads stereo (two-channel) audio data into separate left and right channel buffers.

Declaration
public AVResult32 Read(Span<byte> left, Span<byte> right)
Parameters
Type Name Description
Span<byte> left

A writable span to receive audio samples for the left channel.

Span<byte> right

A writable span to receive audio samples for the right channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Read(Span<byte>, Span<byte>, Span<byte>)

Reads 3-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3)
Parameters
Type Name Description
Span<byte> ch1
Span<byte> ch2
Span<byte> ch3
Returns
Type Description
AVResult32
View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 4-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4)
Parameters
Type Name Description
Span<byte> ch1
Span<byte> ch2
Span<byte> ch3
Span<byte> ch4
Returns
Type Description
AVResult32
View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 5-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly five channels.

View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 6-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly six channels.

View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 7-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly seven channels.

View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 8-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Span<byte> ch8

A span to receive samples for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly eight channels.

View Source

Read(Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>, Span<byte>)

Reads 9-channel audio data into separate channel buffers.

Declaration
public AVResult32 Read(Span<byte> ch1, Span<byte> ch2, Span<byte> ch3, Span<byte> ch4, Span<byte> ch5, Span<byte> ch6, Span<byte> ch7, Span<byte> ch8, Span<byte> ch9)
Parameters
Type Name Description
Span<byte> ch1

A span to receive samples for the first channel.

Span<byte> ch2

A span to receive samples for the second channel.

Span<byte> ch3

A span to receive samples for the third channel.

Span<byte> ch4

A span to receive samples for the fourth channel.

Span<byte> ch5

A span to receive samples for the fifth channel.

Span<byte> ch6

A span to receive samples for the sixth channel.

Span<byte> ch7

A span to receive samples for the seventh channel.

Span<byte> ch8

A span to receive samples for the eighth channel.

Span<byte> ch9

A span to receive samples for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly nine channels.

View Source

Read<T>(Span<T>)

Reads packed multi-channel audio data from the AudioFifo into a span of typed samples.

Declaration
public AVResult32 Read<T>(Span<T> buffer) where T : unmanaged
Parameters
Type Name Description
Span<T> buffer

A writable span to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each audio sample.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
Its size must match GetBytesPerSample(SampleFormat).

Remarks

The number of channels is determined from the current audio stream's Channels property.
This method simply reinterprets the T span as bytes and calls Read(Span<byte>).

View Source

Read<T>(Span<T>, Span<T>)

Reads stereo (two-channel) audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> left, Span<T> right) where T : unmanaged
Parameters
Type Name Description
Span<T> left

A writable span for left-channel samples.

Span<T> right

A writable span for right-channel samples.

Returns
Type Description
AVResult32

The number of samples read or an error code.

Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>)

Reads 3-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1
Span<T> ch2
Span<T> ch3
Returns
Type Description
AVResult32
Type Parameters
Name Description
T
View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>)

Reads 4-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly four channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Reads 5-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly five channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Reads 6-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly six channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Reads 7-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly seven channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Reads 8-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Span<T> ch8

A span to receive samples for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly eight channels.

View Source

Read<T>(Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>, Span<T>)

Reads 9-channel audio data into typed sample buffers.

Declaration
public AVResult32 Read<T>(Span<T> ch1, Span<T> ch2, Span<T> ch3, Span<T> ch4, Span<T> ch5, Span<T> ch6, Span<T> ch7, Span<T> ch8, Span<T> ch9) where T : unmanaged
Parameters
Type Name Description
Span<T> ch1

A span to receive samples for the first channel.

Span<T> ch2

A span to receive samples for the second channel.

Span<T> ch3

A span to receive samples for the third channel.

Span<T> ch4

A span to receive samples for the fourth channel.

Span<T> ch5

A span to receive samples for the fifth channel.

Span<T> ch6

A span to receive samples for the sixth channel.

Span<T> ch7

A span to receive samples for the seventh channel.

Span<T> ch8

A span to receive samples for the eighth channel.

Span<T> ch9

A span to receive samples for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown if the audio stream does not have exactly nine channels.

View Source

Read<T>(T[,])

Reads multi-channel audio data into a two-dimensional typed array.

Declaration
public AVResult32 Read<T>(T[,] data) where T : unmanaged
Parameters
Type Name Description
T[,] data

A two-dimensional T array where the first dimension is the channel index and the second is the sample index.

Returns
Type Description
AVResult32

The number of samples read.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of channels does not match Channels or when sizeof(T) does not match GetBytesPerSample(SampleFormat).

View Source

Read<T>(T[])

Reads typed audio samples into a single buffer.

Declaration
public AVResult32 Read<T>(T[] data) where T : unmanaged
Parameters
Type Name Description
T[] data

A buffer to receive interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each frame.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of frames successfully read (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
The size of T must match the sample size of the current audio Format.

Remarks

This method reinterprets data as a Span<T> and calls Read(Span<byte>) internally.

View Source

Read<T>(params T[][])

Reads multi-channel audio data into an array of typed sample buffers.

Declaration
public AVResult32 Read<T>(params T[][] data) where T : unmanaged
Parameters
Type Name Description
T[][] data

An array of T arrays, one per channel.

Returns
Type Description
AVResult32

The number of samples read.

Type Parameters
Name Description
T

The unmanaged sample type (e.g., float or short).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when any element of data is null.

NotSupportedException

Thrown when data length does not match Channels.

View Source

Write(AVFrame)

Writes audio data from an AVFrame into the AudioFifo buffer.

Declaration
public AVResult32 Write(AVFrame frame)
Parameters
Type Name Description
AVFrame frame

The AVFrame containing audio samples to write.
The frame’s number of channels must match the FIFO’s Channels property, and the sample format must match the planar/packed layout of the FIFO's Format.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written to the FIFO (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

The AudioFifo stores all audio data according to the Format specified when the FIFO was created. This method does not convert between sample types (e.g., float ↔ int16); doing so must be handled by the caller.

Planar ↔ packed conversions are handled automatically:

  • If the frame's format exactly matches the FIFO format, the data is written directly using ffmpeg.av_audio_fifo_write.
  • If the FIFO expects planar but the frame is packed, the data is converted from packed to planar using FFmpeg.Audio.AudioFifo.WritePackedToPlanar(System.Byte*,System.Int32).
  • If the FIFO expects packed but the frame is planar, the data is converted from planar to packed using FFmpeg.Audio.AudioFifo.WritePlanarToPacked(System.Byte**,System.Int32).

To avoid unnecessary copying, it is recommended to provide frames in the same planar/packed layout as the FIFO’s Format.

Exceptions
Type Condition
ArgumentException

Thrown if the frame's channel count does not match the FIFO’s Channels, or if the frame's planar/packed layout does not match the FIFO's Format.

View Source

Write(byte[,])

Writes multi-channel audio data from a two-dimensional byte array.

Declaration
public AVResult32 Write(byte[,] data)
Parameters
Type Name Description
byte[,] data

A two-dimensional byte array where:

  • The first dimension represents the channel index (0-based).
  • The second dimension represents the byte index within each channel’s buffer.

The number of channels (data.GetLength(0)) must match the current audio stream’s Channels property.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of provided channels (data.GetLength(0)) does not match the expected channel count.
This method supports only configurations where data.GetLength(0) == Channels.

View Source

Write(byte[])

Writes audio data from a single byte array.

Declaration
public AVResult32 Write(byte[] data)
Parameters
Type Name Description
byte[] data

A byte array containing interleaved audio samples to write.
The data layout depends on the audio format (Format) and the number of Channels.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of bytes successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Remarks

This method simply reinterprets data as a ReadOnlySpan<T> and calls Write(ReadOnlySpan<byte>).

View Source

Write(params byte[][])

Writes multi-channel audio data from an array of channel buffers.

Declaration
public AVResult32 Write(params byte[][] data)
Parameters
Type Name Description
byte[][] data

An array of byte arrays, where each element represents one channel’s audio samples.
The number of elements in data must match the number of channels in the current audio stream.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when data contains a null channel buffer.

NotSupportedException

Thrown when the number of provided channel buffers does not match the expected number of channels.
This method supports only configurations where data.Length == Channels.

View Source

Write(ReadOnlySpan<byte>)

Writes packed multi-channel audio data from a single contiguous buffer.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> packedData)
Parameters
Type Name Description
ReadOnlySpan<byte> packedData

A read-only span containing interleaved audio samples for all channels. Samples are packed: one sample per channel in sequence for each frame.

Returns
Type Description
AVResult32

The number of frames successfully written, or an error code.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes stereo (two-channel) audio data from separate left and right channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> left, ReadOnlySpan<byte> right)
Parameters
Type Name Description
ReadOnlySpan<byte> left

A read-only span containing audio sample data for the left channel.

ReadOnlySpan<byte> right

A read-only span containing audio sample data for the right channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.
This method supports only stereo output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 3-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly three channels.
This method supports only 3-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 4-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly four channels.
This method supports only 4-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 5-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4, ReadOnlySpan<byte> ch5)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

ReadOnlySpan<byte> ch5

A read-only span containing audio sample data for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly five channels.
This method supports only 5-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 6-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4, ReadOnlySpan<byte> ch5, ReadOnlySpan<byte> ch6)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

ReadOnlySpan<byte> ch5

A read-only span containing audio sample data for the fifth channel.

ReadOnlySpan<byte> ch6

A read-only span containing audio sample data for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly six channels.
This method supports only 6-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 7-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4, ReadOnlySpan<byte> ch5, ReadOnlySpan<byte> ch6, ReadOnlySpan<byte> ch7)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

ReadOnlySpan<byte> ch5

A read-only span containing audio sample data for the fifth channel.

ReadOnlySpan<byte> ch6

A read-only span containing audio sample data for the sixth channel.

ReadOnlySpan<byte> ch7

A read-only span containing audio sample data for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly seven channels.
This method supports only 7-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 8-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4, ReadOnlySpan<byte> ch5, ReadOnlySpan<byte> ch6, ReadOnlySpan<byte> ch7, ReadOnlySpan<byte> ch8)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

ReadOnlySpan<byte> ch5

A read-only span containing audio sample data for the fifth channel.

ReadOnlySpan<byte> ch6

A read-only span containing audio sample data for the sixth channel.

ReadOnlySpan<byte> ch7

A read-only span containing audio sample data for the seventh channel.

ReadOnlySpan<byte> ch8

A read-only span containing audio sample data for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly eight channels.
This method supports only 8-channel output.

View Source

Write(ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>, ReadOnlySpan<byte>)

Writes 9-channel audio data from separate channel buffers.

Declaration
public AVResult32 Write(ReadOnlySpan<byte> ch1, ReadOnlySpan<byte> ch2, ReadOnlySpan<byte> ch3, ReadOnlySpan<byte> ch4, ReadOnlySpan<byte> ch5, ReadOnlySpan<byte> ch6, ReadOnlySpan<byte> ch7, ReadOnlySpan<byte> ch8, ReadOnlySpan<byte> ch9)
Parameters
Type Name Description
ReadOnlySpan<byte> ch1

A read-only span containing audio sample data for the first channel.

ReadOnlySpan<byte> ch2

A read-only span containing audio sample data for the second channel.

ReadOnlySpan<byte> ch3

A read-only span containing audio sample data for the third channel.

ReadOnlySpan<byte> ch4

A read-only span containing audio sample data for the fourth channel.

ReadOnlySpan<byte> ch5

A read-only span containing audio sample data for the fifth channel.

ReadOnlySpan<byte> ch6

A read-only span containing audio sample data for the sixth channel.

ReadOnlySpan<byte> ch7

A read-only span containing audio sample data for the seventh channel.

ReadOnlySpan<byte> ch8

A read-only span containing audio sample data for the eighth channel.

ReadOnlySpan<byte> ch9

A read-only span containing audio sample data for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly nine channels.
This method supports only 9-channel output.

View Source

Write<T>(ReadOnlySpan<T>)

Writes packed multi-channel audio data from a read-only span of typed samples.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> buffer) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> buffer

A read-only span containing interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each frame.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of frames successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).
Its size must match GetBytesPerSample(SampleFormat).

Remarks

The number of channels is determined from the current audio stream's Channels property.
This method simply reinterprets the T span as bytes and calls Write(ReadOnlySpan<byte>).

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes stereo (two-channel) audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> left, ReadOnlySpan<T> right) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> left

A read-only span containing left-channel samples.

ReadOnlySpan<T> right

A read-only span containing right-channel samples.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly two channels.
This method supports only stereo output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 3-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly three channels.
This method supports only 3-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 4-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly four channels.
This method supports only 4-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 5-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4, ReadOnlySpan<T> ch5) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

ReadOnlySpan<T> ch5

A read-only span containing samples for the fifth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly five channels.
This method supports only 5-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 6-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4, ReadOnlySpan<T> ch5, ReadOnlySpan<T> ch6) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

ReadOnlySpan<T> ch5

A read-only span containing samples for the fifth channel.

ReadOnlySpan<T> ch6

A read-only span containing samples for the sixth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly six channels.
This method supports only 6-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 7-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4, ReadOnlySpan<T> ch5, ReadOnlySpan<T> ch6, ReadOnlySpan<T> ch7) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

ReadOnlySpan<T> ch5

A read-only span containing samples for the fifth channel.

ReadOnlySpan<T> ch6

A read-only span containing samples for the sixth channel.

ReadOnlySpan<T> ch7

A read-only span containing samples for the seventh channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly seven channels.
This method supports only 7-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 8-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4, ReadOnlySpan<T> ch5, ReadOnlySpan<T> ch6, ReadOnlySpan<T> ch7, ReadOnlySpan<T> ch8) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

ReadOnlySpan<T> ch5

A read-only span containing samples for the fifth channel.

ReadOnlySpan<T> ch6

A read-only span containing samples for the sixth channel.

ReadOnlySpan<T> ch7

A read-only span containing samples for the seventh channel.

ReadOnlySpan<T> ch8

A read-only span containing samples for the eighth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly eight channels.
This method supports only 8-channel output.

View Source

Write<T>(ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>, ReadOnlySpan<T>)

Writes 9-channel audio data from typed sample buffers.

Declaration
public AVResult32 Write<T>(ReadOnlySpan<T> ch1, ReadOnlySpan<T> ch2, ReadOnlySpan<T> ch3, ReadOnlySpan<T> ch4, ReadOnlySpan<T> ch5, ReadOnlySpan<T> ch6, ReadOnlySpan<T> ch7, ReadOnlySpan<T> ch8, ReadOnlySpan<T> ch9) where T : unmanaged
Parameters
Type Name Description
ReadOnlySpan<T> ch1

A read-only span containing samples for the first channel.

ReadOnlySpan<T> ch2

A read-only span containing samples for the second channel.

ReadOnlySpan<T> ch3

A read-only span containing samples for the third channel.

ReadOnlySpan<T> ch4

A read-only span containing samples for the fourth channel.

ReadOnlySpan<T> ch5

A read-only span containing samples for the fifth channel.

ReadOnlySpan<T> ch6

A read-only span containing samples for the sixth channel.

ReadOnlySpan<T> ch7

A read-only span containing samples for the seventh channel.

ReadOnlySpan<T> ch8

A read-only span containing samples for the eighth channel.

ReadOnlySpan<T> ch9

A read-only span containing samples for the ninth channel.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
NotSupportedException

Thrown when the current audio stream does not have exactly nine channels.
This method supports only 9-channel output.

View Source

Write<T>(T[,])

Writes multi-channel audio data from a two-dimensional typed array.

Declaration
public AVResult32 Write<T>(T[,] data) where T : unmanaged
Parameters
Type Name Description
T[,] data

A two-dimensional array of T where:

  • The first dimension represents the channel index (0-based).
  • The second dimension represents the sample index within each channel.

The number of channels (data.GetLength(0)) must match the current audio stream’s Channels property.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

NotSupportedException

Thrown when the number of provided channels (data.GetLength(0)) does not match the expected channel count.
Or if the element size sizeof(T) does not match GetBytesPerSample(SampleFormat).

View Source

Write<T>(T[])

Writes typed audio samples from a single buffer.

Declaration
public AVResult32 Write<T>(T[] data) where T : unmanaged
Parameters
Type Name Description
T[] data

A buffer containing interleaved audio samples for all channels.
Samples are packed: one sample per channel in sequence for each frame.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of frames successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets data as a ReadOnlySpan<T> and calls Write(ReadOnlySpan<byte>).

View Source

Write<T>(params T[][])

Writes multi-channel audio data from an array of typed sample buffers.

Declaration
public AVResult32 Write<T>(params T[][] data) where T : unmanaged
Parameters
Type Name Description
T[][] data

An array of T arrays, where each element represents one channel’s samples.
The number of elements in data must match the number of channels in the current audio stream.

Returns
Type Description
AVResult32

An AVResult32 value representing either:

  • The number of samples successfully written (if the operation succeeded).
  • An error code (if the operation failed).
Type Parameters
Name Description
T

The unmanaged sample type (for example, float or short).

Remarks

This method simply reinterprets each T array as bytes and calls Write(params byte[][]).

Exceptions
Type Condition
ArgumentNullException

Thrown when data is null.

ArgumentException

Thrown when data contains a null channel buffer.

NotSupportedException

Thrown when the number of provided channel buffers does not match the expected number of channels.
This method supports only configurations where data.Length == Channels.

Implements

IDisposable
  • View Source
In this article
Back to top Generated by DocFX