Table of Contents

Class AudioFrame

Namespace
VisioForge.Core.Types
Assembly
VisioForge.Core.dll

Represents a single frame of audio data, including its raw data, format information, and timing. This class is used to pass audio data between different components of the framework.

public class AudioFrame

Inheritance

Inherited Members

Remarks

Audio frames encapsulate a buffer of audio samples along with metadata describing the format (channels, sample rate, bit depth) and timing information (presentation timestamp and duration). This class provides both pointer-based access to unmanaged memory and helper methods for working with audio data. When working with the Data pointer, ensure proper memory management to avoid leaks or corruption.

Constructors

AudioFrame()

Initializes a new instance of the VisioForge.Core.Types.AudioFrame class. A new VisioForge.Core.Types.RAWBaseAudioInfo object is created by default.

public AudioFrame()

Properties

Caps

Gets or sets the GStreamer caps string that describes the media format. This is typically used for advanced scenarios involving direct GStreamer pipeline manipulation.

public string Caps { get; set; }

Property Value

string

Remarks

A caps string might look like: "audio/x-raw, format=S16LE, layout=interleaved, rate=44100, channels=2".

Data

Gets or sets a pointer to the raw audio data buffer.

public nint Data { get; set; }

Property Value

nint

Remarks

This pointer provides direct memory access to the audio samples. Handle with care to avoid memory corruption.

DataSize

Gets or sets the size of the audio data buffer in bytes.

public int DataSize { get; set; }

Property Value

int

Duration

Gets or sets the duration of the audio frame.

public TimeSpan Duration { get; set; }

Property Value

TimeSpan

Info

Gets or sets the audio format information for this frame.

public RAWBaseAudioInfo Info { get; set; }

Property Value

RAWBaseAudioInfo

See Also

Timestamp

Gets or sets the presentation timestamp of the frame. This indicates the time at which the frame should be rendered.

public TimeSpan Timestamp { get; set; }

Property Value

TimeSpan

Methods

ClearData()

Clears the audio data buffer by setting its contents to zero. This does not release the memory, but overwrites it.

public void ClearData()

GetDataArray()

Copies the raw audio data from the unmanaged memory buffer into a managed byte array.

public byte[] GetDataArray()

Returns

byte[]

A new byte array containing the audio data, or null if no data is present.

ToString()

Returns a string that represents the current audio frame, including its timestamp, duration, and data size.

public override string ToString()

Returns

string

A string representation of this instance.