UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
LateReflectionsFast.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"
7#include "DSP/IntegerDelay.h"
8#include "DSP/LongDelayAPF.h"
10#include "DSP/DynamicDelayAPF.h"
11
12namespace Audio
13{
14 // Structure to hold the various delay line tap outputs produced from a plate.
16 {
17 // Number of tap locations in plate reverb
18 static const int32 NumTaps = 7;
19
20 // Tap sample buffers.
22
23 // Output sample buffer.
25
26 // Resizes and zero all buffers in structure.
28 };
29
30 // Delay line settings for reverb plate delay
31 // Tap locations are determined by analyzing these delay values.
33 {
34 /*
35 Setting the delay values affects the tap locations. The audio flowchart below shows the
36 relationship between delay values and tap locations.
37
38 +---------------+
39 | Input |
40 +------+--------+
41 |
42 +------v--------+
43 | Modulated APF |
44 +------+--------+
45 |
46 +------+-------+
47 | DelayA |
48 +------+-------+ +---------+
49 |--------->+ Tap 0 |
50 +------v-------+ +---------+
51 | DelayB |
52 +------+-------+ +---------+
53 |----------> Tap 1 |
54 +------v-------+ +---------+
55 | DelayC |
56 +------+-------+ +---------+
57 |----------> Tap 2 |
58 +------v-------+ +---------+
59 | DelayD |
60 +------+-------+
61 |
62 +------v--------+
63 | LPF |
64 +------+--------+
65 |
66 +------v-------+ +---------+ +---------+ +---------+ +--------+
67 | APF +--> DelayE +--> |Tap 3 +--> DelayF +--> Tap 4 |
68 +------+-------+ +---------+ +---------+ +---------+ +--------+
69 |
70 +------v-------+
71 | DelayG |
72 +------+-------+ +---------+
73 |----------> Tap 5 |
74 +------v-------+ +---------+
75 | DelayH |
76 +------+-------+ +---------+
77 |--------->+ Tap 6 |
78 +------v-------+ +---------+
79 | DelayI |
80 +------+-------+
81 |
82 +------v-------+
83 | Output |
84 +--------------+
85 */
86
87 // Base delay samples for modulated delay
89 // Max delta samples for modulated delay
91 // Tap 0 exists at the output of DelayA
93 // Tap 1 exists at the output of DelayB
95 // Tap 2 exists at the output of DelayC
97 // Delay line length
99 // All pass filter length
101 // Tap 3 exists at the output of DelayE
103 // Tap 4 exists at the output of DelayF
105 // Tap 5 exists at the output of DelayG
107 // Tap 6 exists at the output of DelayH
109 // Output tap exists at the output of DelayI
111
112 // Default delay settings for left channel.
114
115 // Default delay settings for right channel.
117 };
118
119
120 // Single plate channel for plate reverberation.
122 public:
123 // InMaxNumInternalBufferSamples sets the mmaximum number of samples in an internal buffer.
125 float InSampleRate,
128
130
131 // Processing input samples. All input buffers must be of equal length.
132 // InSamples contains previously unseen audio samples.
133 // InFeedbackSamples contains the delay line output from the other plate.
134 // InDelayModulations contains the fractional delay values per a sample to modulate the first all pass filters delay line.
135 // OutPlateSamples is filled with audio from the various tap points and delay line output.
141
142 // Flush internal audio to silence.
144
148
149 // The number of samples in an internal buffer. This describes the limit of how many values
150 // are accessible via PeekDelayLineOutput(...)
152
153 // Retrieve the internal delay line data. The number of samples retrieved is limited to the
154 // number of samples in the internal buffer. That amount can be determined by calling
155 // "GetNumInternalBufferSamples()".
157
158 protected:
159 // Current parameter settings of reverb
163 float Decay;
164 float Density;
165
166 // Sample delay values
168
169 // Sample rate used for hard-coded delay line values
170 static const int32 PresetSampleRate = 29761;
171
184
188 };
189
190 // Settings for controlling the FLateReflections
192 {
193 // Milliseconds for the predelay
195
196 // Initial attenuation of audio after it leaves the predelay
198
199 // Frequency bandwidth of audio going into input diffusers. 0.999 is full bandwidth
201
202 // Amount of input diffusion (larger value results in more diffusion)
204
205 // The amount of high-frequency dampening in plate feedback paths
207
208 // The amount of decay in the feedback path. Lower value is larger reverb time.
209 float Decay;
210
211 // The amount of diffusion in decay path. Larger values is a more dense reverb.
212 float Density;
213
215
217
219 };
220
221
222 // FLateReflections generates the long tail reverb of an input audio signal using a relatively
223 // fast algorithm using all pass filter delay lines. It supports 1 or 2 channel input and always
224 // produces 2 channel output.
226 public:
227
228 // Limits on settings.
238 static SIGNALPROCESSING_API const float MaxDecay;
239 static SIGNALPROCESSING_API const float MinDecay;
242
244
245 // InMaxNumInternalBufferSamples sets the maximum possible number of samples in an internal
246 // buffer. This only affectsinternal chunking and does not affect the number of samples that
247 // can be sent to ProcessAudio(...),
249
251
252 // Copies the reverb settings internally, clamps the internal copy and applies the clamped settings.
254
255 // Alters settings to ensure they are within acceptable ranges.
257
258 // Create reverberation in OutSamples based upon InSamples.
259 // OutSamples is a 2 channel audio buffer no matter the value of InNumChannels.
260 // OutSamples is mixed with InSamples based upon gain.
262
263 // Flush internal audio to silence.
265
266 private:
267 void ProcessAudioBuffer(const float* InSampleData, const int32 InNumFrames, const int32 InNumChannels, float* OutLeftSampleData, float* OutRightSampleData);
268
269 void ApplySettings();
270
271 void GeneraterPlateModulations(const int32 InNum, FAlignedFloatBuffer& OutLeftDelays, FAlignedFloatBuffer& OutRightDelays);
272
273 float SampleRate;
274 float Gain;
275 float ModulationPhase;
276 float ModulationQuadPhase;
277 float ModulationPhaseIncrement;
278 int32 NumInternalBufferSamples;
279
280 // Current parameter settings of reverb
282
283 // Sample rate used for hard-coded delay line values
284 static const int32 PresetSampleRate = 29761;
285
286 // A simple pre-delay line to emulate large delays for late-reflections
288
289 // Input diffusion
295
296 // The plate delay data
297 FLateReflectionsPlateDelays LeftPlateDelays;
298 FLateReflectionsPlateDelays RightPlateDelays;
299
300 // The plates.
303
304 // The plate outputs
305 FLateReflectionsPlateOutputs LeftPlateOutputs;
306 FLateReflectionsPlateOutputs RightPlateOutputs;
307
308 // Buffer for delay modulation of left and right plates.
309 FAlignedFloatBuffer LeftDelayModSamples;
310 FAlignedFloatBuffer RightDelayModSamples;
311
312 FAlignedFloatBuffer WorkBufferA;
313 FAlignedFloatBuffer WorkBufferB;
314 FAlignedFloatBuffer WorkBufferC;
315
316 };
317
318}
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
Definition LateReflectionsFast.h:225
static SIGNALPROCESSING_API const float MaxLateGainDB
Definition LateReflectionsFast.h:231
SIGNALPROCESSING_API ~FLateReflectionsFast()
Definition LateReflectionsFast.cpp:347
static SIGNALPROCESSING_API void ClampSettings(FLateReflectionsFastSettings &InOutSettings)
Definition LateReflectionsFast.cpp:350
static SIGNALPROCESSING_API const float MinDecay
Definition LateReflectionsFast.h:239
static SIGNALPROCESSING_API const float MinDampening
Definition LateReflectionsFast.h:235
SIGNALPROCESSING_API void SetSettings(const FLateReflectionsFastSettings &InSettings)
Definition LateReflectionsFast.cpp:363
static SIGNALPROCESSING_API const float MinDensity
Definition LateReflectionsFast.h:241
static SIGNALPROCESSING_API const float MaxBandwidth
Definition LateReflectionsFast.h:232
static SIGNALPROCESSING_API const float MinLateDelayMsec
Definition LateReflectionsFast.h:230
static SIGNALPROCESSING_API const float MaxDampening
Definition LateReflectionsFast.h:234
static SIGNALPROCESSING_API const float MinDiffusion
Definition LateReflectionsFast.h:237
static SIGNALPROCESSING_API const float MaxDecay
Definition LateReflectionsFast.h:238
static SIGNALPROCESSING_API const float MinBandwidth
Definition LateReflectionsFast.h:233
static SIGNALPROCESSING_API const FLateReflectionsFastSettings DefaultSettings
Definition LateReflectionsFast.h:243
static SIGNALPROCESSING_API const float MaxDensity
Definition LateReflectionsFast.h:240
SIGNALPROCESSING_API void ProcessAudio(const FAlignedFloatBuffer &InSamples, const int32 InNumChannels, FAlignedFloatBuffer &OutLeftSamples, FAlignedFloatBuffer &OutRightSamples)
Definition LateReflectionsFast.cpp:370
SIGNALPROCESSING_API void FlushAudio()
Definition LateReflectionsFast.cpp:402
static SIGNALPROCESSING_API const float MaxDiffusion
Definition LateReflectionsFast.h:236
static SIGNALPROCESSING_API const float MaxLateDelayMsec
Definition LateReflectionsFast.h:229
Definition LateReflectionsFast.h:121
SIGNALPROCESSING_API void PeekDelayLine(int32 InNum, FAlignedFloatBuffer &OutSamples)
Definition LateReflectionsFast.cpp:265
SIGNALPROCESSING_API ~FLateReflectionsPlate()
Definition LateReflectionsFast.cpp:153
TUniquePtr< FIntegerDelay > DelayA
Definition LateReflectionsFast.h:173
float Dampening
Definition LateReflectionsFast.h:162
SIGNALPROCESSING_API void SetDensity(float InDensity)
Definition LateReflectionsFast.cpp:253
TUniquePtr< FIntegerDelay > DelayE
Definition LateReflectionsFast.h:179
TUniquePtr< FDynamicDelayAPF > ModulatedAPF
Definition LateReflectionsFast.h:172
float Density
Definition LateReflectionsFast.h:164
int32 NumInternalBufferSamples
Definition LateReflectionsFast.h:161
FLateReflectionsPlateDelays PlateDelays
Definition LateReflectionsFast.h:167
TUniquePtr< FIntegerDelay > DelayB
Definition LateReflectionsFast.h:174
SIGNALPROCESSING_API void SetDecay(float InDecay)
Definition LateReflectionsFast.cpp:248
SIGNALPROCESSING_API void ProcessAudioFrames(const FAlignedFloatBuffer &InSamples, const FAlignedFloatBuffer &InFeedbackSamples, const FAlignedFloatBuffer &InDelayModulations, FLateReflectionsPlateOutputs &OutPlateSamples)
Definition LateReflectionsFast.cpp:158
TUniquePtr< FBufferOnePoleLPF > LPF
Definition LateReflectionsFast.h:177
float SampleRate
Definition LateReflectionsFast.h:160
TUniquePtr< FIntegerDelay > DelayD
Definition LateReflectionsFast.h:176
float Decay
Definition LateReflectionsFast.h:163
SIGNALPROCESSING_API void FlushAudio()
Definition LateReflectionsFast.cpp:224
TUniquePtr< FIntegerDelay > DelayH
Definition LateReflectionsFast.h:182
Audio::FAlignedFloatBuffer WorkBufferC
Definition LateReflectionsFast.h:187
TUniquePtr< FLongDelayAPF > APF
Definition LateReflectionsFast.h:178
TUniquePtr< FIntegerDelay > DelayG
Definition LateReflectionsFast.h:181
TUniquePtr< FIntegerDelay > DelayF
Definition LateReflectionsFast.h:180
SIGNALPROCESSING_API void SetDampening(float InDampening)
Definition LateReflectionsFast.cpp:242
TUniquePtr< FIntegerDelay > DelayI
Definition LateReflectionsFast.h:183
SIGNALPROCESSING_API int32 GetNumInternalBufferSamples() const
Definition LateReflectionsFast.cpp:260
static const int32 PresetSampleRate
Definition LateReflectionsFast.h:170
TUniquePtr< FIntegerDelay > DelayC
Definition LateReflectionsFast.h:175
Audio::FAlignedFloatBuffer WorkBufferB
Definition LateReflectionsFast.h:186
Audio::FAlignedFloatBuffer WorkBufferA
Definition LateReflectionsFast.h:185
Definition UniquePtr.h:107
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53
Definition LateReflectionsFast.h:192
float LateDelayMsec
Definition LateReflectionsFast.h:194
SIGNALPROCESSING_API FLateReflectionsFastSettings()
Definition LateReflectionsFast.cpp:18
float Decay
Definition LateReflectionsFast.h:209
float LateGainDB
Definition LateReflectionsFast.h:197
float Dampening
Definition LateReflectionsFast.h:206
float Diffusion
Definition LateReflectionsFast.h:203
SIGNALPROCESSING_API bool operator!=(const FLateReflectionsFastSettings &Other) const
Definition LateReflectionsFast.cpp:42
float Density
Definition LateReflectionsFast.h:212
SIGNALPROCESSING_API bool operator==(const FLateReflectionsFastSettings &Other) const
Definition LateReflectionsFast.cpp:28
float Bandwidth
Definition LateReflectionsFast.h:200
Definition LateReflectionsFast.h:33
int32 NumSamplesDelayH
Definition LateReflectionsFast.h:108
int32 NumSamplesDelayI
Definition LateReflectionsFast.h:110
int32 NumSamplesDelayC
Definition LateReflectionsFast.h:96
static SIGNALPROCESSING_API FLateReflectionsPlateDelays DefaultLeftDelays(float InSampleRate)
Definition LateReflectionsFast.cpp:62
int32 NumSamplesModulatedDelta
Definition LateReflectionsFast.h:90
int32 NumSamplesDelayB
Definition LateReflectionsFast.h:94
int32 NumSamplesDelayE
Definition LateReflectionsFast.h:102
static SIGNALPROCESSING_API FLateReflectionsPlateDelays DefaultRightDelays(float InSampleRate)
Definition LateReflectionsFast.cpp:85
int32 NumSamplesDelayD
Definition LateReflectionsFast.h:98
int32 NumSamplesAPF
Definition LateReflectionsFast.h:100
int32 NumSamplesDelayG
Definition LateReflectionsFast.h:106
int32 NumSamplesDelayA
Definition LateReflectionsFast.h:92
int32 NumSamplesDelayF
Definition LateReflectionsFast.h:104
int32 NumSamplesModulatedBase
Definition LateReflectionsFast.h:88
Definition LateReflectionsFast.h:16
FAlignedFloatBuffer Taps[NumTaps]
Definition LateReflectionsFast.h:21
SIGNALPROCESSING_API void ResizeAndZero(int32 InNumSamples)
Definition LateReflectionsFast.cpp:47
static const int32 NumTaps
Definition LateReflectionsFast.h:18
FAlignedFloatBuffer Output
Definition LateReflectionsFast.h:24