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

#include <IAudioEncoder.h>

+ Inheritance diagram for Audio::IAudioEncoder:

Public Member Functions

SIGNALPROCESSING_API IAudioEncoder (uint32 AudioBufferSlack, uint32 DataBufferSlack=4096)
 
virtual SIGNALPROCESSING_API ~IAudioEncoder ()
 
SIGNALPROCESSING_API bool PushAudio (const float *InBuffer, int32 NumSamples, bool bEncodeIfPossible=true)
 
SIGNALPROCESSING_API int32 PopData (uint8 *OutData, int32 DataSize)
 
virtual int32 GetCompressedPacketSize () const =0
 
SIGNALPROCESSING_API bool EncodeIfPossible ()
 
SIGNALPROCESSING_API int64 Finalize ()
 

Protected Member Functions

SIGNALPROCESSING_API void Init (const FSoundQualityInfo &InQualityInfo)
 
virtual int64 SamplesRequiredPerEncode () const =0
 
virtual bool StartFile (const FSoundQualityInfo &InQualityInfo, TArray< uint8 > &OutFileStart)=0
 
virtual bool EncodeChunk (const TArray< float > &InAudio, TArray< uint8 > &OutBytes)=0
 
virtual bool EndFile (TArray< uint8 > &OutBytes)=0
 

Detailed Description

IAudioEncoder Interface used to implement a runtime audio encoder.

Constructor & Destructor Documentation

◆ IAudioEncoder()

Audio::IAudioEncoder::IAudioEncoder ( uint32  AudioBufferSlack,
uint32  DataBufferSlack = 4096 
)

Must be constructed with AudioBufferSlack. Optionally, DataBufferSlack can be called with a different value depending on how often PushAudio, EncodeIfPossible, or PopData will be called.

◆ ~IAudioEncoder()

Audio::IAudioEncoder::~IAudioEncoder ( )
virtual

Member Function Documentation

◆ EncodeChunk()

virtual bool Audio::IAudioEncoder::EncodeChunk ( const TArray< float > &  InAudio,
TArray< uint8 > &  OutBytes 
)
protectedpure virtual

Override this to compress InAudio to OutBytes. Returns true on success, false on failure.

Implemented in FOpusEncoder, and FWavEncoder.

◆ EncodeIfPossible()

bool Audio::IAudioEncoder::EncodeIfPossible ( )

If you'd like to run audio encoding on a separate thread, use this call. Otherwise, ensure that bEncodeIfPossible is set to true when you call PushAudio.

◆ EndFile()

virtual bool Audio::IAudioEncoder::EndFile ( TArray< uint8 > &  OutBytes)
protectedpure virtual

Override this to compress InAudio to OutBytes. Returns true on success, false on failure.

Implemented in FOpusEncoder, and FWavEncoder.

◆ Finalize()

int64 Audio::IAudioEncoder::Finalize ( )

Call this once you are finished pushing audio. Returns the amount of bytes left to pop if positive, and if negative indicates a failiure.

◆ GetCompressedPacketSize()

virtual int32 Audio::IAudioEncoder::GetCompressedPacketSize ( ) const
pure virtual

Used for internet streaming. Should return the amount of bytes required for a self contained packet.

Implemented in FOpusEncoder, and FWavEncoder.

◆ Init()

void Audio::IAudioEncoder::Init ( const FSoundQualityInfo InQualityInfo)
protected

Should be called in the constructor of any implementation of IAudioEncoder. Calls StartFile if necessary.

◆ PopData()

int32 Audio::IAudioEncoder::PopData ( uint8 OutData,
int32  DataSize 
)

Pop compressed data. If you are using this encoder for streaming over network, use the size returned by GetCompressedPacketSize(). Returns number of bytes written.

◆ PushAudio()

bool Audio::IAudioEncoder::PushAudio ( const float InBuffer,
int32  NumSamples,
bool  bEncodeIfPossible = true 
)

Call this function when audio is available. If you would like to handle compression on a separate thread or call, Call this function with bEncodeIfPossible set to false. Returns true if audio was successfully pushed, false, if the internal buffer is full.

◆ SamplesRequiredPerEncode()

virtual int64 Audio::IAudioEncoder::SamplesRequiredPerEncode ( ) const
protectedpure virtual

How many samples of decoded audio that are required for a single compression operation.

Implemented in FOpusEncoder, and FWavEncoder.

◆ StartFile()

virtual bool Audio::IAudioEncoder::StartFile ( const FSoundQualityInfo InQualityInfo,
TArray< uint8 > &  OutFileStart 
)
protectedpure virtual

This should be overridden to, give the properties in InQualityInfo, write a header into OutFileStart. returns true on success, or false on failure.

Implemented in FOpusEncoder, and FWavEncoder.


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