Skip to main content
Version: 2.x

UOdinDecoder

Represents a decoder for media streams from remote voice chat clients, which encapsulates all the components required to process incoming audio streams.

Declaration
UCLASS(ClassGroup = (Odin), Blueprintable, BlueprintType)
class ODIN_API UOdinDecoder : public UObject
  • Header: #include "OdinAudio/OdinDecoder.h"
  • Module: Odin
  • Inherits from: UObject
  • Blueprint: Blueprint type, Blueprintable · Blueprint reference

Overview​

Functions​

NameDescription
ConstructDecoderCreate uobject decoder with already created decoder handle
SetupInternalDecoderInternally Creates a new instance of an ODIN decoder with default settings used to process the remote media stream.
FreeDecoderFrees the resources associated with the specified decoder.
FreeDecoderInternal
GetOrCreateDecoderPipelineReturns an object to the pointer of the internal ODIN audio pipeline instance used by the given decoder.
GetOrCreatePipelineReturns an object to the pointer of the internal ODIN audio pipeline instance used by the given decoder.
GetIsSilentReturns whether the decoder is currently processing silence.
SetAudioEventHandlerRegisters a callback to receive decoder audio events.
GetActiveChannelMaskReturns a bitmask indicating the channels on which the most recently pushed voice packet was transmitted.
GetPositionsRetrieves the last known 3D position(s) sent by the remote peer.
PopRetrieves a block of processed audio samples from the decoder's buffer.
PushPushes an incoming datagram to the specified decoder for processing.
GetNativeHandleGet internal handle
GetHandle
SetHandleReplace internal handle object
GetHandleCell

Properties​

NameDescription
PipelineThe audio pipeline of the decoder, once it was created.
ChannelMaskThe channels this decoder plays back.
SampleRateSample rate of the audio the decoder produces.
bStereoTrue if the decoder produces interleaved stereo audio.

Functions​

ConstructDecoder​

Overload 1

Static

Create uobject decoder with already created decoder handle

static UOdinDecoder* ConstructDecoder(UObject* WorldContextObject, OdinDecoder* Handle);
ParameterTypeDescription
WorldContextObjectUObject*context lifetime object
HandleOdinDecoder*incomplete internal handle type

Returns UOdinDecoder* – uobject decoder or null

Overload 2

Static · Blueprint: Construct Decoder

Create uobject decoder with already created decoder handle

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
static UOdinDecoder* ConstructDecoder(
UObject* WorldContextObject,
int32 SampleRate = 48000,
bool bUseStereo = false);
ParameterTypeDescription
WorldContextObjectUObject*context lifetime object
SampleRateint32samplerate for f32bit Default: 48000.
bUseStereoboolchannels interleaved Default: false.

Returns UOdinDecoder* – uobject decoder or null

SetupInternalDecoder​

Blueprint: Create Decoder

Internally Creates a new instance of an ODIN decoder with default settings used to process the remote media stream. Will re-setup

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
UOdinDecoder* SetupInternalDecoder(int32 DecoderSampleRate, bool bUseStereo);
ParameterTypeDescription
DecoderSampleRateint32samplerate for f32bit
bUseStereoboolchannels interleaved

Returns UOdinDecoder*

FreeDecoder​

Static · Blueprint: Free Decoder

Frees the resources associated with the specified decoder.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
static bool FreeDecoder(UOdinDecoder* Decoder);
ParameterTypeDescription
DecoderUOdinDecoder*The decoder to free.

Returns bool – True if the decoder was freed.

FreeDecoderInternal​

Static

static bool FreeDecoderInternal(OdinDecoder* DecoderHandle);
ParameterTypeDescription
DecoderHandleOdinDecoder*

Returns bool

GetOrCreateDecoderPipeline​

Static · Blueprint: Get Decoder Pipeline

Returns an object to the pointer of the internal ODIN audio pipeline instance used by the given decoder.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
static UOdinPipeline* GetOrCreateDecoderPipeline(UOdinDecoder* Decoder);
ParameterTypeDescription
DecoderUOdinDecoder*The decoder.

Returns UOdinPipeline* – The pipeline.

GetOrCreatePipeline​

Blueprint: Get Pipeline

Returns an object to the pointer of the internal ODIN audio pipeline instance used by the given decoder.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
UOdinPipeline* GetOrCreatePipeline();

Returns UOdinPipeline*

GetIsSilent​

Const · Blueprint: Get Silent Flag (Decoder)

Returns whether the decoder is currently processing silence. This reflects the internal silence detection state of the decoder, which updates as audio is processed.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline")
bool GetIsSilent() const;

Returns bool – True if silent.

