Sound Meter  0.8.0
Fully resizing juce meter module.
sd::SoundMeter::Level Class Reference

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

Classes

struct  Tick
 Tick-mark class. More...
 

Public Member Functions

 Level ()=default
 Constructor. More...
 
void reset () noexcept
 Reset the meter (but not the peak hold). More...
 
void setInputLevel (float newLevel) noexcept
 Set the level of the meter. More...
 
float getInputLevel () noexcept
 Get's the meter's input level. More...
 
juce::Rectangle< int > calculateMeterLevel (float newLevel) noexcept
 Calculate the actual meter level (ballistics included). More...
 
float getMeterLevel () const noexcept
 Get the actual meter's level (including ballistics). More...
 
void setOptions (Options meterOptions)
 Set the meter's options. More...
 
float getRefreshRate () const noexcept
 Get the meter's refresh (redraw) rate. More...
 
void setRefreshRate (float refreshRate_hz) noexcept
 Sets the meter's refresh rate. More...
 
void setDecay (float decay_ms) noexcept
 Set meter decay. More...
 
float getDecay () const noexcept
 Get meter decay. More...
 
void showPeakHold (bool isVisible) noexcept
 Set's the visibility of the peak hold indicator. More...
 
void defineSegments (const float warningSegment_db, const float peakSegment_db)
 Set the levels dividing the different segments of the meter. More...
 
bool isPeakHoldVisible () const noexcept
 Check if the peak hold indicator is visible. More...
 
void enableValue (bool valueEnabled) noexcept
 Enable the peak 'value' part of the meter. More...
 
void showValue (bool isVisible) noexcept
 Show the peak 'value' part of the meter. More...
 
bool isPeakValueVisible () const noexcept
 Check if the peak 'value' part is visible. More...
 
void resetPeakHoldLevel () noexcept
 Reset the peak hold level. More...
 
float getPeakHoldLevel () const noexcept
 Get the current peak hold level. More...
 
void setValueBounds (juce::Rectangle< int > bounds) noexcept
 Set the bounds of the 'value' part of the meter. More...
 
juce::Rectangle< int > getValueBounds () const noexcept
 Get the bounds of the 'value' part of the meter. More...
 
void setMeterBounds (juce::Rectangle< int > bounds) noexcept
 Set the bounds of the 'meter' part of the meter. More...
 
juce::Rectangle< int > getMeterBounds () const noexcept
 Get the bounds of the 'meter' part. More...
 
bool isMouseOverValue (const int y) noexcept
 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
 Draws the meter. More...
 
void drawInactiveMeter (juce::Graphics &g, const juce::Colour &textColour) const
 Draw the 'meter' part in it's inactive (muted) state. More...
 
void drawPeakValue (juce::Graphics &g, const juce::Colour &textValueColour) const
 Draw the peak 'value'. More...
 
void drawPeakHold (juce::Graphics &g, const juce::Colour &colour) const
 Draw the peak hold indicator. More...
 
void drawTickMarks (juce::Graphics &g, const juce::Colour &tickColour) const
 Draw the tick-marks. More...
 
void drawLabels (juce::Graphics &g, const juce::Colour &textColour) const
 Draw the value labels at the tick marks. More...
 
void setTickMarks (const std::vector< float > &ticks) noexcept
 Set the level of the tick marks. More...
 
void showTickMarks (bool visible) noexcept
 Show tick-marks (divider lines) on the meter. More...
 
void enableTickMarks (bool enabled) noexcept
 Enable tick-marks (divider lines) on the meter. More...
 
void setColours (const juce::Colour &normalColour, const juce::Colour &warningColour, const juce::Colour &peakColour) noexcept
 Set the colours of the segments. More...
 
void useGradients (bool useGradients) noexcept
 Use gradients in stead of hard segment boundaries. 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 ( )
default

Constructor.

Member Function Documentation

◆ reset()

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

Reset the meter (but not the peak hold).

See also
resetPeakHold

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

◆ setInputLevel()

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

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 ( )
noexcept

Get's the meter's input level.

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

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

◆ calculateMeterLevel()

juce::Rectangle< int > sd::SoundMeter::Level::calculateMeterLevel ( float  newLevel)
noexcept

Calculate the actual meter level (ballistics included).

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

Parameters
newLevelThe level to use as input for the meter's ballistics.
Returns
The part of the meter that needs to be redrawn (refreshed).
See also
getMeterLevel, setDecay

