UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterpolatedOnePole.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4#include "CoreMinimal.h"
5#include "DSP/Dsp.h"
6
7
8namespace Audio
9{
11 {
12 public:
13 // ctor
15
16 inline float GetCutoffFrequency() const
17 {
18 return CutoffFrequency;
19 }
20
22
23 /*
24 StartFrequencyInterpolation():
25 Intended use: call once at the beginning of callback, pass the callback length
26 then call ProcessAudioFrame() exactly "InterpLength" number of times
27 At the end of the callback, call StopFrequencyInterpolation()
28
29 Failing to call StopFrequencyInterpolation() after more than InterpLength calls to ProcessAudioFrame
30 will cause the filter to become unstable and blow up to +/- inf!
31 */
33
34 // interpolates coefficient and processes a sample
36
37 // interpolates coefficient and processes a buffer
38 SIGNALPROCESSING_API void ProcessAudioBuffer(const float* RESTRICT InputBuffer, float* RESTRICT OutputBuffer, const int32 NumSamples);
39
40 // interpolates coefficient and processes a buffer
42
43 /*
44 StopFrequencyInterpolation() needs to be called manually when the interpolation should be done.
45 Snaps the coefficient to the target value.
46 Setting the lerp delta to 0.0f avoids introducing a branch in ProcessAudioFrame()
47 */
49 {
50 B1Delta = 0.0f;
51 B1Curr = B1Target;
52 }
53
54 // Resets the sample delay to 0
56
57 // Clears memory without reevaluating coefficients.
58 // This function is useful when there is a break between ProcessAudio calls.
60
61 // Apply the filter transfer function to each z-domain value in the given array (complex numbers given as interleaved floats). Passing in z-domain values on the complex unit circle will give the frequency response.
63
64 private:
65 float CutoffFrequency{ -1.0f };
66 float B1Curr{ 0.0f }; // coefficient
67 float B1Delta{ 0.0f }; // coefficient step size
68 float B1Target{ 0.0f };
69 TArray<float> Z1; // multi-channel delay terms
70 float* Z1Data{ nullptr };
71 int32 CurrInterpLength{ 0 };
72 int32 NumInterpSteps;
73 float SampleRate{ 0 };
74 int32 NumChannels{ 1 };
75 bool bIsFirstFrequencyChange{ true };
76
77 }; // class Interpolated Low pass filter
78
79
80
82 {
83 public:
84 // ctor
86
87 inline float GetCutoffFrequency() const
88 {
89 return CutoffFrequency;
90 }
91
93
94 /*
95 StartFrequencyInterpolation():
96 Intended use: call once at the beginning of callback, pass the callback length
97 then call ProcessAudioFrame() exactly "InterpLength" number of times
98 At the end of the callback, call StopFrequencyInterpolation()
99
100 Failing to call StopFrequencyInterpolation() after more than InterpLength calls to ProcessAudioFrame
101 will cause the filter to become unstable and blow up to +/- inf!
102 */
104
105 // interpolates coefficient and processes a sample
107
108 // interpolates coefficient and processes a buffer
109 SIGNALPROCESSING_API void ProcessAudioBuffer(const float* RESTRICT InputBuffer, float* RESTRICT OutputBuffer, const int32 NumSamples);
110
111 /*
112 StopFrequencyInterpolation() needs to be called manually when the interpolation should be done.
113 Snaps the coefficient to the target value.
114 Setting the lerp delta to 0.0f avoids introducing a branch in ProcessAudioFrame()
115 */
117 {
118 A0Delta = 0.0f;
119 A0Curr = A0Target;
120 }
121
122 // Resets the sample delay to 0
124
125 // Clears memory without reevaluating coefficients.
126 // This function is useful when there is a break between ProcessAudio calls.
128
129 // Apply the filter transfer function to each z-domain value in the given array (complex numbers given as interleaved floats). Passing in z-domain values on the complex unit circle will give the frequency response.
131
132 private:
133 float CutoffFrequency{ -1.0f };
134 float A0Curr{ 0.0f }; // coefficient
135 float A0Delta{ 0.0f }; // coefficient step size
136 float A0Target{ 0.0f };
137 TArray<float> Z1; // multi-channel delay terms
138 float* Z1Data{ nullptr };
139 int32 CurrInterpLength{ 0 };
140 int32 NumInterpSteps;
141 float SampleRate{ 0 };
142 float NyquistLimit{ 0.0f };
143 int32 NumChannels{ 1 };
144 bool bIsFirstFrequencyChange{ true };
145
146 }; // class Interpolated High pass filter
147} // namespace Audio
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
void Init()
Definition LockFreeList.h:4
char const * InputBuffer
Definition binka_ue_decode_test.cpp:29
Definition InterpolatedOnePole.h:82
SIGNALPROCESSING_API void Reset()
Definition InterpolatedOnePole.cpp:483
float GetCutoffFrequency() const
Definition InterpolatedOnePole.h:87
SIGNALPROCESSING_API FInterpolatedHPF()
Definition InterpolatedOnePole.cpp:313
SIGNALPROCESSING_API void ClearMemory()
Definition InterpolatedOnePole.cpp:493
SIGNALPROCESSING_API void ProcessAudioFrame(const float *RESTRICT InputFrame, float *RESTRICT OutputFrame)
Definition InterpolatedOnePole.cpp:359
void StopFrequencyInterpolation()
Definition InterpolatedOnePole.h:116
SIGNALPROCESSING_API void StartFrequencyInterpolation(const float InTargetFrequency, const int32 InterpLength=1)
Definition InterpolatedOnePole.cpp:329
SIGNALPROCESSING_API void ArrayCalculateResponseInPlace(TArrayView< float > InOutComplexValues) const
Definition InterpolatedOnePole.cpp:499
SIGNALPROCESSING_API void ProcessAudioBuffer(const float *RESTRICT InputBuffer, float *RESTRICT OutputBuffer, const int32 NumSamples)
Definition InterpolatedOnePole.cpp:374
Definition InterpolatedOnePole.h:11
float GetCutoffFrequency() const
Definition InterpolatedOnePole.h:16
SIGNALPROCESSING_API void ClearMemory()
Definition InterpolatedOnePole.cpp:285
SIGNALPROCESSING_API void StartFrequencyInterpolation(const float InTargetFrequency, const int32 InterpLength=1)
Definition InterpolatedOnePole.cpp:28
void StopFrequencyInterpolation()
Definition InterpolatedOnePole.h:48
SIGNALPROCESSING_API void ProcessAudioBuffer(const float *RESTRICT InputBuffer, float *RESTRICT OutputBuffer, const int32 NumSamples)
Definition InterpolatedOnePole.cpp:78
SIGNALPROCESSING_API void ArrayCalculateResponseInPlace(TArrayView< float > InOutComplexValues) const
Definition InterpolatedOnePole.cpp:291
SIGNALPROCESSING_API void ProcessBufferInPlace(float *InOutBuffer, int32 NumSamples)
Definition InterpolatedOnePole.cpp:176
SIGNALPROCESSING_API FInterpolatedLPF()
Definition InterpolatedOnePole.cpp:13
SIGNALPROCESSING_API void ProcessAudioFrame(const float *RESTRICT InputFrame, float *RESTRICT OutputFrame)
Definition InterpolatedOnePole.cpp:53
SIGNALPROCESSING_API void Reset()
Definition InterpolatedOnePole.cpp:274
Definition ArrayView.h:139
Definition Array.h:670
NO_LOGGING.
Definition AudioMixerPlatformAndroid.cpp:53