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

Component containing one or more meters. More...

Inheritance diagram for sd::SoundMeter::MetersComponent:

Public Member Functions

 MetersComponent ()
 Constructor. More...
 
 MetersComponent (Options meterOptions)
 Constructor with meter options. More...
 
 MetersComponent (const juce::AudioChannelSet &channelFormat)
 Constructor which accepts a channel format. More...
 
 MetersComponent (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 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 (Options meterOptions)
 Set meter options defining appearance and functionality. More...
 
void setRefreshRate (float refreshRate) noexcept
 Set the refresh (redraw) rate of the meters. More...
 
void useInternalTiming (bool useInternalTiming) noexcept
 Set the timing option to use (internal/external). More...
 
void defineSegments (float warningSegment_db, float peakSegment_db)
 Set the levels dividing the different segments of the meter. More...
 
void setDecay (float decay_ms)
 Set meter decay rate. More...
 
void useGradients (bool useGradients) noexcept
 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 enableHeader (bool headerEnabled)
 Enable the 'header' part above the meters. More...
 
void enableValue (bool valueEnabled)
 Enable the 'value' part below the meters. More...
 
void setFont (const juce::Font &font) noexcept
 Set the font to be used in the panel and it's meters. More...
 
void setEnabled (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 ( )

Constructor.

◆ MetersComponent() [2/4]

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

Constructor with meter options.

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

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

◆ 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 ( 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
channelFormatThe channel format to use to initialise the panel.

◆ ~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 reset(), and setEnabled().

◆ 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

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

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

◆ useInternalTiming()

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

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

When using internal timing, the panel will update it's meters by itself using the refresh rate specified in setPanelRefreshRate. On external, 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

◆ defineSegments()

void sd::SoundMeter::MetersComponent::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_dbThe level (in dB) dividing the normal and warning segments of the meter.
peakSegment_dbThe level (in dB) dividing the warning and peak segments of the meter.

References sd::SoundMeter::Options::peakSegment_db, and sd::SoundMeter::Options::warningSegment_db.

◆ 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
decayThe 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)
noexcept

Use gradients instead of hard segment boundaries.

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

References sd::SoundMeter::Options::useGradient.

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

◆ enableHeader()

void sd::SoundMeter::MetersComponent::enableHeader ( bool  headerEnabled)

Enable 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
headerEnabledWhen set to true, the 'header' part will be shown.
See also
showValue, setChannelNames

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

◆ enableValue()

void sd::SoundMeter::MetersComponent::enableValue ( bool  valueEnabled)

Enable 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
valueEnabledWhen set to true, the 'value' part will be shown.
See also
enableHeader, resetPeakHold

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

◆ setFont()

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

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

Parameters
fontThe font to use.

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

◆ setEnabled()

void sd::SoundMeter::MetersComponent::setEnabled ( 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(), and sd::SoundMeter::Options::tickMarksEnabled.

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