VCV Rack API v2
Loading...
Searching...
No Matches
rack::dsp::VuMeter2 Struct Reference

Models a VU meter with smoothing. More...

#include <vumeter.hpp>

Public Types

enum  Mode { PEAK , RMS }
 

Public Member Functions

void reset ()
 
void process (float deltaTime, float value)
 
float getBrightness (float dbMin, float dbMax)
 Returns the LED brightness measuring tick marks between dbMin and dbMax.
 

Public Attributes

Mode mode = PEAK
 
float v = 0.f
 Either the smoothed peak or the mean-square of the brightness, depending on the mode.
 
float lambda = 30.f
 Inverse time constant in 1/seconds.
 

Detailed Description

Models a VU meter with smoothing.

Supports peak and RMS (root-mean-square) metering. Usage example for a strip of lights with 3dB increments:

// Update VuMeter state every frame.
vuMeter.process(deltaTime, output);
// Iterate lights every ~512 frames (less than a screen refresh).
for (int i = 0; i < 6; i++) {
float b = vuMeter.getBrightness(-3.f * (i + 1), -3.f * i);
// No need to use setSmoothBrightness() since VuMeter2 smooths the value for you.
lights[i].setBrightness(b);
}

Member Enumeration Documentation

◆ Mode

Enumerator
PEAK 
RMS 

Member Function Documentation

◆ reset()

void rack::dsp::VuMeter2::reset ( )
inline

◆ process()

void rack::dsp::VuMeter2::process ( float deltaTime,
float value )
inline

◆ getBrightness()

float rack::dsp::VuMeter2::getBrightness ( float dbMin,
float dbMax )
inline

Returns the LED brightness measuring tick marks between dbMin and dbMax.

For example, getBrightness(-6.f, 0.f) will be at minimum brightness at -6dB and maximum brightness at 0dB. Set dbMin == dbMax == 0.f for a clip indicator that turns fully on when db >= dbMax. Expensive, so call this infrequently.

Member Data Documentation

◆ mode

Mode rack::dsp::VuMeter2::mode = PEAK

◆ v

float rack::dsp::VuMeter2::v = 0.f

Either the smoothed peak or the mean-square of the brightness, depending on the mode.

◆ lambda

float rack::dsp::VuMeter2::lambda = 30.f

Inverse time constant in 1/seconds.


The documentation for this struct was generated from the following file: