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

An individual meter channel. More...

#include <sd_MeterChannel.h>

Inheritance diagram for sd::SoundMeter::MeterChannel:

Public Types

enum  ColourIds {
  backgroundColourId = 0x1a03201 , tickMarkColourId = 0x1a03202 , textColourId = 0x1a03203 , faderColourId = 0x1a03204 ,
  textValueColourId = 0x1a03205 , mutedColourId = 0x1a03206 , solodColourId = 0x1a03207 , mutedMouseOverColourId = 0x1a03208 ,
  inactiveColourId = 0x1a03209 , peakHoldColourId = 0x1a03210
}
 Colour IDs that can be used to customise the colours. More...
 
using ChannelType = juce::AudioChannelSet::ChannelType
 
using Ptr = juce::Component::SafePointer< MeterChannel >
 

Public Member Functions

 MeterChannel () noexcept
 Default constructor. More...
 
 MeterChannel (const Options &meterOptions, Padding padding, const juce::String &channelName, bool isLabelStrip=false, ChannelType channelType=ChannelType::unknown)
 Parameterized constructor. More...
 
void reset ()
 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)
 Sets the meter's refresh rate. More...
 
void setDecay (float decay_ms)
 Set meter decay. More...
 
void setPadding (const Padding &padding) noexcept
 Set the padding of the meter. More...
 
float getDecay () const noexcept
 Get meter decay. More...
 
void setInputLevel (float inputLevel)
 Set the input level from the audio engine. More...
 
void setOptions (const 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 (un-muted). More...
 
void setIsLabelStrip (bool isLabelStrip=false) noexcept
 Set whether this meter is a label strip. More...
 
void setMeterSegments (const std::vector< SegmentOptions > &segmentsOptions)
 Set the segments the meter is made out of. More...
 
void resetPeakHold ()
 Reset the peak hold. More...
 
void showPeakHold (bool showPeakHold=true)
 Show (or hide) the peak hold indicator. More...
 
void showValue (bool showValue=true)
 Show the peak 'value' part of the meter. More...
 
void showHeader (bool headerVisible)
 Show the 'header' part of the meter. More...
 
void setFont (const juce::Font &font)
 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)
 Enable tick-marks (divider lines) on the meter. More...
 
void showTickMarksOnTop (bool showTickMarksOnTop)
 Show the tick-marks on top of the level or below it. More...
 
void setTickMarks (const std::vector< float > &tickMarks)
 Set the level of the tick marks. More...
 
juce::Rectangle< int > getLabelStripBounds () const noexcept
 Get the bounds of the 'meter' and 'header' parts combined. More...
 
void setMinimalMode (bool minimalMode)
 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)
 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

◆ Ptr

using sd::SoundMeter::MeterChannel::Ptr = juce::Component::SafePointer<MeterChannel>

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.

tickMarkColourId 

Tick-mark colour.

textColourId 

Text colour.

faderColourId 

Fader colour.

textValueColourId 

Value text colour.

mutedColourId 

Muted button colour.

solodColourId 

Soloed button colour..

mutedMouseOverColourId 

Muted mouse over button colour.

inactiveColourId 

Inactive (muted) colour.

peakHoldColourId 

Peak hold colour.

Constructor & Destructor Documentation

◆ MeterChannel() [1/2]

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

Default constructor.

◆ MeterChannel() [2/2]

sd::SoundMeter::MeterChannel::MeterChannel ( const 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).
paddingThe padding 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().

Member Function Documentation

◆ reset()

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

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)

Refresh the meter with the current input level.

Parameters
forceRefreshWhen set to true, the meter will be forced to repaint (even if not dirty).
See also
setRefreshRate

References sd::SoundMeter::Level::getDirtyBounds(), sd::SoundMeter::Level::getMeterBounds(), and sd::SoundMeter::Level::refreshMeterLevel().

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

◆ setRefreshRate()

void sd::SoundMeter::MeterChannel::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::Level::setRefreshRate().

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

◆ setDecay()

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

Set meter decay.

Parameters
decay_msMeter decay in milliseconds.
See also
getDecay, setRefreshRate

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

◆ setPadding()

void sd::SoundMeter::MeterChannel::setPadding ( const 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().

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

◆ setInputLevel()

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

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 ( const Options meterOptions)

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

Returns
True, if the meter is active (un-muted).
See also
setActive

Referenced by paint(), and setActive().

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

◆ setMeterSegments()

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

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

◆ resetPeakHold()

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

Reset the peak hold.

Resets the peak hold indicator and value.

See also
showPeakHold

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

◆ showPeakHold()

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

Show (or hide) the peak hold indicator.

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

References setOptions(), showPeakHold(), and sd::SoundMeter::Options::showPeakHoldIndicator.

Referenced by showPeakHold().

◆ showValue()

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

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
showValueWhen set true, shows the 'value' level (in dB) part below the meter.
See also
showPeakHold, resetPeakHold, showValue

References setOptions(), showValue(), and sd::SoundMeter::Options::valueEnabled.

Referenced by sd::SoundMeter::MetersComponent::showValue(), and showValue().

◆ showHeader()

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

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.

References sd::SoundMeter::Header::getBounds(), sd::SoundMeter::Options::headerEnabled, and resized().

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

◆ setFont()

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

Set the meter font.

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

Parameters
fontThe font to use.

References 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
channelTypeThe 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
referredTypeWidthThe 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)

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
showTickMarksWhen set true, the tick-marks are enabled.
See also
showTickMarks, setTickMarks, showTickMarksOnTop

References setOptions(), showTickMarks(), and sd::SoundMeter::Options::tickMarksEnabled.

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

◆ showTickMarksOnTop()

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

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.

References setOptions(), showTickMarksOnTop(), and sd::SoundMeter::Options::tickMarksOnTop.

Referenced by showTickMarksOnTop().

◆ setTickMarks()

void sd::SoundMeter::MeterChannel::setTickMarks ( const std::vector< float > &  tickMarks)

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
tickMarksList of tick mark values (in decibels).
See also
showTickMarks, showTickMarksOnTop, showTickMarks

References setOptions(), and sd::SoundMeter::Options::tickMarks.

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

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

◆ setMinimalMode()

void sd::SoundMeter::MeterChannel::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 sd::SoundMeter::Level::setMinimalMode(), showHeader(), and sd::SoundMeter::Options::useMinimalMode.

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)

Use gradients in stead of hard segment boundaries.

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

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

Referenced by useGradients().

◆ paint()

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

◆ resized()

◆ lookAndFeelChanged()

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

References visibilityChanged().

◆ visibilityChanged()

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

Referenced by lookAndFeelChanged().


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