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

An individual meter channel. More...

Inheritance diagram for sd::SoundMeter::MeterChannel:

Public Types

enum  ColourIds {
  backgroundColourId = 0x1a03201 , peakColourId = 0x1a03202 , warningColourId = 0x1a03203 , normalColourId = 0x1a03204 ,
  tickMarkColourId = 0x1a03205 , textColourId = 0x1a03206 , faderColourId = 0x1a03207 , textValueColourId = 0x1a03208 ,
  textBackgroundColourId = 0x1a03209 , mutedColourId = 0x1a03210 , solodColourId = 0x1a03211 , mutedMouseOverColourId = 0x1a03212 ,
  inactiveColourId = 0x1a03213
}
 Colour IDs that can be used to customise the colours. More...
 
using ChannelType = juce::AudioChannelSet::ChannelType
 

Public Member Functions

 MeterChannel ()
 Default constructor. More...
 
 MeterChannel (Options meterOptions, Padding padding, const juce::String &channelName, bool isLabelStrip=false, ChannelType channelType=ChannelType::unknown)
 Parameterized constructor. More...
 
virtual ~MeterChannel ()
 Destructor. More...
 
void reset () noexcept
 Reset the meter (but not the peak hold). More...
 
void refresh (bool forceRefresh)
 Refresh the meter with the current input level. More...
 
void setRefreshRate (float refreshRate_hz) noexcept
 Sets the meter's refresh rate. More...
 
void setInputLevel (float inputLevel) noexcept
 Set the input level from the audio engine. More...
 
void setOptions (Options meterOptions)
 Set the meter's options. More...
 
void setActive (bool isActive, NotificationOptions notify=NotificationOptions::dontNotify)
 Activate or deactivate (mute) the meter. More...
 
bool isActive () const noexcept
 Check if the meter is active (unmuted). More...
 
void setDecay (float decay_ms) noexcept
 Set meter decay. More...
 
float getDecay () const noexcept
 Get meter decay. More...
 
void setIsLabelStrip (bool isLabelStrip=false) noexcept
 Set whether this meter is a label strip. More...
 
void defineSegments (float warningSegment_db, float peakSegment_db)
 Set the levels dividing the different segments of the meter. More...
 
void resetPeakHold () noexcept
 Reset the peak hold. More...
 
void showPeakHold (bool showPeakHold=true) noexcept
 Show the peak hold indicator. More...
 
void showValue (bool showValue=true) noexcept
 Show the peak 'value' part of the meter. More...
 
void enableValue (bool valueEnabled=true) noexcept
 Enable the peak 'value' part of the meter. More...
 
void showHeader (bool headerVisible) noexcept
 Show the 'header' part of the meter. More...
 
void enableHeader (bool headerEnabled) noexcept
 Enable the 'header' part of the meter. More...
 
void setFont (const juce::Font &font) noexcept
 Set the meter font. More...
 
void setChannelName (const juce::String &channelName)
 Set the channel name. More...
 
void setChannelType (ChannelType channelType)
 Set the channel type. More...
 
bool nameFits (const juce::String &name, int widthAvailable) const
 Check if a specified name will fit in a give width (in pixels). More...
 
float getChannelNameWidth () const noexcept
 Get the width (in pixels) of the channel info in the 'header' part. More...
 
float getChannelTypeWidth () const noexcept
 Get the width (in pixels) of the full type description in the 'header' part. More...
 
void setReferredTypeWidth (float referredTypeWidth) noexcept
 Set the referred width (from other meters) used to decide what info to display. More...
 
void showTickMarks (bool showTickMarks) 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 showTickMarksOnTop (bool showTickMarksOnTop) noexcept
 Show the tick-marks on top of the level or below it. More...
 
void setTickMarks (const std::vector< float > &ticks) noexcept
 Set the level of the tick marks. More...
 
void setPadding (Padding padding) noexcept
 Set the padding of the meter. More...
 
juce::Rectangle< int > getLabelStripBounds () const noexcept
 Get the bounds of the 'meter' and 'header' parts combined. More...
 
void setMinimalMode (bool minimalMode) noexcept
 Set the meter in 'minimal' mode. More...
 
bool isMinimalModeActive () const noexcept
 Check if the meter is in 'minimal' mode. More...
 
bool autoSetMinimalMode (int proposedWidth, int proposedHeight)
 Automatically set the meter in 'minimal' mode. More...
 
