Table of Contents

Struct RAWAudioFrame

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

Represents a raw audio frame, designed for direct memory manipulation and interop scenarios. This struct holds a pointer to the raw audio data, its size, and basic audio format information, along with timing details.

public struct RAWAudioFrame

Inherited Members

Examples

// Example of receiving a RAWAudioFrame from a native component (conceptual)
public void ProcessRawAudio(RAWAudioFrame rawFrame)
{
    Console.WriteLine($"Received raw audio frame: {rawFrame.DataSize} bytes at {rawFrame.Timestamp} ms.");

    // Convert to managed AudioFrame for easier processing if needed
    AudioFrame audioFrame = rawFrame.ToAudioFrame();

    // Now you can work with audioFrame.GetDataArray() or other managed properties
    byte[] audioData = audioFrame.GetDataArray();
    Console.WriteLine($"Converted to AudioFrame with {audioData.Length} bytes.");

    // Important: If the RAWAudioFrame.Data was allocated by a native component,
    // ensure it is freed when no longer needed, typically by the component that allocated it.
}

Remarks

This struct is marked with [StructLayout(LayoutKind.Sequential)] to ensure its memory layout is compatible with unmanaged code. It is primarily used for high-performance audio processing where direct access to audio buffers is required. The VisioForge.Core.Types.RAWAudioFrame.Data field is an IntPtr, meaning memory management (allocation and deallocation) for the audio data buffer must be handled externally or by converting to VisioForge.Core.Types.AudioFrame which manages its own data. This struct is commonly used in callbacks from native audio components or in high-throughput audio processing pipelines. The timing fields (Timestamp and Duration) are in milliseconds for compatibility with native code, unlike the managed AudioFrame which uses TimeSpan. When receiving a RAWAudioFrame from native code, ensure that the memory pointed to by Data remains valid for the duration of processing.

Fields

Data

A pointer to the unmanaged memory buffer containing the raw audio data.

public nint Data

Field Value

nint

DataSize

The size of the raw audio data buffer in bytes.

public int DataSize

Field Value

int

Duration

The duration of the audio frame in milliseconds.

public long Duration

Field Value

long

Info

Contains detailed information about the raw audio format, such as channels, sample rate, and bit depth.

public RAWBaseAudioInfo Info

Field Value

RAWBaseAudioInfo

Timestamp

The presentation timestamp of the audio frame in milliseconds.

public long Timestamp

Field Value

long

Methods

ToAudioFrame()

Converts the current VisioForge.Core.Types.RAWAudioFrame instance into an VisioForge.Core.Types.AudioFrame object. This conversion facilitates working with the audio frame in a more managed and object-oriented way.

public AudioFrame ToAudioFrame()

Returns

AudioFrame

A new VisioForge.Core.Types.AudioFrame instance populated with data from the raw frame.