TCircularAudioBuffer

Basic implementation of a circular buffer built for pushing and popping arbitrary amounts of data at once.

Windows
MacOS
Linux

References

Module

SignalProcessing

Header

/Engine/Source/Runtime/SignalProcessing/Public/DSP/Dsp.h

Include

#include "DSP/Dsp.h"

Syntax

template<typename SampleType>
class TCircularAudioBuffer

Remarks

Basic implementation of a circular buffer built for pushing and popping arbitrary amounts of data at once. Designed to be thread safe for SPSC; However, if Push() and Pop() are both trying to access an overlapping area of the buffer, One of the calls will be truncated. Thus, it is advised that you use a high enough capacity that the producer and consumer are never in contention.

Constructors

Name Description

Public function

TCircularAudioBuffer()

Public function

TCircularAudioBuffer

(
    uint32 InCapacity
)

Functions

Name Description

Public function

uint32

 

GetCapacity()

Get the current capacity of the buffer.

Public function

uint32

 

Num()

Get number of samples that can be popped off of the buffer.

Public function

int32

 

Peek

(
    SampleType* OutBuffer,
    uint32 NumSamples
)

Same as Pop(), but does not increment the read counter.

Public function

int32

 

Pop

(
    SampleType* OutBuffer,
    uint32 NumSamples
)

Pops some amount of samples into this circular buffer. Returns the amount of samples read.

Public function

int32

 

Push

(
    const SampleType* InBuffer,
    uint32 NumSamples
)

Pushes some amount of samples into this circular buffer. Returns the amount of samples written.

Public function

uint32

 

Remainder()

Get number of samples that can be pushed onto the buffer before it is full.

Public function

void

 

SetCapacity

(
    uint32 InCapacity
)

Public function

void

 

SetNum

(
    uint32 NumSamples,
    bool bRetainOldestSamples
)

When called, seeks the read or write cursor to only retain either the NumSamples latest data (if bRetainOldestSamples is false) or the NumSamples oldest data (if bRetainOldestSamples is true) in the buffer.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss