Sound Meter 0.9.0
Fully resizing logarithmic JUCE meter module.
|
Component containing one or more meters. More...
#include <sd_MetersComponent.h>
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 |
Component containing one or more meters.
After setting the channel format it will automatically create the needed meters and give them proper names.
sd::SoundMeter::MetersComponent::MetersComponent | ( | ) |
Default constructor.
|
explicit |
Constructor with meter options.
meterOptions | The options to use with the meters and the label strip. |
|
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.
channelFormat | The channel format to use to initialise the panel. |
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.
meterOptions | The options to use with the meters and the label strip. |
channelFormat | The channel format to use to initialise the panel. |
References sd::SoundMeter::Options::faderEnabled, sd::SoundMeter::Constants::kMetersPanelId, and sd::SoundMeter::Options::refreshRate.
|
override |
Destructor.
void sd::SoundMeter::MetersComponent::refresh | ( | bool | forceRefresh = false | ) |
Refresh (redraw) the meters panel.
This can be called manually or internally (see useInternalTiming).
forceRefresh | When set to true, always redraw the meters panel (not only if it's dirty/changed). |
References sd::SoundMeter::MeterChannel::refresh().
Referenced by clearMeters(), enable(), and reset().
void sd::SoundMeter::MetersComponent::reset | ( | ) |
Reset the meters.
Initialise the meters, faders and clears all the levels (but not preserves the peak hold).
References refresh(), and sd::SoundMeter::MeterChannel::showTickMarks().
void sd::SoundMeter::MetersComponent::resetMeters | ( | ) |
void sd::SoundMeter::MetersComponent::clearMeters | ( | ) |
Clear the level of the meters.
References refresh().
void sd::SoundMeter::MetersComponent::resetPeakHold | ( | ) |
Reset all peak hold indicators and 'values'.
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.
channel | The channel to set the input level of. |
value | The input level to set to the specified channel. |
void sd::SoundMeter::MetersComponent::setNumChannels | ( | int | numChannels, |
const std::vector< juce::String > & | channelNames = {} |
||
) |
Set the number of channels (meters) in the panel.
numChannels | The number of channels (meters). |
channelNames | The (optional) channel names to use in the header of the meters. |
References 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.
channels | The channel format to use. |
channelNames | The (optional) channel names to use in the header of the meters. |
References resized(), and setChannelNames().
Referenced by setNumChannels().
|
noexcept |
Get the number of meters in the panel.
|
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.
void sd::SoundMeter::MetersComponent::setChannelNames | ( | const std::vector< juce::String > & | channelNames | ) |
Set the channel names to display above the meters.
channelNames | The 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().
void sd::SoundMeter::MetersComponent::setOptions | ( | const Options & | meterOptions | ) |
Set meter options defining appearance and functionality.
meterOptions | The options to apply to the meters and label strip. |
References sd::SoundMeter::MeterChannel::setOptions().
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.
refreshRate | The refresh rate (in Hz). |
References sd::SoundMeter::Options::refreshRate, and sd::SoundMeter::MeterChannel::setRefreshRate().
|
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.
useInternalTiming | When set to true, the meter panel will update itself. |
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).
segmentsOptions | The segments options to create the segments with. |
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.
decay_ms | The time it takes the meter to decay (in ms). |
References sd::SoundMeter::Options::decayTime_ms.
void sd::SoundMeter::MetersComponent::useGradients | ( | bool | useGradients | ) |
Use gradients instead of hard segment boundaries.
useGradients | When set to true, uses smooth gradients. False gives hard segment boundaries. |
References useGradients().
Referenced by useGradients().
void sd::SoundMeter::MetersComponent::setLabelStripPosition | ( | LabelStripPosition | labelStripPosition | ) |
Set the position of the label-strip relative to the meters.
labelStripPosition | The position of the label-strip relative to the meters. |
References resized().
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.
showHeader | When set to true, the 'header' part will be shown. |
References sd::SoundMeter::Options::headerEnabled, resized(), sd::SoundMeter::MeterChannel::showHeader(), and showHeader().
Referenced by showHeader().
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).
showValue | When set to true, the 'value' part will be shown. |
References resized(), showValue(), sd::SoundMeter::MeterChannel::showValue(), and sd::SoundMeter::Options::valueEnabled.
Referenced by showValue().
void sd::SoundMeter::MetersComponent::setFont | ( | const juce::Font & | font | ) |
Set the font to be used in the panel and it's meters.
font | The font to use. |
References sd::SoundMeter::MeterChannel::setFont().
void sd::SoundMeter::MetersComponent::enable | ( | bool | enabled = true | ) |
Enable or disable the panel.
enabled | When set to true, the meters panel will be displayed. |
References sd::SoundMeter::Options::enabled, and refresh().
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.
showTickMarks | When set true, shows the tick-marks. |
References sd::SoundMeter::MeterChannel::showTickMarks(), showTickMarks(), and sd::SoundMeter::Options::tickMarksEnabled.
Referenced by showTickMarks().
|
override |
|
override |
|
override |
|
override |
References sd::SoundMeter::MeterChannel::getLabelStripBounds(), sd::SoundMeter::Constants::kDefaultHeaderLabelWidth, sd::SoundMeter::Constants::kMaxWidth, sd::SoundMeter::Constants::kMinWidth, sd::SoundMeter::left, sd::SoundMeter::none, sd::SoundMeter::right, and sd::SoundMeter::MeterChannel::showTickMarks().
Referenced by setChannelFormat(), setLabelStripPosition(), showHeader(), and showValue().