void useGradients (bool useGradients) noexcept
 Use gradients in stead of hard segment boundaries. More...
 
void paint (juce::Graphics &g) override
 
void resized () override
 
void lookAndFeelChanged () override
 
void visibilityChanged () override
 

Detailed Description

An individual meter channel.

This represents a single meter. Use the MetersComponent to create multiple meters matching the specified channel format.

Member Typedef Documentation

◆ ChannelType

using sd::SoundMeter::MeterChannel::ChannelType = juce::AudioChannelSet::ChannelType

Member Enumeration Documentation

◆ ColourIds

Colour IDs that can be used to customise the colours.

This can be done by overriding juce's LookAndFeel class.

Enumerator
backgroundColourId 

Background colour.

peakColourId 

Peak area colour.

warningColourId 

Warning area colour.

normalColourId 

Normal colour.

tickMarkColourId 

Tick-mark colour.

textColourId 

Text colour.

faderColourId 

Fader colour.

textValueColourId 

Value text colour.

textBackgroundColourId 

Text background colour.

mutedColourId 

Muted button colour.

solodColourId 

Soloed button colour..

mutedMouseOverColourId 

Muted mouse over button colour.

inactiveColourId 

Inactive (muted) colour.

Constructor & Destructor Documentation

◆ MeterChannel() [1/2]

sd::SoundMeter::MeterChannel::MeterChannel ( )

Default constructor.

◆ MeterChannel() [2/2]

sd::SoundMeter::MeterChannel::MeterChannel ( Options  meterOptions,
Padding  padding,
const juce::String &  channelName,
bool  isLabelStrip = false,
ChannelType  channelType = ChannelType::unknown 
)

Parameterized constructor.

Parameters
meterOptionsMeter options to use (defining appearance and functionality).
paddingPadding to use (space between meter and the edge of the component).
channelNameThe channel name (set by the user).
isLabelStripWhen set to true, this meter will function as a label strip (with markers for levels at the tick-marks).
channelTypeThe channel type (left, right, center, etc...).

References setChannelType(), setIsLabelStrip(), setOptions(), and setPadding().

◆ ~MeterChannel()

virtual sd::SoundMeter::MeterChannel::~MeterChannel ( )
virtual

Destructor.

Member Function Documentation

◆ reset()

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

Reset the meter (but not the peak hold).

See also
resetPeakHold

References sd::SoundMeter::Level::reset().

Referenced by setActive().

◆ refresh()

void sd::SoundMeter::MeterChannel::refresh ( bool  forceRefresh)

◆ setRefreshRate()

void sd::SoundMeter::MeterChannel::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
refresh, setDecay, getDecay

References sd::SoundMeter::Level::setRefreshRate().

◆ setInputLevel()

void sd::SoundMeter::MeterChannel::setInputLevel ( float  inputLevel)
noexcept

Set the input level from the audio engine.

Called from the audio thread!

Parameters
inputLevelNew input level (in amp).

References sd::SoundMeter::Level::setInputLevel().

◆ setOptions()

void sd::SoundMeter::MeterChannel::setOptions ( Options  meterOptions)

Set the meter's options.

The options determine the appearance and functionality of the meter.

Parameters
meterOptionsMeter options to use.

References sd::SoundMeter::Options::enabled, enableHeader(), sd::SoundMeter::Options::faderEnabled, sd::SoundMeter::Options::headerEnabled, sd::SoundMeter::Level::setOptions(), showTickMarksOnTop(), and sd::SoundMeter::Options::tickMarksOnTop.

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

◆ setActive()

void sd::SoundMeter::MeterChannel::setActive ( bool  isActive,
NotificationOptions  notify = NotificationOptions::dontNotify 
)

Activate or deactivate (mute) the meter.

Parameters
isActiveWhen set to true, the meter is active.
notifyDetermine whether to notify all listeners or not.
See also
isActive

References isActive(), sd::SoundMeter::notify, and reset().

◆ isActive()

bool sd::SoundMeter::MeterChannel::isActive ( ) const
noexcept

Check if the meter is active (unmuted).

Returns
True, if the meter is active (unmuted).
See also
setActive

Referenced by paint(), and setActive().

◆ setDecay()

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

Set meter decay.

Parameters
decay_msMeter decay in milliseconds.
See also
getDecay, setRefreshRate

References sd::SoundMeter::Level::setDecay().

