Sound Meter 0.9.0
Fully resizing logarithmic JUCE meter module.
Loading...
Searching...
No Matches
sd::SoundMeter::Level Class Referencefinal

Class responsible for anything relating to the 'meter' and peak 'value' parts. More...

#include <sd_MeterLevel.h>

Public Member Functions

 Level ()
 Constructor. More...
 
void reset ()
 Reset the meter (but not the peak hold). More...
 
void setInputLevel (float newLevel)
 Set the level of the meter. More...
 
float getInputLevel ()
 Get's the meter's input level. More...
 
void refreshMeterLevel ()
 Calculate the actual meter level (ballistics included). More...
 
float getMeterLevel () const noexcept
 Get the actual meter's level (including ballistics). More...
 
void setMeterOptions (const Options &meterOptions)
 Set the meter's options. More...
 
bool isPeakValueVisible () const noexcept
 Check if the peak 'value' part is visible. More...
 
void resetPeakHold ()
 Reset the peak hold level. More...
 
float getPeakHoldLevel () const noexcept
 Get the current peak hold level. More...
 
void setMinimalMode (bool minimalMode)
 Set the meter in 'minimal' mode. More...
 
void setRefreshRate (float refreshRate_hz)
 Sets the meter's refresh rate. More...
 
float getRefreshRate () const noexcept
 Get the meter's refresh (redraw) rate. More...
 
void setDecay (float decay_ms)
 Set meter decay. More...
 
float getDecay () const noexcept
 Get meter decay. More...
 
void setMeterSegments (const std::vector< SegmentOptions > &segmentsOptions)
 Set the segments the meter is made out of. More...
 
void setIsLabelStrip (bool isLabelStrip=false) noexcept
 Set whether this meter is a label strip. More...
 
void setMeterBounds (const juce::Rectangle< int > &bounds)
 Set the bounds of the 'meter' part of the meter. More...
 
juce::Rectangle< int > getValueBounds () const noexcept
 Get the bounds of the 'value' part of the meter. More...
 
juce::Rectangle< int > getMeterBounds () const noexcept
 Get the bounds of the 'meter' part. More...
 
juce::Rectangle< int > getLevelBounds () const noexcept
 Get the bounds of the 'level' part. More...
 
juce::Rectangle< int > getDirtyBounds ()
 Get the dirty part of the meter. More...
 
bool isMouseOverValue (int y)
 Check if the mouse cursor is over the 'value' part of the meter. More...
 
bool isMouseOverValue () const noexcept
 Check if the mouse cursor is over the 'value' part of the meter. More...
 
void resetMouseOverValue () noexcept
 Reset 'mouse over' status of the 'value' part of the meter. More...
 
void drawMeter (juce::Graphics &g, const MeterColours &meterColours)
 Draws the meter. More...
 
void drawInactiveMeter (juce::Graphics &g, const MeterColours &meterColours) const
 Draw the 'meter' part in it's inactive (muted) state. More...
 
void drawPeakValue (juce::Graphics &g, const MeterColours &meterColours) const
 Draw the peak 'value'. More...
 

Detailed Description

Class responsible for anything relating to the 'meter' and peak 'value' parts.

This also includes the peak hold indicator and the tick-marks.

Constructor & Destructor Documentation

◆ Level()

sd::SoundMeter::Level::Level ( )

Constructor.

References setMeterSegments().

Member Function Documentation

◆ reset()

void sd::SoundMeter::Level::reset ( )

Reset the meter (but not the peak hold).

See also
resetPeakHold

References sd::SoundMeter::Constants::kMinLevel_db.

Referenced by sd::SoundMeter::MeterChannel::reset().

◆ setInputLevel()

void sd::SoundMeter::Level::setInputLevel ( float  newLevel)

Set the level of the meter.

Here the level is actually set from the audio engine. Beware: very likely called from the audio thread!

Parameters
newLevelThe peak level from the audio engine (in amp).
See also
getInputLevel

Referenced by sd::SoundMeter::MeterChannel::setInputLevel().

◆ getInputLevel()

float sd::SoundMeter::Level::getInputLevel ( )

Get's the meter's input level.

Returns
The meter's input level (in decibels).
See also
setInputLevel

Referenced by refreshMeterLevel().

◆ refreshMeterLevel()

void sd::SoundMeter::Level::refreshMeterLevel ( )

Calculate the actual meter level (ballistics included).

