Sound Meter 0.9.0
Fully resizing logarithmic JUCE meter module.
|
An individual meter channel. More...
#include <sd_MeterChannel.h>
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 |
An individual meter channel.
This represents a single meter. Use the MetersComponent to create multiple meters matching the specified channel format.
using sd::SoundMeter::MeterChannel::ChannelType = juce::AudioChannelSet::ChannelType |
using sd::SoundMeter::MeterChannel::Ptr = juce::Component::SafePointer<MeterChannel> |
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. |
|
noexcept |
Default constructor.
sd::SoundMeter::MeterChannel::MeterChannel | ( | const Options & | meterOptions, |
Padding | padding, | ||
const juce::String & | channelName, | ||
bool | isLabelStrip = false , |
||
ChannelType | channelType = ChannelType::unknown |
||
) |
Parameterized constructor.
meterOptions | Meter options to use (defining appearance and functionality). |
padding | The padding to use (space between meter and the edge of the component). |
channelName | The channel name (set by the user). |
isLabelStrip | When set to true, this meter will function as a label strip (with markers for levels at the tick-marks). |
channelType | The channel type (left, right, center, etc...). |
References setChannelType(), setIsLabelStrip(), setOptions(), and setPadding().
void sd::SoundMeter::MeterChannel::reset | ( | ) |
Reset the meter (but not the peak hold).
References sd::SoundMeter::Level::reset().
Referenced by setActive().
void sd::SoundMeter::MeterChannel::refresh | ( | bool | forceRefresh | ) |
Refresh the meter with the current input level.
forceRefresh | When set to true, the meter will be forced to repaint (even if not dirty). |
References sd::SoundMeter::Level::getDirtyBounds(), sd::SoundMeter::Level::getMeterBounds(), and sd::SoundMeter::Level::refreshMeterLevel().
Referenced by sd::SoundMeter::MetersComponent::refresh().
void sd::SoundMeter::MeterChannel::setRefreshRate | ( | float | refreshRate_hz | ) |
Sets the meter's refresh rate.
Set this to optimize the meter's decay rate.
refreshRate_hz | Refresh rate in Hz. |
References sd::SoundMeter::Level::setRefreshRate().
Referenced by sd::SoundMeter::MetersComponent::setRefreshRate().
void sd::SoundMeter::MeterChannel::setDecay | ( | float | decay_ms | ) |
Set meter decay.
decay_ms | Meter decay in milliseconds. |
References sd::SoundMeter::Level::setDecay().
|
noexcept |
Set the padding of the meter.
The padding is the space between the meter and the edges of the component.
padding | Amount of padding to apply. |
Referenced by MeterChannel().
|
noexcept |
Get meter decay.
References sd::SoundMeter::Level::getDecay().
void sd::SoundMeter::MeterChannel::setInputLevel | ( | float | inputLevel | ) |
Set the input level from the audio engine.
Called from the audio thread!
inputLevel | New input level (in amp). |
References sd::SoundMeter::Level::setInputLevel().
void sd::SoundMeter::MeterChannel::setOptions | ( | const Options & | meterOptions | ) |
Set the meter's options.
The options determine the appearance and functionality of the meter.
meterOptions | Meter options to use. |
References sd::SoundMeter::Options::enabled, sd::SoundMeter::Options::faderEnabled, sd::SoundMeter::Options::headerEnabled, sd::SoundMeter::Level::setMeterOptions(), and showHeader().
Referenced by MeterChannel(), sd::SoundMeter::MetersComponent::setOptions(), setTickMarks(), showPeakHold(), showTickMarks(), showTickMarksOnTop(), showValue(), and useGradients().
void sd::SoundMeter::MeterChannel::setActive | ( | bool | isActive, |
NotificationOptions | notify = NotificationOptions::dontNotify |
||
) |
Activate or deactivate (mute) the meter.
isActive | When set to true, the meter is active. |
notify | Determine whether to notify all listeners or not. |
References isActive(), sd::SoundMeter::notify, and reset().
|
noexcept |
Check if the meter is active (un-muted).
Referenced by paint(), and setActive().
|
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.
isLabelStrip | when set, this meter behave like a label strip. |
Referenced by MeterChannel().
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).
segmentsOptions | The segments options to create the segments with. |
References sd::SoundMeter::Level::setMeterSegments().
void sd::SoundMeter::MeterChannel::resetPeakHold | ( | ) |
Reset the peak hold.
Resets the peak hold indicator and value.
References sd::SoundMeter::Level::resetPeakHold().
void sd::SoundMeter::MeterChannel::showPeakHold | ( | bool | showPeakHold = true | ) |
Show (or hide) the peak hold indicator.
showPeakHold | When set true, the peak hold indicator will be shown. |
References setOptions(), showPeakHold(), and sd::SoundMeter::Options::showPeakHoldIndicator.
Referenced by showPeakHold().
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.
showValue | When set true, shows the 'value' level (in dB) part below the meter. |
References setOptions(), showValue(), and sd::SoundMeter::Options::valueEnabled.
Referenced by sd::SoundMeter::MetersComponent::showValue(), and showValue().
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.
headerVisible | When 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().
void sd::SoundMeter::MeterChannel::setFont | ( | const juce::Font & | font | ) |
Set the meter font.
Font to be used for the header, value and label strip.
font | The font to use. |
References sd::SoundMeter::Header::setFont().
Referenced by sd::SoundMeter::MetersComponent::setFont().
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.
channelName | Name to assign to this meter. |
References sd::SoundMeter::Header::getBounds(), and sd::SoundMeter::Header::setName().
void sd::SoundMeter::MeterChannel::setChannelType | ( | ChannelType | channelType | ) |
Set the channel type.
For instance: left, right, center, etc..
channelType | The channel type assigned to the meter. |
References sd::SoundMeter::Header::setType().
Referenced by MeterChannel().
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.
name | The name to check the width of. |
widthAvailable | The width (in pixels) available to fit the name in. |
References sd::SoundMeter::Header::textFits().
Referenced by autoSetMinimalMode().
|
noexcept |
Get the width (in pixels) of the channel info in the 'header' part.
References sd::SoundMeter::Header::getNameWidth().
|
noexcept |
Get the width (in pixels) of the full type description in the 'header' part.
References sd::SoundMeter::Header::getTypeWidth().
|
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.
referredTypeWidth | The width (in pixels) to use when deciding what to display in the header. |
References sd::SoundMeter::Header::setReferredWidth().
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.
showTickMarks | When set true, the tick-marks are enabled. |
References setOptions(), showTickMarks(), and sd::SoundMeter::Options::tickMarksEnabled.
Referenced by sd::SoundMeter::MetersComponent::reset(), sd::SoundMeter::MetersComponent::resized(), showTickMarks(), and sd::SoundMeter::MetersComponent::showTickMarks().
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.
showTickMarksOnTop | Show the tick-marks on top of the level. |
References setOptions(), showTickMarksOnTop(), and sd::SoundMeter::Options::tickMarksOnTop.
Referenced by showTickMarksOnTop().
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.
tickMarks | List of tick mark values (in decibels). |
References setOptions(), and sd::SoundMeter::Options::tickMarks.
|
noexcept |
Get 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().
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.
minimalMode | When set to true, 'minimal' mode will be enabled. |
References sd::SoundMeter::Level::setMinimalMode(), showHeader(), and sd::SoundMeter::Options::useMinimalMode.
Referenced by autoSetMinimalMode().
|
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.
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.
proposedWidth | The width use to determine if the meter would be in 'minimal' mode. |
proposedHeight | The height use to determine if the meter would be in 'minimal' mode. |
References sd::SoundMeter::Constants::kMinModeHeightThreshold, sd::SoundMeter::Constants::kMinModeWidthThreshold, nameFits(), and setMinimalMode().
void sd::SoundMeter::MeterChannel::useGradients | ( | bool | useGradients | ) |
Use gradients in stead of hard segment boundaries.
useGradients | When set to true, uses smooth gradients. False gives hard segment boundaries. |
References setOptions(), sd::SoundMeter::Options::useGradient, and useGradients().
Referenced by useGradients().
|
override |
|
override |
|
override |
References visibilityChanged().
|
override |
Referenced by lookAndFeelChanged().