class Core::AudioMeterBallistics

Overview

GUI-side audio meter ballistics: turns a raw, undecayed (linear) AudioMeterData snapshot into smoothly-falling peak, RMS and peak hold levels in dB plus a held clip state. More…

#include <coreaudiometerballistics.h>

class AudioMeterBallistics
{
public:
    // fields

    static constexpr float kDefaultPeakDecayRate = 20.f;
    static constexpr TSeconds kDefaultRMSSmoothingTime = 0.2;
    static constexpr TSeconds kDefaultClipHoldTime = 1.5;
    static constexpr TSeconds kDefaultPeakHoldTime = 2.0;
    static constexpr TSeconds kInfiniteHold = -1.;

    // methods

    bool setChannelCount(int channelCount);
    bool reset();
    bool update(const AudioMeterData& rawData, TSeconds elapsedSeconds);
    bool resetHolds();
    int getChannelCount() const;
    float getPeakLevelDb(int channel) const;
    float getRMSLevelDb(int channel) const;
    float getPeakHoldLevelDb(int channel) const;
    bool isClipped(int channel) const;
    uint32 getClipState() const;
    void setPeakDecayRate(float dbPerSecond);
    void setRMSSmoothingTime(TSeconds seconds);
    void setClipHoldTime(TSeconds seconds);
    void setPeakHoldTime(TSeconds seconds);
    bool isRMSEnabled() const;
    void setRMSEnabled(bool state);
    bool isClipEnabled() const;
    void setClipEnabled(bool state);
    bool isPeakHoldEnabled() const;
    void setPeakHoldEnabled(bool state);
};

Detailed Documentation

GUI-side audio meter ballistics: turns a raw, undecayed (linear) AudioMeterData snapshot into smoothly-falling peak, RMS and peak hold levels in dB plus a held clip state.

RMS, clip and peak hold are each individually enabled/disabled (off by default).

Fields

static constexpr float kDefaultPeakDecayRate = 20.f

dB/sec, classic peak-meter fall rate

static constexpr TSeconds kDefaultRMSSmoothingTime = 0.2

one-pole, much lighter than peak hold

static constexpr TSeconds kInfiniteHold = -1.

never auto-release; call resetHolds () to clear

Methods

bool update(const AudioMeterData& rawData, TSeconds elapsedSeconds)

Feed one freshly-read raw snapshot plus real elapsed time since the previous call.

Returns true if any channel’s peak/RMS/clip/peak-hold state changed as a result.

bool resetHolds()

Clear both clip-hold and peak-hold state back to silence/off.

Does not affect live peak/RMS.

uint32 getClipState() const

bit field, one bit per channel