Navigation
API > API/Runtime > API/Runtime/SignalProcessing
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.
| Name | TCircularAudioBuffer |
| Type | class |
| Header File | /Engine/Source/Runtime/SignalProcessing/Public/DSP/Dsp.h |
| Include Path | #include "DSP/Dsp.h" |
Syntax
template<typename SampleType, size_t Alignment>
class TCircularAudioBuffer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| DSP/Dsp.h | |||
TCircularAudioBuffer
(
const TCircularAudioBuffer< SampleType, Alignment >& InOther |
DSP/Dsp.h | ||
TCircularAudioBuffer
(
uint32 InCapacity |
DSP/Dsp.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Capacity | uint32 | DSP/Dsp.h | ||
| InternalBuffer | TArray< SampleType, TAlignedHeapAllocator< Alignment > > | DSP/Dsp.h | ||
| ReadCounter | FThreadSafeCounter | DSP/Dsp.h | ||
| WriteCounter | FThreadSafeCounter | DSP/Dsp.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Empty() |
DSP/Dsp.h | ||
uint32 GetCapacity() |
Get the current capacity of the buffer. | DSP/Dsp.h | |
uint32 Num() |
Get number of samples that can be popped off of the buffer. | DSP/Dsp.h | |
int32 Peek
(
SampleType* OutBuffer, |
Same as Pop(), but does not increment the read counter. | DSP/Dsp.h | |
bool Peek
(
SampleType& OutElement |
Peeks a single element. returns false if the element is empty. | DSP/Dsp.h | |
DisjointedArrayView< const SampleType > PeekInPlace
(
uint32 NumSamples |
Same Peek(), but provides a (possibly) disjointed view of the memory in-place Push calls while the returned view is being accessed is undefined behavior | DSP/Dsp.h | |
int32 Pop
(
SampleType* OutBuffer, |
Pops some amount of samples into this circular buffer. Returns the amount of samples read. | DSP/Dsp.h | |
int32 Pop
(
uint32 NumSamples |
Pops some amount of samples into this circular buffer. Returns the amount of samples read. | DSP/Dsp.h | |
SampleType Pop () |
Pops a single element. Will assert if the buffer is empty. Please check Num() > 0 before calling. | DSP/Dsp.h | |
DisjointedArrayView< const SampleType > PopInPlace
(
uint32 NumSamples |
Same as Pop(), but provides a (possibly) disjinted view of memory in-place Push calls while the returned view is being accessed is undefined behavior | DSP/Dsp.h | |
int32 Push
(
TArrayView< const SampleType > InBuffer |
Push an array of values into circular buffer. | DSP/Dsp.h | |
bool Push
(
SampleType&& InElement |
DSP/Dsp.h | ||
bool Push
(
const SampleType& InElement |
Push a single sample onto this buffer. Returns false if the buffer is full. | DSP/Dsp.h | |
int32 Push
(
const SampleType* InBuffer, |
Pushes some amount of samples into this circular buffer. | DSP/Dsp.h | |
int32 PushZeros
(
uint32 NumSamplesOfZeros |
Pushes some amount of zeros into the circular buffer. | DSP/Dsp.h | |
uint32 Remainder() |
Get number of samples that can be pushed onto the buffer before it is full. | DSP/Dsp.h | |
void Reserve
(
uint32 InMinimumCapacity, |
Reserve capacity. | DSP/Dsp.h | |
void Reset
(
uint32 InCapacity |
DSP/Dsp.h | ||
void SetCapacity
(
uint32 InCapacity |
DSP/Dsp.h | ||
void SetNum
(
uint32 NumSamples, |
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. | DSP/Dsp.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TCircularAudioBuffer & operator=
(
const TCircularAudioBuffer< SampleType, Alignment >& InOther |
DSP/Dsp.h |