◆ getDecay()

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

Get meter decay.

Returns
Meter decay in milliseconds.
See also
setDecay, setRefreshRate

References sd::SoundMeter::Level::getDecay().

◆ setIsLabelStrip()

void sd::SoundMeter::MeterChannel::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.

Referenced by MeterChannel().

◆ defineSegments()

void sd::SoundMeter::MeterChannel::defineSegments ( float  warningSegment_db,
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::Level::defineSegments().

◆ resetPeakHold()

void sd::SoundMeter::MeterChannel::resetPeakHold ( )
noexcept

Reset the peak hold.

Resets the peak hold indicator and value.

See also
showPeakHold

References sd::SoundMeter::Level::resetPeakHoldLevel().

◆ showPeakHold()

void sd::SoundMeter::MeterChannel::showPeakHold ( bool  showPeakHold = true)
noexcept

Show the peak hold indicator.

Parameters
showPeakHoldWhen set true, the peak hold indicator will be shown.
See also
showPeakValue, resetPeakHold

◆ showValue()

void sd::SoundMeter::MeterChannel::showValue ( bool  showValue = true)
noexcept

Show the peak 'value' part of the meter.

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

Parameters
showPeakValueWhen set true, shows the 'value' level (in dB) part below the meter.
See also
showPeakHold, resetPeakHold, enableValue

◆ enableValue()

void sd::SoundMeter::MeterChannel::enableValue ( bool  valueEnabled = true)
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
showPeakHold, resetPeakHold, showValue

Referenced by sd::SoundMeter::MetersComponent::enableValue().

◆ showHeader()

void sd::SoundMeter::MeterChannel::showHeader ( bool  headerVisible)
noexcept

Show the 'header' part of the meter.

The 'header' part is the part above the meter displaying the channel name (when set) or the channel type. It also doubles as a mute button for the specific channel.

Parameters
headerVisibleWhen set to true, the 'header' part will be visible.
See also
enableHeader

◆ enableHeader()

void sd::SoundMeter::MeterChannel::enableHeader ( bool  headerEnabled)
noexcept

Enable the 'header' part of the meter.

The 'header' part is the part above the meter displaying the channel name (when set) or the channel type. It also doubles as a mute button for the specific channel.

Parameters
headerEnabledWhen set to true, the header part will be enabled.
See also
showHeader

Referenced by sd::SoundMeter::MetersComponent::enableHeader(), and setOptions().

◆ setFont()

void sd::SoundMeter::MeterChannel::setFont ( const juce::Font &  font)
noexcept

Set the meter font.

Font to be used for the header, value and label strip.

Parameters
fontThe font to use.

References sd::SoundMeter::Constants::kDefaultHeaderFontHeight, and sd::SoundMeter::Header::setFont().

Referenced by sd::SoundMeter::MetersComponent::setFont().

◆ setChannelName()

void sd::SoundMeter::MeterChannel::setChannelName ( const juce::String &  channelName)

Set the channel name.

Set's the channel name belonging to the track feeding the meter.

Parameters
channelNameName to assign to this meter.

References sd::SoundMeter::Header::getBounds(), and sd::SoundMeter::Header::setName().

◆ setChannelType()

void sd::SoundMeter::MeterChannel::setChannelType ( ChannelType  channelType)

Set the channel type.

For instance: left, right, center, etc..

Parameters
typeThe channel type assigned to the meter.
See also
getType

References sd::SoundMeter::Header::setType().

Referenced by MeterChannel().

◆ nameFits()

bool sd::SoundMeter::MeterChannel::nameFits ( const juce::String &  name,
int  widthAvailable 
) const

Check if a specified name will fit in a give width (in pixels).

This can be a more detailed, multi-line description of the function, and it's containing logic.

Parameters
nameThe name to check the width of.
widthAvailableThe width (in pixels) available to fit the name in.
Returns
True, if the name will fit in the given width (in pixels).
See also
getChannelNameWidth, setChannelNames

References sd::SoundMeter::Header::textFits().

Referenced by autoSetMinimalMode().

◆ getChannelNameWidth()

float sd::SoundMeter::MeterChannel::getChannelNameWidth ( ) const
noexcept

Get the width (in pixels) of the channel info in the 'header' part.

Returns
The width (in pixels) taken by the channel info in the 'header' part.
See also
getChannelTypeWidth, nameFits, setChannelName

References sd::SoundMeter::Header::getNameWidth().

◆ getChannelTypeWidth()

float sd::SoundMeter::MeterChannel::getChannelTypeWidth ( ) const
noexcept

Get the width (in pixels) of the full type description in the 'header' part.

Returns
The width (in pixels) taken by the full type description in the 'header' part.
See also
getChannelNameWidth, nameFits, setChannelType

References sd::SoundMeter::Header::getTypeWidth().

◆ setReferredTypeWidth()

void sd::SoundMeter::MeterChannel::setReferredTypeWidth ( float  referredTypeWidth)
noexcept

Set the referred width (from other meters) used to decide what info to display.

When this is set to zero, each meter uses his own bounds to decide what to display. When set to a non zero value (for instance from another meter) this meter will use that value to decide what to display. When there is not enough room (width) to display the full description or name, display the abbreviated type description.

Parameters
referredWidthThe width (in pixels) to use when deciding what to display in the header.

References sd::SoundMeter::Header::setReferredWidth().

◆ showTickMarks()

void sd::SoundMeter::MeterChannel::showTickMarks ( bool  showTickMarks)
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
showTickMarksWhen set true, shows the tick-marks.
See also
setTickMarks, enableTickMarks, showTickMarksOnTop

Referenced by sd::SoundMeter::MetersComponent::reset(), and sd::SoundMeter::MetersComponent::showTickMarks().

◆ enableTickMarks()

void sd::SoundMeter::MeterChannel::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
showTickMarks, setTickMarks, showTickMarksOnTop

◆ showTickMarksOnTop()

void sd::SoundMeter::MeterChannel::showTickMarksOnTop ( bool  showTickMarksOnTop)
noexcept

Show the tick-marks on top of the level or below it.

When below the level, the tick-marks will be obscured if the level is loud enough.

Parameters
showTickMarksOnTopShow the tick-marks on top of the level.

Referenced by setOptions().

◆ setTickMarks()

void sd::SoundMeter::MeterChannel::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
showTickMarks, showTickMarksOnTop, enableTickMarks

◆ setPadding()

void sd::SoundMeter::MeterChannel::setPadding ( Padding  padding)
noexcept

Set the padding of the meter.

The padding is the space between the meter and the edges of the component.

Parameters
paddingAmount of padding to apply.

Referenced by MeterChannel().

◆ getLabelStripBounds()

juce::Rectangle< int > sd::SoundMeter::MeterChannel::getLabelStripBounds ( ) const
noexcept

Get the bounds of the 'meter' and 'header' parts combined.

Returns
The bounds of the 'meter' and 'header' parts combined.

References sd::SoundMeter::Header::getBounds(), and sd::SoundMeter::Level::getMeterBounds().

◆ setMinimalMode()

void sd::SoundMeter::MeterChannel::setMinimalMode ( bool  minimalMode)
noexcept

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

Referenced by autoSetMinimalMode().

◆ isMinimalModeActive()

bool sd::SoundMeter::MeterChannel::isMinimalModeActive ( ) const
noexcept

Check if the meter is 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.

Returns
True, if the meter is in 'minimal' mode.
See also
setMinimalMode, autoSetMinimalMode

◆ autoSetMinimalMode()

bool sd::SoundMeter::MeterChannel::autoSetMinimalMode ( int  proposedWidth,
int  proposedHeight 
)

Automatically set the meter in 'minimal' mode.

Use the proposed height and width to determine if that would lead to the meter being in 'minimal' mode. Then apply that 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
proposedWidthThe width use to determine if the meter would be in 'minimal' mode.
proposedHeightThe height use to determine if the meter would be in 'minimal' mode.
Returns
True, if the meter is in 'minimal' mode.
See also
setMinimalMode, isMinimalModeActive

References sd::SoundMeter::Constants::kMinModeHeightThreshold, sd::SoundMeter::Constants::kMinModeWidthThreshold, nameFits(), and setMinimalMode().

◆ useGradients()

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

Use gradients in stead of hard segment boundaries.

Beware that this will come with a CPU cost.

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

◆ paint()

void sd::SoundMeter::MeterChannel::paint ( juce::Graphics &  g)
override

◆ resized()

◆ lookAndFeelChanged()

void sd::SoundMeter::MeterChannel::lookAndFeelChanged ( )
override

◆ visibilityChanged()

void sd::SoundMeter::MeterChannel::visibilityChanged ( )
override

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