-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGainVuMeter.h
73 lines (55 loc) · 1.92 KB
/
GainVuMeter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
Copyright 2020 Dario Mambro
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <JuceHeader.h>
#include <array>
/**
* A simple Component implementing a gain VU meter, useful to show gain
* reduction in dynamic processors.
*/
class GainVuMeter
: public Component
, public Timer
{
public:
GainVuMeter(
std::array<std::atomic<float>*, 2> source,
float range = 36.f,
std::function<float(float)> scaling = [](float x) { return std::sqrt(x); },
Colour lowColour = Colours::green,
Colour highColour = Colours::red,
Colour backgroundColour = Colours::black);
void paint(Graphics& g) override;
void resized() override;
void mouseDown(MouseEvent const& event) override;
Colour backgroundColour = Colours::black;
Colour internalColour = Colours::transparentBlack;
Colour labelColour = Colours::lightgrey;
Colour lineColour = Colours::grey;
int fontSize = 10;
float range;
void setColours(Colour lowColour, Colour highColour);
std::function<float(float)> scaling;
std::array<std::atomic<float>*, 2> source;
private:
void timerCallback() override { repaint(); }
void updateGradients();
void reset();
Colour lowColour;
Colour highColour;
ColourGradient topGradient;
ColourGradient bottomGradient;
std::array<float, 2> minValue = { { 0.f, 0.f } };
std::array<float, 2> maxValue = { { 0.f, 0.f } };
};