DragonFftFrame Class

Value object holding one FFT visualization frame. More...

Header: #include <DragonFftFrame>
CMake: find_package(DragonMediaBackend REQUIRED COMPONENTS DragonMediaBackend)
target_link_libraries(mytarget PRIVATE DragonMediaBackend::DragonMediaBackend)

Public Functions

DragonFftFrame()
DragonFftFrame(std::span<const float> frequenciesDb, std::span<const float> barData, std::chrono::microseconds timestamp)
DragonFftFrame(const DragonFftFrame &other)
DragonFftFrame(DragonFftFrame &&other)
std::span<const float> bars() const
std::span<const float> frequencies() const
std::chrono::microseconds timestamp() const
bool operator!=(const DragonFftFrame &other) const
DragonFftFrame &operator=(DragonFftFrame &&other)
DragonFftFrame &operator=(const DragonFftFrame &other)
bool operator==(const DragonFftFrame &other) const

Static Public Members

const std::size_t NUM_BARS
const std::size_t NUM_FREQUENCIES

Detailed Description

A DragonFftFrame carries the frequency magnitudes computed by the visualization pipeline for a single point in time: 512 mel scale frequency magnitudes in dB, 24 smoothed bar magnitudes derived from them, and the timestamp of the audio they were computed from.

Instances are emitted by DragonSpectrumAnalyzer through its frameReady() signal at roughly 60fps while visualization is active.

The frame is implicitly shared, so copying one is cheap.

See also DragonSpectrumAnalyzer.

Member Function Documentation

DragonFftFrame::DragonFftFrame()

Constructs a null frame. frequencies(), bars() and timestamp() return empty and default values respectively.

DragonFftFrame::DragonFftFrame(std::span<const float> frequenciesDb, std::span<const float> barData, std::chrono::microseconds timestamp)

Constructs a frame from frequenciesDb (magnitude in dB per mel scale bin), barData (smoothed bar magnitudes) and the audio position timestamp the data was computed from.

DragonFftFrame::DragonFftFrame(const DragonFftFrame &other)

Copies other. The underlying data is implicitly shared.

[noexcept] DragonFftFrame::DragonFftFrame(DragonFftFrame &&other)

Moves other into this frame, leaving other null.

std::span<const float> DragonFftFrame::bars() const

Returns the NUM_BARS smoothed bar magnitudes.

The returned span is empty for a null frame.

std::span<const float> DragonFftFrame::frequencies() const

Returns the NUM_FREQUENCIES mel scale frequency magnitudes in dB.

The returned span is empty for a null frame.

std::chrono::microseconds DragonFftFrame::timestamp() const

Returns the position in the audio stream the frame was computed from.

bool DragonFftFrame::operator!=(const DragonFftFrame &other) const

Returns true if other describes a different frame.

[noexcept] DragonFftFrame &DragonFftFrame::operator=(DragonFftFrame &&other)

Move-assigns other into this frame, leaving other null.

DragonFftFrame &DragonFftFrame::operator=(const DragonFftFrame &other)

Assigns other to this frame. The underlying data is implicitly shared.

bool DragonFftFrame::operator==(const DragonFftFrame &other) const

Returns true if other describes the same magnitudes and timestamp as this frame.

Member Variable Documentation

const std::size_t DragonFftFrame::NUM_BARS

The number of smoothed bar magnitudes in bars().

const std::size_t DragonFftFrame::NUM_FREQUENCIES

The number of mel scale frequency magnitudes in frequencies().