FSpectrumAnalyzer

Class built to be a rolling spectrum analyzer for arbitrary, monaural audio data.

Windows
MacOS
Linux

References

Module

SignalProcessing

Header

/Engine/Source/Runtime/SignalProcessing/Public/DSP/SpectrumAnalyzer.h

Include

#include "DSP/SpectrumAnalyzer.h"

Syntax

class FSpectrumAnalyzer

Remarks

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().

Constructors

Name Description

Public function

FSpectrumAnalyzer()

If an instance is created using the default constructor, Init() must be called before it is used.

Public function

FSpectrumAnalyzer

(
    float InSampleRate
)

If an instance is created using either of these constructors, Init() is not neccessary.

Public function

FSpectrumAnalyzer

(
    const FSpectrumAnalyzerSettings& I...,
    float InSampleRate
)

Destructors

Name Description

Public function Virtual

~FSpectrumAnalyzer()

Functions

Name Description

Public function

void

 

GetBands

(
    ISpectrumBandExtractor& InExtracto...,
    TArray< float >& OutValues
)

Return array of bands using spectrum band extractor.

Public function

float

 

GetMagnitudeForFrequency

(
    float InFrequency,
    EPeakInterpolationMethod InMethod
)

Samples magnitude (linearly) for a given frequency, in Hz.

Public function

float

 

GetNormalizedMagnitudeForFrequency

(
    float InFrequency,
    EPeakInterpolationMethod InMethod
)

Public function

float

 

GetPhaseForFrequency

(
    float InFrequency,
    EPeakInterpolationMethod InMethod
)

Samples phase for a given frequency, in Hz.

Public function

void

 

GetSettings

(
    FSpectrumAnalyzerSettings& OutSett...
)

Get the current settings used by this Spectrum Analyzer.

Public function

void

 

Init

(
    const FSpectrumAnalyzerSettings& I...,
    float InSampleRate
)

Initialize sample rate of analyzer if not known at time of construction.

Public function

void

 

Init

(
    float InSampleRate
)

Initialize sample rate of analyzer if not known at time of construction.

Public function

bool

 

IsInitialized()

Returns false if this instance of FSpectrumAnalyzer was constructed with the default constructor and Init() has not been called yet.

Public function

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.

Public function

bool

 

PerformAnalysisIfPossible

(
    bool bUseLatestAudio
)

Thread safe call to perform actual FFT.

Public function

bool

 

PushAudio

(
    const TSampleBuffer< float >& InBu...
)

Push audio to queue. Returns false if the queue is already full.

Public function

bool

 

PushAudio

(
    const float* InBuffer,
    int32 NumSamples
)

Push audio to queue. Returns false if the queue is already full.

Public function

void

 

SetSettings

(
    const FSpectrumAnalyzerSettings& I...
)

Update the settings used by this Spectrum Analyzer. Safe to call on any thread, but should not be called every tick.

Public function

void

 

UnlockOutputBuffer()

Enums

Name

Description

Public enum

EPeakInterpolationMethod

Peak interpolation method.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss