DragonSpectrumAnalyzer Class

Control surface for the FFT visualization stream. More...

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

Public Types

enum class Mode { Off, BarsOnly, DetailedOnly, Both }

Properties

Public Functions

DragonSpectrumAnalyzer(DragonPlayer *player, QObject *parent = nullptr)
int frameRate() const
bool isActive() const
DragonSpectrumAnalyzer::Mode mode() const

Public Slots

void setFrameRate(int framesPerSecond)
void setMode(DragonSpectrumAnalyzer::Mode mode)

Signals

void activeChanged(bool active)
void frameRateChanged(int rate)
void frameReady(const DragonFftFrame &frame)
void modeChanged(DragonSpectrumAnalyzer::Mode mode)

Detailed Description

DragonSpectrumAnalyzer gives applications access to the spectrum data computed by the visualization stage of a DragonPlayer pipeline. While active, it emits frameReady() with DragonFftFrame values at the configured frame rate, typically 60fps, which can drive bar and spectrogram visualizers.

The analyzer is inactive unless mode() selects a visualization mode, so applications that do not visualize audio pay no FFT cost.

See also DragonPlayer and DragonFftFrame.

Member Type Documentation

enum class DragonSpectrumAnalyzer::Mode

The visualization data to deliver.

ConstantValueDescription
DragonSpectrumAnalyzer::Mode::Off0No visualization data is computed.
DragonSpectrumAnalyzer::Mode::BarsOnly1Only the smoothed bar magnitudes are delivered.
DragonSpectrumAnalyzer::Mode::DetailedOnly2Only the detailed frequency magnitudes are delivered.
DragonSpectrumAnalyzer::Mode::Both3Both bars and detailed magnitudes are delivered.

Property Documentation

[read-only] active : bool

Whether frames are currently being emitted. This is true when the mode is not Off and the player pipeline is running.

Access functions:

bool isActive() const

Notifier signal:

void activeChanged(bool active)

frameRate : int

The target number of frames delivered per second. Clamped to the range supported by the pipeline.

Access functions:

int frameRate() const
void setFrameRate(int framesPerSecond)

Notifier signal:

void frameRateChanged(int rate)

mode : Mode

Which parts of the frame data are computed and delivered. Setting the mode to Off deactivates the analyzer.

Access functions:

DragonSpectrumAnalyzer::Mode mode() const
void setMode(DragonSpectrumAnalyzer::Mode mode)

Notifier signal:

void modeChanged(DragonSpectrumAnalyzer::Mode mode)

Member Function Documentation

[explicit] DragonSpectrumAnalyzer::DragonSpectrumAnalyzer(DragonPlayer *player, QObject *parent = nullptr)

Constructs an analyzer for the pipeline of player, with parent as its QObject parent. The analyzer starts in the Off mode.

[signal] void DragonSpectrumAnalyzer::activeChanged(bool active)

Emitted when frame emission starts or stops, with the new state in active.

Note: Notifier signal for property active.

int DragonSpectrumAnalyzer::frameRate() const

Returns the target frame rate in frames per second.

Note: Getter function for property frameRate.

See also setFrameRate().

[signal] void DragonSpectrumAnalyzer::frameRateChanged(int rate)

Emitted when the target frame rate changes to rate.

Note: Notifier signal for property frameRate.

[signal] void DragonSpectrumAnalyzer::frameReady(const DragonFftFrame &frame)

Emitted while the analyzer is active, delivering one frame of spectrum data at the configured frame rate.

bool DragonSpectrumAnalyzer::isActive() const

Returns true if frames are currently being emitted.

Note: Getter function for property active.

DragonSpectrumAnalyzer::Mode DragonSpectrumAnalyzer::mode() const

Returns the visualization mode.

Note: Getter function for property mode.

See also setMode().

[signal] void DragonSpectrumAnalyzer::modeChanged(DragonSpectrumAnalyzer::Mode mode)

Emitted when the visualization mode changes to mode.

Note: Notifier signal for property mode.

[slot] void DragonSpectrumAnalyzer::setFrameRate(int framesPerSecond)

Sets the target frame rate to framesPerSecond.

Note: Setter function for property frameRate.

See also frameRate().

[slot] void DragonSpectrumAnalyzer::setMode(DragonSpectrumAnalyzer::Mode mode)

Sets the visualization mode to mode. Setting Off stops frame emission, any other value starts it.

Note: Setter function for property mode.

See also mode().