Calculate the meter's level including ballistics. Instant attack, but decayed release.

See also
getMeterLevel, setDecay

References getInputLevel(), and getPeakHoldLevel().

Referenced by sd::SoundMeter::MeterChannel::refresh().

◆ getMeterLevel()

float sd::SoundMeter::Level::getMeterLevel ( ) const
noexcept

Get the actual meter's level (including ballistics).

Get the decayed meter level. Instant attack, but decayed release.

Returns
The actual meter's level (in decibels) with ballistics.
See also
setMeterLevel, setDecay

◆ setMeterOptions()

void sd::SoundMeter::Level::setMeterOptions ( const Options meterOptions)

Set the meter's options.

The options determine the appearance and functionality of the meter.

Parameters
meterOptionsMeter options to use.

Referenced by sd::SoundMeter::MeterChannel::setOptions().

◆ isPeakValueVisible()

bool sd::SoundMeter::Level::isPeakValueVisible ( ) const
noexcept

Check if the peak 'value' part is visible.

The peak value will be shown below the meter (in db). It's the same level as the peak hold bar.

Returns
True, if the peak hold 'value' part is visible.
See also
showValue, resetPeakHold

◆ resetPeakHold()

void sd::SoundMeter::Level::resetPeakHold ( )

Reset the peak hold level.

See also
getPeakHoldLevel, isPeakValueVisible, setPeakValueVisible, showPeakHold, showValue, isPeakHoldEnabled

Referenced by sd::SoundMeter::MeterChannel::resetPeakHold().

◆ getPeakHoldLevel()

float sd::SoundMeter::Level::getPeakHoldLevel ( ) const
noexcept

Get the current peak hold level.

Returns
The current peak hold level (in decibels).
See also
resetPeakHold, isPeakValueVisible, setPeakValueVisible, setPeakHoldVisible, isPeakHoldEnabled

References sd::SoundMeter::Constants::kMinLevel_db.

Referenced by drawPeakValue(), and refreshMeterLevel().

◆ setMinimalMode()

void sd::SoundMeter::Level::setMinimalMode ( bool  minimalMode)

Set the meter in 'minimal' mode.

In minimal mode, the meter is in it's cleanest state possible. This means no header, no tick-marks, no value, no faders and no indicator.

Parameters
minimalModeWhen set to true, 'minimal' mode will be enabled.
See also
isMinimalModeActive, autoSetMinimalMode

References setMeterBounds().

Referenced by sd::SoundMeter::MeterChannel::setMinimalMode().

◆ setRefreshRate()

void sd::SoundMeter::Level::setRefreshRate ( float  refreshRate_hz)

Sets the meter's refresh rate.

Set this to optimize the meter's decay rate.

Parameters
refreshRate_hzRefresh rate in Hz.
See also
refresh, setDecay, getDecay

References sd::SoundMeter::Options::refreshRate.

Referenced by sd::SoundMeter::MeterChannel::setRefreshRate().

◆ getRefreshRate()

float sd::SoundMeter::Level::getRefreshRate ( ) const
noexcept

Get the meter's refresh (redraw) rate.

Returns
The refresh rate of the meter in Hz.
See also
setRefreshRate

References sd::SoundMeter::Options::refreshRate.

◆ setDecay()

void sd::SoundMeter::Level::setDecay ( float  decay_ms)

Set meter decay.

Parameters
decay_msMeter decay in milliseconds.
See also
getDecay, setRefreshRate

References sd::SoundMeter::Options::decayTime_ms.

Referenced by sd::SoundMeter::MeterChannel::setDecay().

◆ getDecay()

float sd::SoundMeter::Level::getDecay ( ) const
noexcept

Get meter decay.

Returns
Meter decay in milliseconds
See also
setDecay

References sd::SoundMeter::Options::decayTime_ms.

Referenced by sd::SoundMeter::MeterChannel::getDecay().

◆ setMeterSegments()

void sd::SoundMeter::Level::setMeterSegments ( const std::vector< SegmentOptions > &  segmentsOptions)

Set the segments the meter is made out of.

All segments have a level range, a range within the meter and a colour (or gradient).

Parameters
segmentsOptionsThe segments options to create the segments with.

Referenced by Level(), and sd::SoundMeter::MeterChannel::setMeterSegments().

◆ setIsLabelStrip()

void sd::SoundMeter::Level::setIsLabelStrip ( bool  isLabelStrip = false)
noexcept

