Skip to main content
Version: 2.x

UOdinFunctionLibrary

Declaration
UCLASS()
class ODIN_API UOdinFunctionLibrary : public UBlueprintFunctionLibrary
  • Header: #include "OdinFunctionLibrary.h"
  • Module: Odin
  • Inherits from: UBlueprintFunctionLibrary
  • Blueprint: Reflected (UCLASS) · Blueprint reference

Overview​

Functions​

NameDescription
GenerateAccessKeyGenerates a new random access key, e.g.
FormatOdinErrorConverts an ODIN error code into a human-readable string description.
OdinStringToBytesHelper to convert a String to a UTF-8 Byte Array.
OdinHexStringToBytesConverts a hexadecimal string (e.g.
OdinBytesToStringConverts a UTF-8 byte array to a string.
OdinBytesToHexStringConverts bytes to a hexadecimal string.
CreateOdinAudioCaptureCreates an Odin Audio Capture object, which records audio from the operating system's input devices.
CreateOdinEncoderFromGeneratorCreates encoder with the samplerate and channel count from the generator.
LinkEncoderToRoomLinks an encoder to a room.
UnlinkEncoderFromRoomUnlinks an encoder from a room.
RegisterDecoderRegisters a decoder for a peer of a room, so the decoder receives the peer's audio.
GetDecodersForPeerFinds all decoders associated with a specific peer.
GetRoomsByNameReturns all rooms that were created with the given room ID.
DeregisterDecoderFromAllConnectionsDeregisters the specified decoder from all active connections.
Conv_OdinPositionToVectorConverts an Odin Position to a Vector.
Conv_VectorToOdinPositionConverts a Vector to an Odin Position.
CreateChannelMaskCreates a channel mask from a map of channel indices (0-63) to enabled flags.
SetChannelsEnables or disables the channels in the map on an existing mask.
SetChannelsEnabledEnables the given channels on an existing mask.
SetChannelsDisabledDisables the given channels on an existing mask.
CreateChannelMaskFromEnabledCreates a channel mask in which only the given channels are enabled.
CreateChannelMaskFromDisabledCreates a channel mask in which all channels except the given ones are enabled.
SetChannelInMaskEnables or disables one channel of an existing mask.
IsChannelEnabledInMaskReturns whether a channel is enabled in the mask.
CreateFullMaskCreates a channel mask with all 64 channels enabled.
CreateEmptyMaskCreates a channel mask with no channels enabled.
DoesAudioEventMatchFilterReturns true if the audio event is part of the filter bitmask, e.g.
OdinDebugDumpStateReturns a text dump of the internal state of the native ODIN library for debugging, e.g.

Functions​

GenerateAccessKey​

Static · Blueprint: Generate Access Key

Generates a new random access key, e.g. for local testing. Room tokens are signed with an access key; for production, use the key from your ODIN dashboard and generate tokens on a server.

UFUNCTION(BlueprintPure, Category = "Odin|Authentication")
static FString GenerateAccessKey();

Returns FString – The generated access key.

FormatOdinError​

Static · Blueprint: Format Odin Error

Converts an ODIN error code into a human-readable string description.

UFUNCTION(BlueprintPure, Category = "Odin|Error Handling")
static FString FormatOdinError(EOdinError Code, bool bUETrace);
ParameterTypeDescription
CodeEOdinErrorThe error code.
bUETraceboolInclude UE trace.

Returns FString – Human-readable error.

OdinStringToBytes​

Static · Blueprint: Odin String to Bytes

Helper to convert a String to a UTF-8 Byte Array. Useful for raw data messages.

UFUNCTION(BlueprintPure, Category = "Odin|Custom Data")
static void OdinStringToBytes(const FString& Str, TArray<uint8>& Buffer);
ParameterTypeDescription
Strconst FString&String to convert.
BufferTArray<uint8>&Output byte array.

OdinHexStringToBytes​

Static · Blueprint: Odin Hex String to Bytes

Converts a hexadecimal string (e.g. 0a1b2c) to bytes. Returns an empty array if the string contains other characters.

UFUNCTION(BlueprintPure, Category = "Odin|Custom Data")
static void OdinHexStringToBytes(const FString& Str, TArray<uint8>& Buffer);
ParameterTypeDescription
Strconst FString&
BufferTArray<uint8>&

OdinBytesToString​

Static · Blueprint: Odin Bytes to String

Converts a UTF-8 byte array to a string.

UFUNCTION(BlueprintPure, Category = "Odin|Custom Data")
static void OdinBytesToString(const TArray<uint8>& Buffer, FString& Str);
ParameterTypeDescription
Bufferconst TArray<uint8>&Byte array.
StrFString&Output string.

OdinBytesToHexString​

Static · Blueprint: Odin Bytes to Hex String

Converts bytes to a hexadecimal string.

UFUNCTION(BlueprintPure, Category = "Odin|Custom Data")
static void OdinBytesToHexString(const TArray<uint8>& Buffer, FString& Str);
ParameterTypeDescription
Bufferconst TArray<uint8>&
StrFString&

CreateOdinAudioCapture​

Static · Blueprint: Create Odin Audio Capture

Creates an Odin Audio Capture object, which records audio from the operating system's input devices. This is the first step to set up microphone input. Don't forget to call Start Capturing on it.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Capture")
static UOdinAudioCapture* CreateOdinAudioCapture(UObject* WorldContextObject);
ParameterTypeDescription
WorldContextObjectUObject*

Returns UOdinAudioCapture* – The audio capture object.

CreateOdinEncoderFromGenerator​

Static · Blueprint: Create Odin Encoder from Generator

Creates encoder with the samplerate and channel count from the generator. The encoder will automatically use the generator as audio source. Will also automatically link the encoder to the provided Odin Room.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Capture")
static UOdinEncoder* CreateOdinEncoderFromGenerator(
UObject* WorldContextObject,
UPARAM(ref) UOdinRoom*& OdinRoom,
UPARAM(ref) UAudioGenerator*& AudioGenerator);
ParameterTypeDescription
WorldContextObjectUObject*
OdinRoomUOdinRoom*&The Odin Room that the encoder should be linked to.
AudioGeneratorUAudioGenerator*&The audio generator that should be used as audio source for the encoder.

Returns UOdinEncoder* – The created encoder, already linked to the room.

LinkEncoderToRoom​

Static · Blueprint: Link Encoder to Room

Links an encoder to a room. Audio from the encoder will be sent to the room.

UFUNCTION(BlueprintCallable, Category = "Odin|Encoder")
static void LinkEncoderToRoom(UOdinEncoder* Encoder, UOdinRoom* Room);
ParameterTypeDescription
EncoderUOdinEncoder*
RoomUOdinRoom*

UnlinkEncoderFromRoom​

Static · Blueprint: Unlink Encoder from Room

Unlinks an encoder from a room. Audio from the encoder will no longer be sent to the room.

UFUNCTION(BlueprintCallable, Category = "Odin|Encoder")
static void UnlinkEncoderFromRoom(UOdinEncoder* Encoder);
ParameterTypeDescription
EncoderUOdinEncoder*

RegisterDecoder​

Static · Blueprint: Register Decoder to Peer

Registers a decoder for a peer of a room, so the decoder receives the peer's audio. To remove it, use Deregister Decoder From All. A decoder can only be registered to one peer at a time.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
static void RegisterDecoder(UOdinDecoder* Decoder, UOdinRoom* Room, int64 PeerId);
ParameterTypeDescription
DecoderUOdinDecoder*The decoder.
RoomUOdinRoom*The room.
PeerIdint64Target peer ID.

GetDecodersForPeer​

Static · Blueprint: Get Decoders for Peer

Finds all decoders associated with a specific peer.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline")
static TArray<UOdinDecoder*> GetDecodersForPeer(UOdinRoom* Room, int64 PeerId);
ParameterTypeDescription
RoomUOdinRoom*The room.
PeerIdint64The peer ID.

Returns TArray<UOdinDecoder*> – Array of decoders.

GetRoomsByName​

Static · Blueprint: Get Rooms by Name

Returns all rooms that were created with the given room ID.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline")
static TArray<UOdinRoom*> GetRoomsByName(const FString& RoomId);
ParameterTypeDescription
RoomIdconst FString&The room identifier.

Returns TArray<UOdinRoom*> – Array of rooms.

DeregisterDecoderFromAllConnections​

Static · Blueprint: Deregister Decoder From All

Deregisters the specified decoder from all active connections.

UFUNCTION(BlueprintCallable, Category = "Odin|Audio Pipeline")
static void DeregisterDecoderFromAllConnections(UOdinDecoder* Decoder);
ParameterTypeDescription
DecoderUOdinDecoder*The decoder to deregister.

Conv_OdinPositionToVector​

Static · Blueprint: To Vector

Converts an Odin Position to a Vector. This is an autocast node: the editor inserts it automatically when you connect the two pin types.

UFUNCTION(BlueprintPure, Category = "Odin|Conversions")
static FVector Conv_OdinPositionToVector(FOdinPosition InPosition);
ParameterTypeDescription
InPositionFOdinPosition

Returns FVector

Conv_VectorToOdinPosition​

Static · Blueprint: To Odin Position

Converts a Vector to an Odin Position. This is an autocast node: the editor inserts it automatically when you connect the two pin types.

UFUNCTION(BlueprintPure, Category = "Odin|Conversions")
static FOdinPosition Conv_VectorToOdinPosition(const FVector& InPosition);
ParameterTypeDescription
InPositionconst FVector&

Returns FOdinPosition

CreateChannelMask​

Static · Blueprint: Create Channel Mask

Creates a channel mask from a map of channel indices (0-63) to enabled flags. Channels that are not in the map get the Default Value.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static FOdinChannelMask CreateChannelMask(const TMap<int32, bool>& Channels, bool bDefaultValue);
ParameterTypeDescription
Channelsconst TMap<int32, bool>&Channel index mapped to whether the channel is enabled.
bDefaultValueboolWhether the channels that are not in the map are enabled.

Returns FOdinChannelMask – The channel mask.

SetChannels​

Static · Blueprint: Set Channels

Enables or disables the channels in the map on an existing mask.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static void SetChannels(UPARAM(ref) FOdinChannelMask& Mask, const TMap<int32, bool>& Channels);
ParameterTypeDescription
MaskFOdinChannelMask&The mask to change.
Channelsconst TMap<int32, bool>&Channel index mapped to whether the channel is enabled.

SetChannelsEnabled​

Static · Blueprint: Set Channels Enabled

Enables the given channels on an existing mask.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static void SetChannelsEnabled(UPARAM(ref) FOdinChannelMask& Mask, const TArray<int32>& EnabledChannels);
ParameterTypeDescription
MaskFOdinChannelMask&The mask to change.
EnabledChannelsconst TArray<int32>&Indices of the channels to enable.

SetChannelsDisabled​

Static · Blueprint: Set Channels Disabled

Disables the given channels on an existing mask.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static void SetChannelsDisabled(UPARAM(ref) FOdinChannelMask& Mask, const TArray<int32>& DisabledChannels);
ParameterTypeDescription
MaskFOdinChannelMask&The mask to change.
DisabledChannelsconst TArray<int32>&Indices of the channels to disable.

CreateChannelMaskFromEnabled​

Static · Blueprint: Create Channel Mask from Enabled

Creates a channel mask in which only the given channels are enabled.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static FOdinChannelMask CreateChannelMaskFromEnabled(const TArray<int32>& EnabledChannels);
ParameterTypeDescription
EnabledChannelsconst TArray<int32>&Indices of the channels to enable.

Returns FOdinChannelMask

CreateChannelMaskFromDisabled​

Static · Blueprint: Create Channel Mask from Disabled

Creates a channel mask in which all channels except the given ones are enabled.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static FOdinChannelMask CreateChannelMaskFromDisabled(const TArray<int32>& DisabledChannels);
ParameterTypeDescription
DisabledChannelsconst TArray<int32>&Indices of the channels to disable.

Returns FOdinChannelMask

SetChannelInMask​

Static · Blueprint: Set Channel in Mask

Enables or disables one channel of an existing mask.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static void SetChannelInMask(UPARAM(ref) FOdinChannelMask& Mask, int32 ChannelIndex, bool bEnabled);
ParameterTypeDescription
MaskFOdinChannelMask&The mask to change.
ChannelIndexint32Index of the channel, 0-63.
bEnabledboolWhether the channel is enabled.

IsChannelEnabledInMask​

Static · Blueprint: Is Channel Enabled in Mask

Returns whether a channel is enabled in the mask.

UFUNCTION(BlueprintPure, Category = "Odin|Channels")
static bool IsChannelEnabledInMask(const FOdinChannelMask& Mask, const int32 ChannelIndex);
ParameterTypeDescription
Maskconst FOdinChannelMask&
ChannelIndexconst int32Index of the channel, 0-63.

Returns bool

CreateFullMask​

Static · Blueprint: Create Full Mask

Creates a channel mask with all 64 channels enabled.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static FOdinChannelMask CreateFullMask();

Returns FOdinChannelMask – Full mask.

note

Do not use a full mask for Set Encoder Position: an encoder holds at most 12 channel positions, so a full mask fails with ODIN_ERROR_AUDIO_POSITION_LIMIT_REACHED. Mask only the channels that are actually transmitted on (usually just channel 0).

CreateEmptyMask​

Static · Blueprint: Create Empty Mask

Creates a channel mask with no channels enabled.

UFUNCTION(BlueprintCallable, Category = "Odin|Channels")
static FOdinChannelMask CreateEmptyMask();

Returns FOdinChannelMask – Empty mask.

DoesAudioEventMatchFilter​

Static · Blueprint: Does Audio Event Match Filter

Returns true if the audio event is part of the filter bitmask, e.g. to check the Filter output of On Audio Event.

UFUNCTION(BlueprintPure, Category = "Odin|Audio Pipeline|Events")
static bool DoesAudioEventMatchFilter(
EOdinAudioEvents Event,
UPARAM(meta = (DisplayName = "Filter", Bitmask, BitmaskEnum = "/Script/Odin.EOdinAudioEvents")) int32 Filter);
ParameterTypeDescription
EventEOdinAudioEvents
Filterint32

Returns bool

OdinDebugDumpState​

Static · Blueprint: Odin Debug Dump State

Returns a text dump of the internal state of the native ODIN library for debugging, e.g. to attach to a support request.

UFUNCTION(BlueprintPure, Category = "Odin|Debug")
static FString OdinDebugDumpState();

Returns FString