UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AudioChannelFormatConverter.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
9
10namespace Audio
11{
14 {
15 public:
18 {
21 };
22
25 {
28 };
29
30 virtual ~IChannelFormatConverter() = default;
31
33 virtual const FInputFormat& GetInputFormat() const = 0;
34
36 virtual const FOutputFormat& GetOutputFormat() const = 0;
37
48 };
49
50
55 {
56
57 public:
62 {
65
68
71 float Gain = 0.f;
72 };
73
75
77 SIGNALPROCESSING_API const FInputFormat& GetInputFormat() const override;
78
81
90
99
111
119
126
137
138
149
150 protected:
151
153
154 private:
155
156 // Output gain state holds current and next gain levels.
157 struct FOutputGainState
158 {
159 float Gain = 1.f;
160 float NextGain = 0.f;
161 bool bFadeToNextGain = false;
162 };
163
164 // Channel mix entry holds current and next gain levels for a mix entry.
165 struct FChannelMixState : FChannelMixEntry
166 {
167 FChannelMixState() = default;
168
169 FChannelMixState(const FChannelMixEntry& InEntry)
170 : FChannelMixEntry(InEntry)
171 {
172 }
173
174 bool bFadeToNextGain = false;
175 float NextGain = 0.f;
176 };
177
178 // Channel mix key is used to lookup entries from a TSortedMap
179 struct FChannelMixKey
180 {
181 const int32 InputChannelIndex = 0;
182 const int32 OutputChannelIndex = 0;
183
185 : InputChannelIndex(InInputChannelIndex)
186 , OutputChannelIndex(InOutputChannelIndex)
187 {
188 }
189
190 FChannelMixKey(const FChannelMixEntry& InEntry)
191 : InputChannelIndex(InEntry.InputChannelIndex)
192 , OutputChannelIndex(InEntry.OutputChannelIndex)
193 {
194 }
195
196 // Operator needed for using in a TSortedMap
197 friend bool operator<(const FChannelMixKey& InLHS, const FChannelMixKey& InRHS)
198 {
199 if (InLHS.InputChannelIndex == InRHS.InputChannelIndex)
200 {
201 return InLHS.OutputChannelIndex < InRHS.OutputChannelIndex;
202 }
203
204 return InLHS.InputChannelIndex < InRHS.InputChannelIndex;
205 }
206 };
207
208 // The input audio format
209 FInputFormat InputFormat;
210
211 // The output audio format.
212 FOutputFormat OutputFormat;
213
214 // Gain states
215 FOutputGainState OutputGainState;
217
218 int32 NumFramesPerCall;
219 };
220}
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
bool operator<(const FTextFormatString &LHS, const FTextFormatString &RHS)
Definition ITextFormatArgumentModifier.h:147
Definition AudioChannelFormatConverter.h:55
SIGNALPROCESSING_API const FOutputFormat & GetOutputFormat() const override
Definition AudioChannelFormatConverter.cpp:19
SIGNALPROCESSING_API void SetOutputGain(float InOutputGain, bool bFadeToGain=true)
Definition AudioChannelFormatConverter.cpp:24
SIGNALPROCESSING_API float GetTargetOutputGain() const
Definition AudioChannelFormatConverter.cpp:116
SIGNALPROCESSING_API void SetMixGain(const FChannelMixEntry &InEntry, bool bFadeToGain=true)
Definition AudioChannelFormatConverter.cpp:39
virtual SIGNALPROCESSING_API ~FBaseChannelFormatConverter()
SIGNALPROCESSING_API float GetTargetMixGain(int32 InInputChannelIndex, int32 InOutputChannelIndex) const
Definition AudioChannelFormatConverter.cpp:100
SIGNALPROCESSING_API void ProcessAudio(const TArray< FAlignedFloatBuffer > &InInputBuffers, TArray< FAlignedFloatBuffer > &OutOutputBuffers) override
Definition AudioChannelFormatConverter.cpp:123
static SIGNALPROCESSING_API TUniquePtr< FBaseChannelFormatConverter > CreateBaseFormatConverter(const FInputFormat &InInputFormat, const FOutputFormat &InOutputFormat, TArrayView< const FChannelMixEntry > InMixEntries, int32 InNumFramesPerCall)
Definition AudioChannelFormatConverter.cpp:231
SIGNALPROCESSING_API const FInputFormat & GetInputFormat() const override
Definition AudioChannelFormatConverter.cpp:14
Definition AudioChannelFormatConverter.h:14
virtual void ProcessAudio(const TArray< FAlignedFloatBuffer > &InInputBuffers, TArray< FAlignedFloatBuffer > &OutOutputBuffers)=0
virtual ~IChannelFormatConverter()=default
virtual const FOutputFormat & GetOutputFormat() const =0
virtual const FInputFormat & GetInputFormat() const =0
Definition ArrayView.h:139
Definition Array.h:670
Definition SortedMap.h:20
Definition UniquePtr.h:107
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
Definition AudioChannelFormatConverter.h:62
int32 OutputChannelIndex
Definition AudioChannelFormatConverter.h:67
float Gain
Definition AudioChannelFormatConverter.h:71
int32 InputChannelIndex
Definition AudioChannelFormatConverter.h:64
Definition AudioChannelFormatConverter.h:18
int32 NumChannels
Definition AudioChannelFormatConverter.h:20
Definition AudioChannelFormatConverter.h:25
int32 NumChannels
Definition AudioChannelFormatConverter.h:27