Set whether this meter is a label strip.

A label strip only draws the value labels (at the tick-marks), but does not display any level.

Parameters
isLabelStripwhen set, this meter behave like a label strip.

◆ setMeterBounds()

void sd::SoundMeter::Level::setMeterBounds ( const juce::Rectangle< int > &  bounds)

Set the bounds of the 'meter' part of the meter.

Parameters
boundsThe bounds to use for the 'meter' part of the meter.
See also
getValueBounds, setValueBounds, getMeterBounds, getDirtyBounds, getLevelBounds

References sd::SoundMeter::Constants::kDefaultHeaderHeight, and sd::SoundMeter::Options::valueEnabled.

Referenced by sd::SoundMeter::MeterChannel::resized(), and setMinimalMode().

◆ getValueBounds()

juce::Rectangle< int > sd::SoundMeter::Level::getValueBounds ( ) const
noexcept

Get the bounds of the 'value' part of the meter.

Returns
The bounds of the 'value' part of the meter.
See also
setMeterBounds, setValueBounds, getMeterBounds, getDirtyBounds, getLevelBounds

◆ getMeterBounds()

juce::Rectangle< int > sd::SoundMeter::Level::getMeterBounds ( ) const
noexcept

Get the bounds of the 'meter' part.

Returns
The bounds of the 'meter' part.
See also
getValueBounds, setValueBounds, setMeterBounds, getDirtyBounds, getLevelBounds

Referenced by sd::SoundMeter::MeterChannel::getLabelStripBounds(), and sd::SoundMeter::MeterChannel::refresh().

◆ getLevelBounds()

juce::Rectangle< int > sd::SoundMeter::Level::getLevelBounds ( ) const
noexcept

Get the bounds of the 'level' part.

Returns
The bounds of the 'level' part.
See also
getValueBounds, setValueBounds, setMeterBounds, getDirtyBounds, getMeterBounds

Referenced by sd::SoundMeter::MeterChannel::resized().

◆ getDirtyBounds()

juce::Rectangle< int > sd::SoundMeter::Level::getDirtyBounds ( )

Get the dirty part of the meter.

Referenced by sd::SoundMeter::MeterChannel::refresh().

◆ isMouseOverValue() [1/2]

bool sd::SoundMeter::Level::isMouseOverValue ( int  y)

Check if the mouse cursor is over the 'value' part of the meter.

Parameters
yThe y coordinate (relative to the meter bounds) to use to determine if the mouse if over the 'value' part of the meter.
Returns
True, if the mouse cursor is over the 'value' part of the meter.

◆ isMouseOverValue() [2/2]

bool sd::SoundMeter::Level::isMouseOverValue ( ) const
noexcept

Check if the mouse cursor is over the 'value' part of the meter.

Returns
True, if the mouse cursor is over the 'value' part of the meter.

◆ resetMouseOverValue()

void sd::SoundMeter::Level::resetMouseOverValue ( )
noexcept

Reset 'mouse over' status of the 'value' part of the meter.

◆ drawMeter()

void sd::SoundMeter::Level::drawMeter ( juce::Graphics &  g,
const MeterColours meterColours 
)

Draws the meter.

Parameters
[in,out]gThe juce graphics context to use.
meterColoursThe colours to use to draw the meter.
See also
drawInactiveMeter, drawPeakValue, drawPeakHold, drawTickMarks, drawLabels

◆ drawInactiveMeter()

void sd::SoundMeter::Level::drawInactiveMeter ( juce::Graphics &  g,
const MeterColours meterColours 
) const

Draw the 'meter' part in it's inactive (muted) state.

Parameters
[in,out]gThe juce graphics context to use.
meterColoursThe colours to use to draw the meter.
See also
drawMeter, drawTickMarks, drawPeakValue, drawPeakHold, drawLabels

References sd::SoundMeter::MeterColours::textColour.

◆ drawPeakValue()

void sd::SoundMeter::Level::drawPeakValue ( juce::Graphics &  g,
const MeterColours meterColours 
) const

Draw the peak 'value'.

Parameters
[in,out]gThe juce graphics context to use.
meterColoursThe colours to use to draw the meter.
See also
drawMeter, drawInactiveMeter, drawInactiveMeter, drawPeakHold, drawTickMarks, drawLabels

References getPeakHoldLevel(), and sd::SoundMeter::MeterColours::textValueColour.


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