References sd::SoundMeter::Segment::getSegmentBounds(), sd::SoundMeter::Segment::isDirty(), and sd::SoundMeter::Segment::setLevel().

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 with ballistics.
See also
setMeterLevel, setDecay

◆ setOptions()

◆ 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.

◆ setRefreshRate()

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

Sets the meter's refresh rate.

Set this to optimize the meter's decay rate.

Parameters
refreshRate_hzRefresh rate in Hz.
See also
setDecay, getDecay

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

Referenced by setOptions(), and sd::SoundMeter::MeterChannel::setRefreshRate().

◆ setDecay()

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

Set meter decay.

Parameters
decay_msMeter decay in milliseconds.
See also
getDecay

References sd::SoundMeter::Options::decayTime_ms, sd::SoundMeter::Constants::kMaxDecay_ms, and sd::SoundMeter::Constants::kMinDecay_ms.

Referenced by sd::SoundMeter::MeterChannel::setDecay(), and setOptions().

◆ 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().

◆ showPeakHold()

void sd::SoundMeter::Level::showPeakHold ( bool  isVisible)
noexcept

Set's the visibility of the peak hold indicator.

Parameters
isVisibleWhen true, the peak hold indicator is shown.
See also
isPeakHoldVisible, resetPeakHoldLevel

References sd::SoundMeter::Options::showPeakHoldIndicator.

Referenced by setOptions().

◆ defineSegments()

void sd::SoundMeter::Level::defineSegments ( const float  warningSegment_db,
const float  peakSegment_db 
)

Set the levels dividing the different segments of the meter.

The meter has 3 segments. Normal, warning and peak. The peak segment level supplied need to be larger then the warning segment level.

Parameters
warningSegment_dbSets the level (in db) dividing the normal and warning segments of the meter.
peakSegment_dbSets the level (in db) dividing the warning and peak segments of the meter.

References sd::SoundMeter::Segment::setRange().

Referenced by sd::SoundMeter::MeterChannel::defineSegments(), and setOptions().

◆ isPeakHoldVisible()

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

Check if the peak hold indicator is visible.

Returns
True if the peak hold indicator is visible.
See also
showPeakHold, resetPeakHoldLevel

References sd::SoundMeter::Options::showPeakHoldIndicator.

◆ enableValue()

void sd::SoundMeter::Level::enableValue ( bool  valueEnabled)
noexcept

Enable the peak 'value' part of the meter.

When enabled (and made visible with showValue) the peak 'value' part will be shown below the meter (in dB). It's the same level as the peak hold bar.

Parameters
valueEnabledWhen set true, the 'value' level (in dB) part below the meter will be enabled.
See also
isPeakValueVisible, resetPeakHoldLevel, setValueVisible

References sd::SoundMeter::Options::valueEnabled.

◆ showValue()

void sd::SoundMeter::Level::showValue ( bool  isVisible)
noexcept

Show the peak 'value' part of the meter.

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

Parameters
isVisibleWhen set true, shows the 'value' level (in dB) part below the meter.
See also
isPeakValueVisible, resetPeakHoldLevel, enableValue

◆ 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, resetPeakHoldLevel

References sd::SoundMeter::Options::valueEnabled.

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

◆ resetPeakHoldLevel()

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

Reset the peak hold level.

Set's the peak hold level to 0.

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

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

◆ getPeakHoldLevel()

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

Get the current peak hold level.

Set's the peak hold level to 0.

Returns
The current peak hold level (in amp).
See also
resetPeakHoldLevel, isPeakValueVisible, setPeakValueVisible, setPeakHoldVisible, isPeakHoldVisible

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

◆ setValueBounds()

void sd::SoundMeter::Level::setValueBounds ( juce::Rectangle< int >  bounds)
noexcept

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

Parameters
boundsThe bounds to use for the 'value' part of the meter.
See also
getValueBounds, setMeterBounds, getMeterBounds

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

◆ 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

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

◆ setMeterBounds()

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

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

References sd::SoundMeter::Segment::setMeterBounds().

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

◆ 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

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

◆ isMouseOverValue() [1/2]

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

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

Draws the meter.

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

References sd::SoundMeter::Segment::draw(), and sd::SoundMeter::Options::useGradient.

◆ drawInactiveMeter()

void sd::SoundMeter::Level::drawInactiveMeter ( juce::Graphics &  g,
const juce::Colour &  textColour 
) const

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

