Navigation
API > API/Runtime > API/Runtime/SignalProcessing
Class built to be a rolling spectrum analyzer for arbitrary, monaural audio data. Class is meant to scale accuracy with CPU and memory budgets. Typical usage is to either call PushAudio() and then PerformAnalysisIfPossible immediately afterwards, or have a seperate thread call PerformAnalysisIfPossible().
| Name | FSpectrumAnalyzer |
| Type | class |
| Header File | /Engine/Source/Runtime/SignalProcessing/Public/DSP/SpectrumAnalyzer.h |
| Include Path | #include "DSP/SpectrumAnalyzer.h" |
Syntax
class FSpectrumAnalyzer
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FSpectrumAnalyzer
(
const FSpectrumAnalyzerSettings& InSettings, |
DSP/SpectrumAnalyzer.h | ||
FSpectrumAnalyzer
(
float InSampleRate |
If an instance is created using either of these constructors, Init() is not neccessary. | DSP/SpectrumAnalyzer.h | |
| If an instance is created using the default constructor, Init() must be called before it is used. | DSP/SpectrumAnalyzer.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FSpectrumAnalyzer() |
DSP/SpectrumAnalyzer.h |
Enums
Public
| Name | Remarks |
|---|---|
| EPeakInterpolationMethod | Peak interpolation method. |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| AnalysisTimeDomainBuffer | FAlignedFloatBuffer | DSP/SpectrumAnalyzer.h | ||
| bIsInitialized | volatile bool | DSP/SpectrumAnalyzer.h | ||
| bSettingsWereUpdated | volatile bool | DSP/SpectrumAnalyzer.h | ||
| CurrentSettings | FSpectrumAnalyzerSettings | Cached current settings. Only actually used in ResetSettings(). | DSP/SpectrumAnalyzer.h | |
| FFT | TUniquePtr< IFFTAlgorithm > | DSP/SpectrumAnalyzer.h | ||
| FFTScaling | EFFTScaling | DSP/SpectrumAnalyzer.h | ||
| FFTSize | int32 | DSP/SpectrumAnalyzer.h | ||
| FrequencyBuffer | FSpectrumAnalyzerBuffer | DSP/SpectrumAnalyzer.h | ||
| HopInSamples | int32 | DSP/SpectrumAnalyzer.h | ||
| InputQueue | TCircularAudioBuffer< float > | DSP/SpectrumAnalyzer.h | ||
| LockedBufferTimestamp | double | If non-null, owns pointer to locked frequency vector we're using. | DSP/SpectrumAnalyzer.h | |
| LockedFrequencyVector | const FAlignedFloatBuffer * | DSP/SpectrumAnalyzer.h | ||
| SampleCounter | FThreadSafeCounter | DSP/SpectrumAnalyzer.h | ||
| SampleRate | float | DSP/SpectrumAnalyzer.h | ||
| Window | FWindow | Cached window that is applied prior to running the FFT. | DSP/SpectrumAnalyzer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void GetBands
(
ISpectrumBandExtractor& InExtractor, |
Return array of bands using spectrum band extractor. | DSP/SpectrumAnalyzer.h | |
float GetMagnitudeForFrequency
(
float InFrequency, |
Samples magnitude (linearly) for a given frequency, in Hz. | DSP/SpectrumAnalyzer.h | |
float GetNormalizedMagnitudeForFrequency
(
float InFrequency, |
DSP/SpectrumAnalyzer.h | ||
float GetPhaseForFrequency
(
float InFrequency, |
Samples phase for a given frequency, in Hz. | DSP/SpectrumAnalyzer.h | |
void GetSettings
(
FSpectrumAnalyzerSettings& OutSettings |
Get the current settings used by this Spectrum Analyzer. | DSP/SpectrumAnalyzer.h | |
void Init
(
const FSpectrumAnalyzerSettings& InSettings, |
DSP/SpectrumAnalyzer.h | ||
void Init
(
float InSampleRate |
Initialize sample rate of analyzer if not known at time of construction. | DSP/SpectrumAnalyzer.h | |
bool IsInitialized() |
Returns false if this instance of FSpectrumAnalyzer was constructed with the default constructor and Init() has not been called yet. | DSP/SpectrumAnalyzer.h | |
void LockOutputBuffer () |
You can call this function to ensure that you're sampling the same window of frequency data, Then call UnlockOutputBuffer when you're done. | DSP/SpectrumAnalyzer.h | |
bool PerformAnalysisIfPossible
(
bool bUseLatestAudio |
Thread safe call to perform actual FFT. | DSP/SpectrumAnalyzer.h | |
bool PushAudio
(
const TSampleBuffer< float >& InBuffer |
Push audio to queue. Returns false if the queue is already full. | DSP/SpectrumAnalyzer.h | |
bool PushAudio
(
const float* InBuffer, |
DSP/SpectrumAnalyzer.h | ||
void SetSettings
(
const FSpectrumAnalyzerSettings& InSettings |
Update the settings used by this Spectrum Analyzer. Safe to call on any thread, but should not be called every tick. | DSP/SpectrumAnalyzer.h | |
void UnlockOutputBuffer() |
DSP/SpectrumAnalyzer.h |