Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/SoundDevelopment/sound_meter

Fully resizing juce peak meter module with optional fader overlay.
https://github.com/SoundDevelopment/sound_meter

analyzer audio dsp juce sound vst

Last synced: 3 months ago
JSON representation

Fully resizing juce peak meter module with optional fader overlay.

Awesome Lists containing this project

README

        

# Sound Meter
[Juce](https://juce.com/) peak meter module with optional fader overlay.


*by Marcel Huibers | [Sound Development](https://www.sounddevelopment.nl) 2023 | Published under the [MIT License](https://en.wikipedia.org/wiki/MIT_License)*

Features:
- Fully **resize-able**.
- **Adaptive**. Will show header, value, tick-marks only when there is space available.
- Unlimited number of user defineable **segments**, with custom ranges and configurable colours or gradients.
- **Efficient**. Only redraws when needed.
- Configurable meter **ballistics** (meter decay).
- **Tick-marks** (dividing lines on the meter) at user specified levels.
- Peak hold **indicator** and optional peak **value** readout.
- Optional **label strip** next to the meters (which can double as master fader).
- Optional **header** identifying the meter's name (set by user) or channel type.
- Optional **fader** and mute button (in the header).

You can find the API documentation [here](https://www.sounddevelopment.nl/sd/resources/documentation/sound_meter/)...


An example project, demonstrating sound_meter can be found [here](https://github.com/SoundDevelopment/sound_meter-example)...

# Usage

All classes are in the namespace `sd::SoundMeter` to avoid collisions. You can either prefix each symbol, or import the namespace.

### MetersComponent

The [MetersComponent](https://www.sounddevelopment.nl/sd/resources/documentation/sound_meter/classsd_1_1SoundMeter_1_1MetersComponent.html) class creates and controls the meters.
This would live in your **editor.h**.
```cpp
private:
sd::SoundMeter::MetersComponent m_meters;
```

In the **constructor** you can specify a channel format with [setChannelFormat](https://www.sounddevelopment.nl/sd/resources/documentation/sound_meter/classsd_1_1SoundMeter_1_1MetersComponent.html#aea27fda8af5ec463436186e8fb3afd20) or set the nummer of channels with [setNumChannels](https://www.sounddevelopment.nl/sd/resources/documentation/sound_meter/classsd_1_1SoundMeter_1_1MetersComponent.html#a042d84e77a91f501c57377d461957e41):
```cpp
m_meters.setChannelFormat (juce::AudioChannelSet::stereo());
```
and configure it's options: (for all meter options, see [documentation](https://www.sounddevelopment.nl/sd/resources/documentation/sound_meter/structsd_1_1SoundMeter_1_1Options.html))
```cpp
sd::SoundMeter::Options meterOptions;
meterOptions.faderEnabled = true;
meterOptions.headerEnabled = true;
meterOptions.showTickMarks = true;
m_meters.setOptions (meterOptions);
```
and configure the segments:
```cpp
std::vector segmentOptions =
{ // From bottom of the meter (0.0f) to the half. Displaying -60 dB up to -18 dB.
{ { -60.0f, -18.0f }, { 0.0f, 0.5f }, juce::Colours::green, juce::Colours::green },
// From half of the meter to almost the top (0.9f). Displaying -18 dB up to -3 dB.
{ { -18.0f, -3.0f }, { 0.5f, 0.90f }, juce::Colours::green, juce::Colours::yellow },
// From almost the top to the top of the meter (1.0f). Displaying -3 dB up to 0 dB.
{ { -3.0f, 0.0f }, { 0.90f, 1.0f }, juce::Colours::yellow, juce::Colours::red } };
m_meters.setMeterSegments (segmentOptions);
```

Finally (still in the **constructor**) we add the component and make it visible:
```cpp
addAndMakeVisible (m_meters);
```

In the `resized()` method, you set the bounds (left, right, width, height) of the meters:
```cpp
m_meters.setBounds (getLocalBounds());
```

### Getting the levels

Basically everything is set up now.

All left to do now is to supply the meter with the level with the method:
`setInputLevel (int channel, float value);`

The recommended way to get the levels from the audio processor is to let the editor poll the audio processor (with a timer for instance).
Preferably it would poll atomic values in the audio processor for thread safety.

A fully working example demonstrating this can be found [here](https://github.com/SoundDevelopment/sound_meter-example)...



-----
*Sound Development 2023*