UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SoundFieldRendering.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
6#include "ISoundfieldFormat.h"
9
13
14
16{
17public:
18 // Interleaved audio buffer for all vector parts of the ambisonics stream.
20
21 // number of channels in the Ambisonics stream.
22 // Currently we don't explicitly support mixed order ambisonics,
23 // so this will always be equal to (m + 1)^2, where m is the order of ambisonics this was encoded with.
25
26 // This is the rotation of the ambisonics source.
29
31 : NumChannels(0)
32 , Rotation(FQuat::Identity)
33 , PreviousRotation(FQuat::Identity)
34 {}
35
38
39 SOUNDFIELDRENDERING_API virtual void Serialize(FArchive& Ar) override;
41 SOUNDFIELDRENDERING_API virtual void Reset() override;
42
43};
44
54
56{
57public:
58 SOUNDFIELDRENDERING_API FSoundFieldDecoder(); // initializes VirtualSpeakerWorldLockedSpeakerGains
59
63
65
66private:
67 // Special cased, vectorized versions of first order operations.
68 static SOUNDFIELDRENDERING_API void FirstOrderDecodeLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
69 static SOUNDFIELDRENDERING_API void FirstOrderToSevenOneLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
70
71 // Special cased vectorized versions of 3rd and fifth order operations.
72 static SOUNDFIELDRENDERING_API void OddOrderDecodeLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
73 static SOUNDFIELDRENDERING_API void OddOrderToSevenOneLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
74
75 // Partially vectorized decode operations for 2nd and 4th order operations.
76 static SOUNDFIELDRENDERING_API void EvenOrderDecodeLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
77 static SOUNDFIELDRENDERING_API void EvenOrderToSevenOneLoop(const int32 NumFrames, const int32 NumOutputChannels, const float* pAmbiFrame, const int32 NumAmbiChannels, float* SpeakerGainsPtr, float* OutputBufferPtrBuffer);
78
79 // Helper function to get the default channel positions for a channel array.
81
82 Audio::FAlignedFloatBuffer VirtualSpeakerScratchBuffers;
83 Audio::FAlignedFloatBuffer FoaVirtualSpeakerWordLockedGains;
84 Audio::FAlignedFloatBuffer TargetSpeakerGains;
85 Audio::FAlignedFloatBuffer CurrentSpeakerGains;
86 Audio::FAlignedFloatBuffer MixdownGainsMap;
87 Audio::FBufferLinearEase SpeakerGainLerper;
88 FVector2D LastListenerRotationSphericalCoord{ -999.f, -999.f }; // force interpolation on first callback
89
91 static SOUNDFIELDRENDERING_API TArray<Audio::FChannelPositionInfo> VirtualSpeakerLocationsHorzOnly;
92 static SOUNDFIELDRENDERING_API const VectorRegister Sqrt2Over2Vec;
93 static SOUNDFIELDRENDERING_API const VectorRegister ZeroVec;
94
95
96 friend class FSoundFieldEncoder;
97};
98
100{
101public:
104
105private:
106 static void EncodeLoop(const int32 NumFrames, const int32 NumInputChannels, const float* RESTRICT InputAudioPtr, const int32 NumAmbiChannels, float* RESTRICT SpeakerGainsPtr, float* RESTRICT OutputAmbiBuffer);
107
108 Audio::FAlignedFloatBuffer VirtualSpeakerScratchBuffers;
109 Audio::FAlignedFloatBuffer SpeakerGains;
110 Audio::FAlignedFloatBuffer MixdownGainsMap;
111};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define RESTRICT
Definition Platform.h:706
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
SOUNDFIELDRENDERING_API TUniquePtr< ISoundfieldDecoderStream > CreateDefaultSourceAmbisonicsDecoder(Audio::FMixerDevice *InDevice)
Definition SoundFieldRendering.cpp:826
SOUNDFIELDRENDERING_API ISoundfieldEncodingSettingsProxy & GetAmbisonicsSourceDefaultSettings()
Definition SoundFieldRendering.cpp:847
SOUNDFIELDRENDERING_API FName GetUnrealAmbisonicsFormatName()
Definition SoundFieldRendering.cpp:820
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition BufferVectorOperations.h:156
Definition AudioMixerDevice.h:117
Definition SoundFieldRendering.h:16
Audio::FAlignedFloatBuffer AudioBuffer
Definition SoundFieldRendering.h:19
int32 NumChannels
Definition SoundFieldRendering.h:24
FAmbisonicsSoundfieldBuffer()
Definition SoundFieldRendering.h:30
virtual ~FAmbisonicsSoundfieldBuffer()
Definition SoundFieldRendering.h:36
virtual SOUNDFIELDRENDERING_API void Reset() override
Definition SoundFieldRendering.cpp:801
FQuat Rotation
Definition SoundFieldRendering.h:27
FQuat PreviousRotation
Definition SoundFieldRendering.h:28
virtual SOUNDFIELDRENDERING_API TUniquePtr< ISoundfieldAudioPacket > Duplicate() const override
Definition SoundFieldRendering.cpp:796
Definition SoundFieldRendering.h:46
int32 Order
Definition SoundFieldRendering.h:48
virtual SOUNDFIELDRENDERING_API TUniquePtr< ISoundfieldEncodingSettingsProxy > Duplicate() const override
Definition SoundFieldRendering.cpp:813
virtual SOUNDFIELDRENDERING_API uint32 GetUniqueId() const override
Definition SoundFieldRendering.cpp:807
Definition Archive.h:1208
Definition NameTypes.h:617
Definition SoundFieldRendering.h:56
static SOUNDFIELDRENDERING_API void FoaRotationInPlace(Audio::FAlignedFloatBuffer &InOutFrames, const float XRotDegrees, const float YRotDegrees, const float ZRotDegrees)
Definition SoundFieldRendering.cpp:653
static SOUNDFIELDRENDERING_API void RotateFirstOrderAmbisonicsBed(const FAmbisonicsSoundfieldBuffer &InputData, FAmbisonicsSoundfieldBuffer &OutputData, const FQuat &DestinationRotation, const FQuat &PreviousRotation)
Definition SoundFieldRendering.cpp:448
SOUNDFIELDRENDERING_API FSoundFieldDecoder()
Definition SoundFieldRendering.cpp:12
SOUNDFIELDRENDERING_API void DecodeAudioDirectlyToDeviceOutputPositions(const FAmbisonicsSoundfieldBuffer &InputData, const FSoundfieldSpeakerPositionalData &OutputPositions, Audio::FAlignedFloatBuffer &OutputData)
Definition SoundFieldRendering.cpp:85
SOUNDFIELDRENDERING_API void DecodeAudioToSevenOneAndDownmixToDevice(const FAmbisonicsSoundfieldBuffer &InputData, const FSoundfieldSpeakerPositionalData &OutputPositions, Audio::FAlignedFloatBuffer &OutputData)
Definition SoundFieldRendering.cpp:283
Definition SoundFieldRendering.h:100
SOUNDFIELDRENDERING_API FSoundFieldEncoder()
Definition SoundFieldRendering.cpp:697
SOUNDFIELDRENDERING_API void EncodeAudioDirectlyFromOutputPositions(const Audio::FAlignedFloatBuffer &InputData, const FSoundfieldSpeakerPositionalData &InputPositions, const FAmbisonicsSoundfieldSettings &Settings, FAmbisonicsSoundfieldBuffer &OutputData)
Definition SoundFieldRendering.cpp:701
Definition SphericalHarmonicCalculator.h:17
Definition ISoundfieldFormat.h:137
Definition ISoundfieldFormat.h:104
Definition UniquePtr.h:107
Definition ISoundfieldFormat.h:161
Definition UnrealMathFPU.h:42