Parameters
[in,out]gThe juce graphics context to use.
textColourColour of the text on the inactive meter.
See also
drawMeter, drawTickMarks, drawPeakValue, drawPeakHold, drawLabels

◆ drawPeakValue()

void sd::SoundMeter::Level::drawPeakValue ( juce::Graphics &  g,
const juce::Colour &  textValueColour 
) const

Draw the peak 'value'.

Parameters
[in,out]gThe juce graphics context to use.
textValueColourColour of the text displaying the peak value.
See also
drawMeter, drawInactiveMeter, drawInactiveMeter, drawPeakHold, drawTickMarks, drawLabels

References getPeakHoldLevel(), and sd::SoundMeter::Constants::kDefaultHeaderHeight.

◆ drawPeakHold()

void sd::SoundMeter::Level::drawPeakHold ( juce::Graphics &  g,
const juce::Colour &  colour 
) const

Draw the peak hold indicator.

Parameters
[in,out]gThe juce graphics context to use.
colourThe colour of the peak hold indicator.
See also
drawMeter, drawInactiveMeter, drawInactiveMeter, drawPeakValue, drawTickMarks, drawLabels

References sd::SoundMeter::Constants::kPeakHoldHeight.

◆ drawTickMarks()

void sd::SoundMeter::Level::drawTickMarks ( juce::Graphics &  g,
const juce::Colour &  tickColour 
) const

Draw the tick-marks.

These are the lines dividing the meters at certain dB levels.

Parameters
[in,out]gThe juce graphics context to use.
tickColourColour of the tick marks.
See also
drawMeter, drawInactiveMeter, drawInactiveMeter, drawPeakValue, drawPeakHold, drawLabels

References sd::SoundMeter::Constants::kTickMarkHeight, and sd::SoundMeter::Options::tickMarksEnabled.

◆ drawLabels()

void sd::SoundMeter::Level::drawLabels ( juce::Graphics &  g,
const juce::Colour &  textColour 
) const

Draw the value labels at the tick marks.

These will be displayed if the meter is a labelStrip.

Parameters
[in,out]gThe juce graphics context to use.
textColourColour of the label text.
See also
drawMeter, drawInactiveMeter, drawInactiveMeter, drawPeakValue, drawPeakHold, drawTickMarks

References sd::SoundMeter::Constants::kLabelStripTextPadding.

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

◆ setTickMarks()

void sd::SoundMeter::Level::setTickMarks ( const std::vector< float > &  ticks)
noexcept

Set the level of the tick marks.

A tick mark is a horizontal line, dividing the meter. This is also the place the label strip will put it's text values.

Parameters
tickslist of tick mark values (in amp).
See also
setTickMarksVisible, enableTickMarks

Referenced by setOptions().

◆ showTickMarks()

void sd::SoundMeter::Level::showTickMarks ( bool  visible)
noexcept

Show tick-marks (divider lines) on the meter.

A tick mark is a horizontal line, dividing the meter. This is also the place the label strip will put it's text values.

Parameters
visibleWhen set true, shows the tick-marks.
See also
setTickMarks, enableTickMarks

◆ enableTickMarks()

void sd::SoundMeter::Level::enableTickMarks ( bool  enabled)
noexcept

Enable tick-marks (divider lines) on the meter.

A tick mark is a horizontal line, dividing the meter. This is also the place the label strip will put it's text values.

The tick-marks will be shown when they are enable and visible.

Parameters
enabledWhen set true, the tick-marks are enabled.
See also
setTickMarks, showTickMarks

References sd::SoundMeter::Options::tickMarksEnabled.

Referenced by setOptions().

◆ setColours()

void sd::SoundMeter::Level::setColours ( const juce::Colour &  normalColour,
const juce::Colour &  warningColour,
const juce::Colour &  peakColour 
)
noexcept

Set the colours of the segments.

Parameters
normalColourColour of the 'normal' segment.
warningColourColour of the 'warning' segment.
peakColourColour of the 'peak' segment.

References sd::SoundMeter::Segment::setColours().

◆ useGradients()

void sd::SoundMeter::Level::useGradients ( bool  useGradients)
noexcept

Use gradients in stead of hard segment boundaries.

Parameters
useGradientsWhen set to true, uses smooth gradients. False gives hard segment boundaries.

References sd::SoundMeter::Options::useGradient, and useGradients().

Referenced by setOptions(), and useGradients().


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