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

Component containing one or more meters. More...

#include <sd_MetersComponent.h>

Inheritance diagram for sd::SoundMeter::MetersComponent:

Public Member Functions

 MetersComponent ()
 Default constructor. More...
 
 MetersComponent (const Options &meterOptions)
 Constructor with meter options. More...
 
 MetersComponent (const juce::AudioChannelSet &channelFormat)
 Constructor which accepts a channel format. More...
 
 MetersComponent (const Options &meterOptions, const juce::AudioChannelSet &channelFormat)
 Constructor with meter options and which accepts a channel format. More...
 
 ~MetersComponent () override
 Destructor. More...
 
void refresh (bool forceRefresh=false)
 Refresh (redraw) the meters panel. More...
 
void reset ()
 Reset the meters. More...
 
void resetMeters ()
 Reset all meters. More...
 
void clearMeters ()
 Clear the level of the meters. More...
 
void resetPeakHold ()
 Reset all peak hold indicators and 'values'. More...
 
void setInputLevel (int channel, float value)
 Set the input level. More...
 
void setNumChannels (int numChannels, const std::vector< juce::String > &channelNames={})
 Set the number of channels (meters) in the panel. More...
 
void setChannelFormat (const juce::AudioChannelSet &channels, const std::vector< juce::String > &channelNames={})
 Set the channel format (number of channels) to use for the mixer/meters. More...
 
int getNumChannels () const noexcept
 Get the number of meters in the panel. More...
 
int getAutoSizedPanelWidth () const noexcept
 Get the default meters panel width. More...
 
void setChannelNames (const std::vector< juce::String > &channelNames)
 Set the channel names to display above the meters. More...
 
void setOptions (const Options &meterOptions)
 Set meter options defining appearance and functionality. More...
 
void setRefreshRate (float refreshRate)
 Set the refresh (redraw) rate of the meters. More...
 
void useInternalTiming (bool useInternalTiming) noexcept
 Set the timing option to use (internal/external). More...
 
void setMeterSegments (const std::vector< SegmentOptions > &segmentsOptions)
 Set the segments the meter is made out of. More...
 
void setDecay (float decay_ms)
 Set meter decay rate. More...
 
void useGradients (bool useGradients)
 Use gradients instead of hard segment boundaries. More...
 
void setLabelStripPosition (LabelStripPosition labelStripPosition)
 Set the position of the label-strip relative to the meters. More...
 
void showHeader (bool showHeader)
 Show the 'header' part above the meters. More...
 
void showValue (bool showValue)
 Show the 'value' part below the meters. More...
 
void setFont (const juce::Font &font)
 Set the font to be used in the panel and it's meters. More...
 
void enable (bool enabled=true)
 Enable or disable the panel. More...
 
void showTickMarks (bool showTickMarks)
 Show tick-marks (divider lines) on the meter. More...
 
void visibilityChanged () override
 
void lookAndFeelChanged () override
 
void paint (juce::Graphics &g) override
 
void resized () override
 

Detailed Description

Component containing one or more meters.

After setting the channel format it will automatically create the needed meters and give them proper names.

Constructor & Destructor Documentation

◆ MetersComponent() [1/4]

sd::SoundMeter::MetersComponent::MetersComponent ( )

Default constructor.

◆ MetersComponent() [2/4]

sd::SoundMeter::MetersComponent::MetersComponent ( const Options meterOptions)
explicit

Constructor with meter options.

Parameters
meterOptionsThe options to use with the meters and the label strip.

◆ MetersComponent() [3/4]

sd::SoundMeter::MetersComponent::MetersComponent ( const juce::AudioChannelSet &  channelFormat)
explicit

Constructor which accepts a channel format.

This constructor will automatically setup the panel with the right amount of meters, named according to the channel format.

Parameters
channelFormatThe channel format to use to initialise the panel.

◆ MetersComponent() [4/4]

sd::SoundMeter::MetersComponent::MetersComponent ( const Options meterOptions,
const juce::AudioChannelSet &  channelFormat 
)

