UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ISoundfieldFormat.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "AudioMixer.h"
6#include "Containers/Array.h"
7#include "CoreMinimal.h"
8#include "CoreTypes.h"
11#include "Math/Quat.h"
13#include "Templates/TypeHash.h"
14#include "Templates/UniquePtr.h"
15#include "UObject/NameTypes.h"
16#include "UObject/Object.h"
18#include "UObject/ObjectPtr.h"
20
21#include "ISoundfieldFormat.generated.h"
22
23class FArchive;
24class UClass;
25
26
53// List of classes that that interface with Soundfield objects:
54namespace Audio
55{
56 class FMixerDevice;
57 class FMixerSourceManager;
58 class FMixerSubmix;
59
61 {
63
64 // Horizontal angle of the position of this channel, in radians.
65 // Increases as the channel moves clockwise about the listener.
66 // Goes from -PI to PI.
67 float Azimuth = 0.0f;
68 // Vertical angle of the position of this channel, in radians.
69 // Increases as the height of the channel increases proportional to the channel's distance from the listener.
70 // Goes from -PI to PI.
71 float Elevation = 0.0f;
72
73 // distance from the listener. By default, channels are typically on the unit sphere and have a radius of 1.0f.
74 // For spatialized inputs, this radius will be expressed in Unreal Units.
75 float Radius = 1.0f;
76 };
77}
78
84template<typename ToType, typename FromType>
85ToType& DowncastSoundfieldRef(FromType& InRef)
86{
87#if PLATFORM_WINDOWS
88 constexpr bool bIsToTypeChildClass = std::is_base_of<FromType, ToType>::value;
89 static_assert(bIsToTypeChildClass, "Tried to cast a reference to an unrelated type.");
90#endif
91
92 check(&InRef != nullptr);
93
94 return *static_cast<ToType*>(&InRef);
95}
96
97
117
122UCLASS(config = Engine, abstract, editinlinenew, BlueprintType, MinimalAPI)
130
132
137{
138public:
140
144 virtual void Serialize(FArchive& Ar) = 0;
145
150
154 virtual void Reset() = 0;
155};
156
161{
163
165
166 // For encoding, this is the rotation of the emitter source relative to the world.
167 // For decoding, this is the rotation of the listener relative to the output speaker bed.
169};
170
175{
176 /*
177 * Input buffer of interleaved floats. Each channel of the interleaved AudioBuffer corresponds to a channel index in PositionalData.
178 */
180
181 // Number of channels of the source audio buffer.
183
184 // if the input audio was already encoded to ambisonics,
185 // this will point to the settings the audio was encoded with.
186 // Otherwise, this will be a null pointer.
188
190};
191
193{
194public:
196
197 virtual void Encode(const FSoundfieldEncoderInputData& InputData, ISoundfieldAudioPacket& OutputData) = 0;
198 virtual void EncodeAndMixIn(const FSoundfieldEncoderInputData& InputData, ISoundfieldAudioPacket& OutputData) = 0;
199};
200
202{
204
205 // The positions of the channels we will output FSoundfieldDecoderOutputData::AudioBuffer to.
207
210};
211
216
218{
219public:
221
222 virtual void Decode(const FSoundfieldDecoderInputData& InputData, FSoundfieldDecoderOutputData& OutputData) = 0;
223 virtual void DecodeAndMixIn(const FSoundfieldDecoderInputData& InputData, FSoundfieldDecoderOutputData& OutputData) = 0;
224};
225
234
236{
237 // Packet that should be mixed into the output.
239 // settings used to encode both the input packet than the packet we are mixing to.
241 // The amount, in linear gain, to
243};
244
246{
247public:
249
251};
252
254{
255public:
258 {
259 }
260
263
266
269
275
281
285 static AUDIOEXTENSIONS_API ISoundfieldFactory* Get(const FName& InName);
286
288
291
295
296 // Transcoder streams are fed a soundfield audio packet with either a different format entirely, or the same format and different settings.
297 // Specifying and returns a Transcoder Stream is not necessary if CanTranscodeSoundfieldFormat and ShouldReencodeBetween always returns false.
301
302 /*
303 * Override this function to determine whether an incoming ISoundfieldPacket would need to be explicitly operated on between two submixes with the same format, but potentially different encoding settings.
304 * If this returns true, a new transcoder will be created.
305 * if this returns false, then the source submix's ISoundfieldPacket will be passed down directly.
306 */
311
317
323 {
324 return false;
325 }
326
331 {
332 return nullptr;
333 }
334
336
341 virtual bool IsEndpointFormat() { return false; }
342};
343
349
350UCLASS(config = Engine, abstract, editinlinenew, BlueprintType, MinimalAPI)
352{
354
355protected:
357
358private:
359 // This is called by any engine system that is explicitly marked as a friend.
360 TUniquePtr<ISoundfieldEffectSettingsProxy> PrivateGetProxy() const { return GetNewProxy(); }
361
362 // List of classes that use USoundfieldEffectSettingsBase:
363 friend Audio::FMixerSubmix;
365};
366
377
382UCLASS(config = Engine, abstract, editinlinenew, BlueprintType, MinimalAPI)
384{
386
387public:
388
392 UPROPERTY(EditAnywhere, Category = EffectPreset)
394
396 /*
397 * Get the implementation of USoundfieldProcessorSettingsBase that is used for this processor's settings. Will always be called on the CDO.
398 */
399 virtual bool SupportsFormat(const FName& InFormat) const PURE_VIRTUAL(USoundfieldEncodingSettingsBase::SupportsFormat, return false;);
400
401 /*
402 * Get the implementation of USoundfieldProcessorSettingsBase that is used for this processor's settings. Will always be called on the CDO.
403 */
404 virtual const UClass* GetSettingsClass() const PURE_VIRTUAL(USoundfieldEncodingSettingsBase::GetSettingsClass, return nullptr;);
405
409 virtual const USoundfieldEffectSettingsBase* GetDefaultSettings() const PURE_VIRTUAL(USoundfieldEncodingSettingsBase::GetDefaultSettings, return nullptr;);
410
414 virtual TUniquePtr<ISoundfieldEffectInstance> GetNewProcessor(const ISoundfieldEncodingSettingsProxy& EncodingSettings) const PURE_VIRTUAL(USoundfieldEncodingSettingsBase::GetProxy, return nullptr;);
415
416private:
417
418 const USoundfieldEffectSettingsBase* PrivateGetDefaultSettings() const { return GetDefaultSettings(); };
419 TUniquePtr<ISoundfieldEffectInstance> PrivateGetNewProcessor(const ISoundfieldEncodingSettingsProxy& EncodingSettings) const { return GetNewProcessor(EncodingSettings); }
420
421 // List of classes that use USoundfieldEffectBase:
423 friend Audio::FMixerSubmix;
424
425};
426
429{
432
434 : SoundfieldFormat(ISoundfieldFactory::GetFormatNameForNoEncoding())
436 {
437 }
438
440 : SoundfieldFormat(Factory ? Factory->GetSoundfieldFormatName() : ISoundfieldFactory::GetFormatNameForNoEncoding())
441 , EncodingSettingsID(InSettings.GetUniqueId())
442 {
443 }
444
445 inline bool operator==(const FSoundfieldEncodingKey& Other) const
446 {
447 return (SoundfieldFormat == Other.SoundfieldFormat) && (EncodingSettingsID == Other.EncodingSettingsID);
448 }
449
451 {
452 return HashCombine(Value.EncodingSettingsID, Value.SoundfieldFormat.GetNumber());
453 }
454};
#define check(expr)
Definition AssertionMacros.h:314
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ToType & DowncastSoundfieldRef(FromType &InRef)
Definition ISoundfieldFormat.h:85
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define UCLASS(...)
Definition ObjectMacros.h:776
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition AudioMixerSourceManager.h:192
Definition AudioMixerSubmix.h:110
Definition Engine.Build.cs:7
Definition Archive.h:1208
Definition NameTypes.h:617
Definition IModularFeature.h:12
Definition ISoundfieldFormat.h:137
virtual void Reset()=0
virtual TUniquePtr< ISoundfieldAudioPacket > Duplicate() const =0
virtual ~ISoundfieldAudioPacket()
Definition ISoundfieldFormat.h:139
virtual void Serialize(FArchive &Ar)=0
Definition ISoundfieldFormat.h:218
virtual ~ISoundfieldDecoderStream()
Definition ISoundfieldFormat.h:220
virtual void Decode(const FSoundfieldDecoderInputData &InputData, FSoundfieldDecoderOutputData &OutputData)=0
virtual void DecodeAndMixIn(const FSoundfieldDecoderInputData &InputData, FSoundfieldDecoderOutputData &OutputData)=0
Definition ISoundfieldFormat.h:371
virtual ~ISoundfieldEffectInstance()
Definition ISoundfieldFormat.h:373
virtual void ProcessAudio(ISoundfieldAudioPacket &InOutPacket, const ISoundfieldEncodingSettingsProxy &EncodingSettings, const ISoundfieldEffectSettingsProxy &ProcessorSettings)=0
Definition ISoundfieldFormat.h:345
virtual ~ISoundfieldEffectSettingsProxy()
Definition ISoundfieldFormat.h:347
Definition ISoundfieldFormat.h:193
virtual void EncodeAndMixIn(const FSoundfieldEncoderInputData &InputData, ISoundfieldAudioPacket &OutputData)=0
virtual ~ISoundfieldEncoderStream()
Definition ISoundfieldFormat.h:195
virtual void Encode(const FSoundfieldEncoderInputData &InputData, ISoundfieldAudioPacket &OutputData)=0
Definition ISoundfieldFormat.h:104
virtual ~ISoundfieldEncodingSettingsProxy()
Definition ISoundfieldFormat.h:106
virtual uint32 GetUniqueId() const =0
virtual TUniquePtr< ISoundfieldEncodingSettingsProxy > Duplicate() const =0
Definition ISoundfieldFormat.h:254
virtual bool IsTranscodeRequiredBetweenSettings(const ISoundfieldEncodingSettingsProxy &SourceSettings, const ISoundfieldEncodingSettingsProxy &DestinationSettings)
Definition ISoundfieldFormat.h:307
static AUDIOEXTENSIONS_API void RegisterSoundfieldFormat(ISoundfieldFactory *InFactory)
Definition ISoundfieldFormat.cpp:28
virtual TUniquePtr< ISoundfieldDecoderStream > CreateDecoderStream(const FAudioPluginInitializationParams &InitInfo, const ISoundfieldEncodingSettingsProxy &InitialSettings)=0
static AUDIOEXTENSIONS_API FName GetFormatNameForInheritedEncoding()
Definition ISoundfieldFormat.cpp:16
virtual TUniquePtr< ISoundfieldAudioPacket > CreateEmptyPacket()=0
static AUDIOEXTENSIONS_API FName GetModularFeatureName()
Definition ISoundfieldFormat.cpp:22
virtual ~ISoundfieldFactory()
Definition ISoundfieldFormat.h:257
virtual TUniquePtr< ISoundfieldMixerStream > CreateMixerStream(const ISoundfieldEncodingSettingsProxy &InitialSettings)=0
virtual FName GetSoundfieldFormatName()=0
static AUDIOEXTENSIONS_API ISoundfieldFactory * Get(const FName &InName)
Definition ISoundfieldFormat.cpp:40
virtual bool IsEndpointFormat()
Definition ISoundfieldFormat.h:341
virtual bool CanTranscodeFromSoundfieldFormat(FName SourceFormat, const ISoundfieldEncodingSettingsProxy &SourceEncodingSettings)=0
static AUDIOEXTENSIONS_API TArray< FName > GetAvailableSoundfieldFormats()
Definition ISoundfieldFormat.cpp:68
static AUDIOEXTENSIONS_API FName GetFormatNameForNoEncoding()
Definition ISoundfieldFormat.cpp:10
virtual UClass * GetCustomEncodingSettingsClass() const
Definition ISoundfieldFormat.h:330
virtual TUniquePtr< ISoundfieldTranscodeStream > CreateTranscoderStream(const FName SourceFormat, const ISoundfieldEncodingSettingsProxy &InitialSourceSettings, const FName DestinationFormat, const ISoundfieldEncodingSettingsProxy &InitialDestinationSettings, const FAudioPluginInitializationParams &InitInfo)=0
virtual bool CanTranscodeToSoundfieldFormat(FName DestinationFormat, const ISoundfieldEncodingSettingsProxy &DestinationEncodingSettings)=0
virtual const USoundfieldEncodingSettingsBase * GetDefaultEncodingSettings()=0
static AUDIOEXTENSIONS_API void UnregisterSoundfieldFormat(ISoundfieldFactory *InFactory)
Definition ISoundfieldFormat.cpp:34
virtual TUniquePtr< ISoundfieldEncoderStream > CreateEncoderStream(const FAudioPluginInitializationParams &InitInfo, const ISoundfieldEncodingSettingsProxy &InitialSettings)=0
virtual bool ShouldEncodeAllStreamsIndependently(const ISoundfieldEncodingSettingsProxy &EncodingSettings)
Definition ISoundfieldFormat.h:322
Definition ISoundfieldFormat.h:246
virtual ~ISoundfieldMixerStream()
Definition ISoundfieldFormat.h:248
virtual void MixTogether(const FSoundfieldMixerInputData &InputData, ISoundfieldAudioPacket &PacketToMixInto)=0
Definition ISoundfieldFormat.h:227
virtual void Transcode(const ISoundfieldAudioPacket &InputData, const ISoundfieldEncodingSettingsProxy &InputSettings, ISoundfieldAudioPacket &OutputData, const ISoundfieldEncodingSettingsProxy &OutputSettings)=0
virtual void TranscodeAndMixIn(const ISoundfieldAudioPacket &InputData, const ISoundfieldEncodingSettingsProxy &InputSettings, ISoundfieldAudioPacket &PacketToMixTo, const ISoundfieldEncodingSettingsProxy &OutputSettings)=0
virtual ~ISoundfieldTranscodeStream()
Definition ISoundfieldFormat.h:229
Definition Array.h:670
Definition UniquePtr.h:107
Definition Class.h:3793
Definition Object.h:95
Definition ISoundfieldFormat.h:384
Definition ISoundfieldFormat.h:352
virtual TUniquePtr< ISoundfieldEffectSettingsProxy > GetNewProxy() const PURE_VIRTUAL(USoundfieldEffectSettingsBase
Definition ISoundfieldFormat.h:356
Definition ISoundfieldFormat.h:124
virtual TUniquePtr< ISoundfieldEncodingSettingsProxy > GetProxy() const PURE_VIRTUAL(USoundfieldEncodingSettingsBase
Definition ISoundfieldFormat.h:128
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
Type
Definition AudioMixer.h:83
@ DefaultChannel
Definition AudioMixer.h:104
@ false
Definition radaudio_common.h:23
Definition ISoundfieldFormat.h:61
float Elevation
Definition ISoundfieldFormat.h:71
float Radius
Definition ISoundfieldFormat.h:75
float Azimuth
Definition ISoundfieldFormat.h:67
EAudioMixerChannel::Type Channel
Definition ISoundfieldFormat.h:62
Definition IAudioExtensionPlugin.h:127
Definition ISoundfieldFormat.h:202
ISoundfieldAudioPacket & SoundfieldBuffer
Definition ISoundfieldFormat.h:203
float SampleRate
Definition ISoundfieldFormat.h:209
int32 NumFrames
Definition ISoundfieldFormat.h:208
FSoundfieldSpeakerPositionalData & PositionalData
Definition ISoundfieldFormat.h:206
Definition ISoundfieldFormat.h:213
Audio::FAlignedFloatBuffer & AudioBuffer
Definition ISoundfieldFormat.h:214
Definition ISoundfieldFormat.h:175
Audio::FAlignedFloatBuffer & AudioBuffer
Definition ISoundfieldFormat.h:179
ISoundfieldEncodingSettingsProxy & InputSettings
Definition ISoundfieldFormat.h:187
int32 NumChannels
Definition ISoundfieldFormat.h:182
FSoundfieldSpeakerPositionalData & PositionalData
Definition ISoundfieldFormat.h:189
Definition ISoundfieldFormat.h:429
bool operator==(const FSoundfieldEncodingKey &Other) const
Definition ISoundfieldFormat.h:445
friend uint32 GetTypeHash(const FSoundfieldEncodingKey &Value)
Definition ISoundfieldFormat.h:450
FSoundfieldEncodingKey(ISoundfieldFactory *Factory, ISoundfieldEncodingSettingsProxy &InSettings)
Definition ISoundfieldFormat.h:439
FSoundfieldEncodingKey()
Definition ISoundfieldFormat.h:433
FName SoundfieldFormat
Definition ISoundfieldFormat.h:430
int32 EncodingSettingsID
Definition ISoundfieldFormat.h:431
Definition ISoundfieldFormat.h:236
const ISoundfieldEncodingSettingsProxy & EncodingSettings
Definition ISoundfieldFormat.h:240
const ISoundfieldAudioPacket & InputPacket
Definition ISoundfieldFormat.h:238
float SendLevel
Definition ISoundfieldFormat.h:242
Definition ISoundfieldFormat.h:161
const TArray< Audio::FChannelPositionInfo > * ChannelPositions
Definition ISoundfieldFormat.h:164
int32 NumChannels
Definition ISoundfieldFormat.h:162
FQuat Rotation
Definition ISoundfieldFormat.h:168
Definition ObjectPtr.h:488
static CORE_API const TQuat< double > Identity
Definition Quat.h:63