note

Always returns true, if the passed decoder is invalid.

SetAudioEventHandler​

Blueprint: Register AudioEvent Handler (Decoder)

Registers a callback to receive decoder audio events. The filter determines which event types will trigger the callback, allowing selective handling.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline|Events")
bool SetAudioEventHandler(UPARAM(meta = (DisplayName = "Filter", Bitmask, BitmaskEnum = "/Script/Odin.EOdinAudioEvents")) int32 EFilter);
ParameterTypeDescription
EFilterint32Bitmask filter for events.

Returns bool – True if registration was successful.

note

Any previously registered callback is replaced.

GetActiveChannelMask​

Const · Blueprint: Get Active ChannelMask

Returns a bitmask indicating the channels on which the most recently pushed voice packet was transmitted.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline")
int64 GetActiveChannelMask() const;

Returns int64 – Active channel mask.

note

If no packet has been processed yet, the value is 0.

GetPositions​

Const · Blueprint: Get Positions (Decoder)

Retrieves the last known 3D position(s) sent by the remote peer. This data is available even if the audio stream is currently silent.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline")
TArray<FOdinPosition> GetPositions(FOdinChannelMask ChannelMask) const;
ParameterTypeDescription
ChannelMaskFOdinChannelMaskThe channel mask.

Returns TArray<FOdinPosition> – Array of positions, one for each channel in the mask.

Pop​

Overload 1

Const · Blueprint: Pop Samples

Retrieves a block of processed audio samples from the decoder's buffer. The samples are interleaved floating-point values in the range[-1, 1] and are written into the provided output buffer.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
int32 Pop(TArray<float>& Samples, bool& bSilence) const;
ParameterTypeDescription
SamplesTArray<float>&interleaved float buffer
bSilencebool&A flag is also set to indicate if the output is silent

Returns int32 – samples count

Overload 2

Const

int32 Pop(float* Samples, int32 Count, bool* bSilence) const;
ParameterTypeDescription
Samplesfloat*
Countint32
bSilencebool*

Returns int32

Push​

Const · Blueprint: Push Datagram

Pushes an incoming datagram to the specified decoder for processing.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
int32 Push(const TArray<uint8>& Datagram) const;
ParameterTypeDescription
Datagramconst TArray<uint8>&audio byte array

Returns int32 – datagram size

GetNativeHandle​

Const · Inline

Get internal handle

OdinDecoder* GetNativeHandle() const;

Returns OdinDecoder* – incomplete handle type or nullptr

note

OdinDecoder operations are thread-safe and the same encoder handle may be accessed concurrently from multiple threads.

GetHandle​

Const · Inline

TWeakObjectPtr<UOdinHandle> GetHandle() const;

Returns TWeakObjectPtr<UOdinHandle>

SetHandle​

Replace internal handle object

void SetHandle(OdinDecoder* NewHandle);
ParameterTypeDescription
NewHandleOdinDecoder*internal handle

GetHandleCell​

Const · Inline

TSharedRef<FOdinDecoderHandleCell, ESPMode::ThreadSafe> GetHandleCell() const;

Returns TSharedRef<FOdinDecoderHandleCell, ESPMode::ThreadSafe>

Properties​

Pipeline​

Blueprint: Get

The audio pipeline of the decoder, once it was created.

UPROPERTY(BlueprintReadOnly, Category = "Odin|Audio Pipeline")
UOdinPipeline* Pipeline = nullptr;

ChannelMask​

Blueprint: Get/Set

The channels this decoder plays back. Applied when the decoder is registered to a peer; voice packets on other channels are not routed to it.

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Odin|Channels")
FOdinChannelMask ChannelMask = FOdinChannelMask::CreateFull();

SampleRate​

Blueprint: Get

Sample rate of the audio the decoder produces.

UPROPERTY(BlueprintReadOnly, Category = "Odin")
int32 SampleRate = 48000;

bStereo​

Blueprint: Get

True if the decoder produces interleaved stereo audio.

UPROPERTY(BlueprintReadOnly, Category = "Odin")
bool bStereo = true;

Events​

OnAudioEventCallbackBP​

Blueprint: On Audio Event (Decoder)

A callback invoked when the decoder reports one or more audio events.

UPROPERTY(BlueprintAssignable, Category = "Odin|Audio Pipeline|Events")
FOdinDecoderAudioEventCallbackDelegate OnAudioEventCallbackBP;

Signature: FOdinDecoderAudioEventCallbackDelegate void(UOdinDecoder* decoder, EOdinAudioEvents filter) (multicast)

warning

Please remember to start listening by calling SetAudioEventHandler!