Constructor with meter options and which accepts a channel format.

This constructor will automatically setup the panel with the right amount of meters, named according to the channel format.

Parameters
meterOptionsThe options to use with the meters and the label strip.
channelFormatThe channel format to use to initialise the panel.

References sd::SoundMeter::Options::faderEnabled, sd::SoundMeter::Constants::kMetersPanelId, and sd::SoundMeter::Options::refreshRate.

◆ ~MetersComponent()

sd::SoundMeter::MetersComponent::~MetersComponent ( )
override

Destructor.

Member Function Documentation

◆ refresh()

void sd::SoundMeter::MetersComponent::refresh ( bool  forceRefresh = false)

Refresh (redraw) the meters panel.

This can be called manually or internally (see useInternalTiming).

Parameters
forceRefreshWhen set to true, always redraw the meters panel (not only if it's dirty/changed).
See also
setRefreshRate, useInternalTiming

References sd::SoundMeter::MeterChannel::refresh().

Referenced by clearMeters(), enable(), and reset().

◆ reset()

void sd::SoundMeter::MetersComponent::reset ( )

Reset the meters.

Initialise the meters, faders and clears all the levels (but not preserves the peak hold).

See also
resetPeakHold, resetMeters

References refresh(), and sd::SoundMeter::MeterChannel::showTickMarks().

◆ resetMeters()

void sd::SoundMeter::MetersComponent::resetMeters ( )

Reset all meters.

Resets all meters to 0 (but not the peak hold).

See also
reset, resetPeakHold

◆ clearMeters()

void sd::SoundMeter::MetersComponent::clearMeters ( )

Clear the level of the meters.

References refresh().

◆ resetPeakHold()

void sd::SoundMeter::MetersComponent::resetPeakHold ( )

Reset all peak hold indicators and 'values'.

See also
reset, resetMeters

◆ setInputLevel()

void sd::SoundMeter::MetersComponent::setInputLevel ( int  channel,
float  value 
)

Set the input level.

This supplies a meter of a specific channel with the peak level from the audio engine. Beware: this will usually be called from the audio thread.

Parameters
channelThe channel to set the input level of.
valueThe input level to set to the specified channel.

◆ setNumChannels()

void sd::SoundMeter::MetersComponent::setNumChannels ( int  numChannels,
const std::vector< juce::String > &  channelNames = {} 
)

Set the number of channels (meters) in the panel.

Parameters
numChannelsThe number of channels (meters).
channelNamesThe (optional) channel names to use in the header of the meters.
See also
getNumChannels, setChannelFormat

References setChannelFormat().

◆ setChannelFormat()

void sd::SoundMeter::MetersComponent::setChannelFormat ( const juce::AudioChannelSet &  channels,
const std::vector< juce::String > &  channelNames = {} 
)

Set the channel format (number of channels) to use for the mixer/meters.

Parameters
channelsThe channel format to use.
channelNamesThe (optional) channel names to use in the header of the meters.
See also
setNumChannels, getNumChannels

References resized(), and setChannelNames().

Referenced by setNumChannels().

◆ getNumChannels()

int sd::SoundMeter::MetersComponent::getNumChannels ( ) const
noexcept

Get the number of meters in the panel.

Returns
The number of meters in the panel.
See also
setNumChannels, setChannelFormat

◆ getAutoSizedPanelWidth()

int sd::SoundMeter::MetersComponent::getAutoSizedPanelWidth ( ) const
noexcept

Get the default meters panel width.

Get's the default panel width in pixels. This is the width where all channels are wide enough to display all channel names.

Returns
The default panel width (in pixels).

◆ setChannelNames()

void sd::SoundMeter::MetersComponent::setChannelNames ( const std::vector< juce::String > &  channelNames)

Set the channel names to display above the meters.

Parameters
channelNamesThe list of names to use for the meters.

References sd::SoundMeter::Constants::kDefaultHeaderLabelWidth, sd::SoundMeter::Constants::kFaderRightPadding, sd::SoundMeter::Constants::kLabelStripLeftPadding, and sd::SoundMeter::Constants::kMinWidth.

Referenced by setChannelFormat().

◆ setOptions()

void sd::SoundMeter::MetersComponent::setOptions ( const Options meterOptions)

Set meter options defining appearance and functionality.

Parameters
meterOptionsThe options to apply to the meters and label strip.

References sd::SoundMeter::MeterChannel::setOptions().

◆ setRefreshRate()

void sd::SoundMeter::MetersComponent::setRefreshRate ( float  refreshRate)

Set the refresh (redraw) rate of the meters.

Also used for meter ballistics. When using the internal timer (setInternalTiming) this set's it's refresh rate. When manually redrawing (with refresh) you could (should) still provide the refresh rate to optimize a smooth decay.

Parameters
refreshRateThe refresh rate (in Hz).
See also
setDecay, refresh, setInternalTiming

References sd::SoundMeter::Options::refreshRate, and sd::SoundMeter::MeterChannel::setRefreshRate().

◆ useInternalTiming()

void sd::SoundMeter::MetersComponent::useInternalTiming ( bool  useInternalTiming)
noexcept

Set the timing option to use (internal/external).

When using internal timing, the panel will redraw (refresh) the meters automatically using the refresh rate specified in setPanelRefreshRate. When using external timing, the user has to do this manually with the 'refresh' method.

Parameters
useInternalTimingWhen set to true, the meter panel will update itself.
See also
refresh, setPanelRefreshRate

◆ setMeterSegments()

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

◆ setDecay()

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

Set meter decay rate.

Set's the meter's decay rate in milliseconds. The meter's attack is instant.

Parameters
decay_msThe time it takes the meter to decay (in ms).
See also
setRefreshRate

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

◆ useGradients()

void sd::SoundMeter::MetersComponent::useGradients ( bool  useGradients)

Use gradients instead of hard segment boundaries.

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

References useGradients().

Referenced by useGradients().

◆ setLabelStripPosition()

void sd::SoundMeter::MetersComponent::setLabelStripPosition ( LabelStripPosition  labelStripPosition)

Set the position of the label-strip relative to the meters.

Parameters
labelStripPositionThe position of the label-strip relative to the meters.

References resized().

◆ showHeader()

void sd::SoundMeter::MetersComponent::showHeader ( bool  showHeader)

Show the 'header' part above the meters.

This will display the channel name (a custom one that the user can set) or the channel type (left, right, center, etc...). This also doubles as a mute button for the specific channel.

Parameters
showHeaderWhen set to true, the 'header' part will be shown.
See also
showValue, setChannelNames

References sd::SoundMeter::Options::headerEnabled, resized(), sd::SoundMeter::MeterChannel::showHeader(), and showHeader().

Referenced by showHeader().

◆ showValue()

void sd::SoundMeter::MetersComponent::showValue ( bool  showValue)

Show the 'value' part below the meters.

This will display the peak value, in decibels, below the meter. The level displayed here matches the peak level indicator on the meter. Double clicking will reset the peak hold value (as well as the indicator).

Parameters
showValueWhen set to true, the 'value' part will be shown.
See also
showHeader, resetPeakHold

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

Referenced by showValue().

◆ setFont()

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

Set the font to be used in the panel and it's meters.

Parameters
fontThe font to use.

References sd::SoundMeter::MeterChannel::setFont().

◆ enable()

void sd::SoundMeter::MetersComponent::enable ( bool  enabled = true)

Enable or disable the panel.

Parameters
enabledWhen set to true, the meters panel will be displayed.

References sd::SoundMeter::Options::enabled, and refresh().

◆ showTickMarks()

void sd::SoundMeter::MetersComponent::showTickMarks ( bool  showTickMarks)

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.

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

Referenced by showTickMarks().

◆ visibilityChanged()

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

◆ lookAndFeelChanged()

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

◆ paint()

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

◆ resized()


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