UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Audio::FPatchMixer Class Reference

#include <MultithreadedPatching.h>

Public Member Functions

SIGNALPROCESSING_API FPatchInput AddNewInput (int32 MaxLatencyInSamples, float InGain)
 
SIGNALPROCESSING_API void AddNewInput (const FPatchInput &InPatchInput)
 
SIGNALPROCESSING_API void RemovePatch (const FPatchInput &InPatchInput)
 
SIGNALPROCESSING_API int32 PopAudio (float *OutBuffer, int32 OutNumSamples, bool bUseLatestAudio)
 
SIGNALPROCESSING_API int32 Num ()
 
SIGNALPROCESSING_API int32 MaxNumberOfSamplesThatCanBePopped ()
 
SIGNALPROCESSING_API bool WaitUntilNumSamplesAvailable (int32 NumSamples, uint32 TimeOutMilliseconds=MAX_uint32)
 
SIGNALPROCESSING_API void DisconnectAllInputs ()
 

Detailed Description

This class is used for retrieving and mixing down audio from multiple threads. Important to note that this is MPSC: while multiple threads can enqueue audio on an instance of FPatchMixer using instances of FPatchInput, only one thread can call PopAudio safely.

Member Function Documentation

◆ AddNewInput() [1/2]

void Audio::FPatchMixer::AddNewInput ( const FPatchInput InPatchInput)

Adds an existing patch input to the patch mixer.

◆ AddNewInput() [2/2]

FPatchInput Audio::FPatchMixer::AddNewInput ( int32  MaxLatencyInSamples,
float  InGain 
)

Adds a new input to the tap collector. Calling this is thread safe, but individual instances of FPatchInput are only safe to be used from one thread.

◆ DisconnectAllInputs()

void Audio::FPatchMixer::DisconnectAllInputs ( )

Disconnect everything currently connected to this mixer.

◆ MaxNumberOfSamplesThatCanBePopped()

int32 Audio::FPatchMixer::MaxNumberOfSamplesThatCanBePopped ( )

This function call gets the maximum number of samples that's safe to pop, based on the thread with the least amount of samples buffered. Thread safe, but blocks for PopAudio.

◆ Num()

int32 Audio::FPatchMixer::Num ( )

This returns the number of inputs currently connected to this patch mixer. Thread safe, but blocks for PopAudio.

◆ PopAudio()

int32 Audio::FPatchMixer::PopAudio ( float OutBuffer,
int32  OutNumSamples,
bool  bUseLatestAudio 
)

Mixes all inputs into a single buffer. This should only be called from a single thread. Returns the number of non-silent samples popped to OutBuffer.

◆ RemovePatch()

void Audio::FPatchMixer::RemovePatch ( const FPatchInput InPatchInput)

Removes a tap from the tap collector. Calling this is thread safe, though FPatchOutput will likely not be deleted until the next call of PopAudio.

◆ WaitUntilNumSamplesAvailable()

bool Audio::FPatchMixer::WaitUntilNumSamplesAvailable ( int32  NumSamples,
uint32  TimeOutMilliseconds = MAX_uint32 
)

Pauses the current thread until there are the given number of samples available to pop. Will return true if it succeeded, false if it timed out.


The documentation for this class was generated from the following files: