Navigation
API > API/Runtime > API/Runtime/SignalProcessing > API/Runtime/SignalProcessing/DSP
References
| Module | SignalProcessing |
| Header | /Engine/Source/Runtime/SignalProcessing/Public/DSP/Dsp.h |
| Include | #include "DSP/Dsp.h" |
Syntax
class FSinOsc2DRotation
Remarks
Generates a sine wave in the given buffer with the given frequency.
Uses the method of generating a 2D point on the unit circle and multiplying with a 2d rotation matrix to advance the phase. Very accurate and very fast.
Use this unless you're changing frequency every few samples on very tiny blocks (single digit sample count)
Distortion vs directly calling FMath::Sin() is on the order of -100db, and is roughly 10x faster (for constant frequency).
Frequency changes are not interpolated across the buffer, so dramatic changes could introduce aliasing due to a discontinuous derivative in the output. If you're changing frequencies by a lot, constantly, you should probably use VectorSinCos in a loop.
Usage:
constexpr const int32 ChunkSampleCount = 480; alignas (sizeof(VectorRegister4Float)) float ChunkBuffer[ChunkSampleCount]; FSinOscBufferGenerator Generator; Generator.GenerateBuffer(48000, 400, ChunkBuffer, ChunkSampleCount);
ChunkBuffer now has 10ms of sine tone at 400hz. The next call will continue the sine tone where it left off.
Constructors
| Type | Name | Description | |
|---|---|---|---|
FSinOsc2DRotation
(
float InStartingPhaseRadians |
|||
FSinOsc2DRotation
(
FSinOsc2DRotation const& other |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | GenerateBuffer
(
float SampleRate, |
Generates the sine tone, continuing from the last phase. |
Operators
| Type | Name | Description | |
|---|---|---|---|
| FSinOsc2DRotation & | operator=
(
FSinOsc2DRotation const& other |