Video display and composing engine for JUCE
Loading...
Searching...
No Matches
LevelMeterSource Class Reference

To get a meter GUI create a LevelMeterSource in your AudioProcessor or whatever instance processes an AudioBuffer. More...

#include <LevelMeterSource.h>

Public Member Functions

 LevelMeterSource ()
 
 ~LevelMeterSource ()
 
void resize (const int channels, const int rmsWindow)
 Resize the meters data containers.
 
template<typename FloatType >
void measureBlock (const juce::AudioBuffer< FloatType > &buffer)
 Call this method to measure a block af levels to be displayed in the meters.
 
void decayIfNeeded ()
 This is called from the GUI.
 
void setReductionLevel (const int channel, const float reduction)
 With the reduction level you can add an extra bar do indicate, by what amount the level was reduced.
 
void setReductionLevel (const float reduction)
 With the reduction level you can add an extra bar do indicate, by what amount the level was reduced.
 
void setMaxHoldMS (const juce::int64 millis)
 Set the timeout, how long the peak line will be displayed, before it resets to the current peak.
 
float getReductionLevel (const int channel) const
 Returns the reduction level.
 
float getMaxLevel (const int channel) const
 This is the max level as displayed by the little line above the RMS bar.
 
float getMaxOverallLevel (const int channel) const
 This is the max level as displayed under the bar as number.
 
float getRMSLevel (const int channel) const
 This is the RMS level that the bar will indicate.
 
bool getClipFlag (const int channel) const
 Returns the status of the clip flag.
 
void clearClipFlag (const int channel)
 Reset the clip flag to reset the indicator in the meter.
 
void clearAllClipFlags ()
 
void clearMaxNum (const int channel)
 Reset the max number to minus infinity.
 
void clearAllMaxNums ()
 Reset all max numbers.
 
int getNumChannels () const
 Get the number of channels to be displayed.
 
void setSuspended (const bool shouldBeSuspended)
 The measure can be suspended, e.g.
 
bool checkNewDataFlag () const
 
void resetNewDataFlag ()
 

Detailed Description

To get a meter GUI create a LevelMeterSource in your AudioProcessor or whatever instance processes an AudioBuffer.

Then call LevelMeterSource::measureBlock (AudioBuffer<float>& buf) to create the readings.

Constructor & Destructor Documentation

◆ LevelMeterSource()

◆ ~LevelMeterSource()

Member Function Documentation

◆ resize()

void resize ( const int  channels,
const int  rmsWindow 
)

Resize the meters data containers.

Set the

Parameters
numChannelsto the number of channels. If you don't do this in prepareToPlay, it will be done when calling measureBlock, but a few bytes will be allocated on the audio thread, so be aware.
rmsWindowis the number of rms values to gather. Keep that aligned with the sampleRate and the blocksize to get reproducable results. e.g. rmsWindow = msecs * 0.001f * sampleRate / blockSize;

◆ measureBlock()

template<typename FloatType >
void measureBlock ( const juce::AudioBuffer< FloatType > &  buffer)

Call this method to measure a block af levels to be displayed in the meters.

◆ decayIfNeeded()

void decayIfNeeded ( )

This is called from the GUI.

If processing was stalled, this will pump zeroes into the buffer, until the readings return to zero.

◆ setReductionLevel() [1/2]

void setReductionLevel ( const int  channel,
const float  reduction 
)

With the reduction level you can add an extra bar do indicate, by what amount the level was reduced.

This will be printed on top of the bar with half the width.

Parameters
channelthe channel index, that was reduced
reductionthe factor for the reduction applied to the channel, 1.0=no reduction, 0.0=block completely

◆ setReductionLevel() [2/2]

void setReductionLevel ( const float  reduction)

With the reduction level you can add an extra bar do indicate, by what amount the level was reduced.

This will be printed on top of the bar with half the width.

Parameters
reductionthe factor for the reduction applied to all channels, 1.0=no reduction, 0.0=muted completely

◆ setMaxHoldMS()

void setMaxHoldMS ( const juce::int64  millis)

Set the timeout, how long the peak line will be displayed, before it resets to the current peak.

◆ getReductionLevel()

float getReductionLevel ( const int  channel) const

Returns the reduction level.

This value is not computed but can be set manually via

See also
setReductionLevel.

Referenced by drawMeterBars(), and drawMeterChannel().

◆ getMaxLevel()

float getMaxLevel ( const int  channel) const

This is the max level as displayed by the little line above the RMS bar.

It is reset by

See also
setMaxHoldMS.

Referenced by drawMeterBars(), and drawMeterChannel().

◆ getMaxOverallLevel()

float getMaxOverallLevel ( const int  channel) const

This is the max level as displayed under the bar as number.

It will stay up until

See also
clearMaxNum was called.

Referenced by drawMeterBars(), and drawMeterChannel().

◆ getRMSLevel()

float getRMSLevel ( const int  channel) const

This is the RMS level that the bar will indicate.

It is summed over rmsWindow number of blocks/measureBlock calls.

Referenced by drawMeterBars(), and drawMeterChannel().

◆ getClipFlag()

bool getClipFlag ( const int  channel) const

Returns the status of the clip flag.

Referenced by drawMeterBars(), and drawMeterChannel().

◆ clearClipFlag()

void clearClipFlag ( const int  channel)

Reset the clip flag to reset the indicator in the meter.

◆ clearAllClipFlags()

void clearAllClipFlags ( )

◆ clearMaxNum()

void clearMaxNum ( const int  channel)

Reset the max number to minus infinity.

◆ clearAllMaxNums()

void clearAllMaxNums ( )

Reset all max numbers.

◆ getNumChannels()

int getNumChannels ( ) const

Get the number of channels to be displayed.

Referenced by drawMeterBars(), hitTestClipIndicator(), and hitTestMaxNumber().

◆ setSuspended()

void setSuspended ( const bool  shouldBeSuspended)

The measure can be suspended, e.g.

to save CPU when no meter is displayed. In this case, the

See also
measureBlock will return immediately

◆ checkNewDataFlag()

bool checkNewDataFlag ( ) const

◆ resetNewDataFlag()

void resetNewDataFlag ( )

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