-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlrameter.h
67 lines (53 loc) · 1.36 KB
/
lrameter.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
#ifndef LRAMETER_H
#define LRAMETER_H
#include <math.h>
#include <QPixmap>
#include <QString>
#include <QWidget>
#include <mutex>
#include "vu_common.h"
class QObject;
class QPaintEvent;
class QResizeEvent;
class LRAMeter : public QWidget
{
Q_OBJECT
public:
LRAMeter(QWidget *parent);
void set_levels(float level_lufs, float range_low_lufs, float range_high_lufs) {
std::unique_lock<std::mutex> lock(level_mutex);
this->level_lufs = level_lufs;
this->range_low_lufs = range_low_lufs;
this->range_high_lufs = range_high_lufs;
QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
}
double lufs_to_pos(float level_lu, int height)
{
return ::lufs_to_pos(level_lu, height, min_level, max_level);
}
void set_min_level(float min_level)
{
this->min_level = min_level;
recalculate_pixmaps();
}
void set_max_level(float max_level)
{
this->max_level = max_level;
recalculate_pixmaps();
}
void set_ref_level(float ref_level_lufs)
{
this->ref_level_lufs = ref_level_lufs;
}
private:
void resizeEvent(QResizeEvent *event) override;
void paintEvent(QPaintEvent *event) override;
void recalculate_pixmaps();
std::mutex level_mutex;
float level_lufs = -HUGE_VAL;
float range_low_lufs = -HUGE_VAL;
float range_high_lufs = -HUGE_VAL;
float min_level = -18.0f, max_level = 9.0f, ref_level_lufs = -23.0f;
QPixmap on_pixmap, off_pixmap;
};
#endif