10 #include "vu_common.h"
16 class VUMeter : public QWidget
21 VUMeter(QWidget *parent);
23 void set_level(float level_lufs) {
24 set_level(level_lufs, level_lufs);
27 void set_level(float level_lufs_left, float level_lufs_right) {
28 std::lock_guard<std::mutex> lock(level_mutex);
29 this->level_lufs[0] = level_lufs_left;
30 this->level_lufs[1] = level_lufs_right;
31 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
34 void set_peak(float peak_lufs) {
35 set_peak(peak_lufs, peak_lufs);
38 void set_peak(float peak_lufs_left, float peak_lufs_right) {
39 std::lock_guard<std::mutex> lock(level_mutex);
40 this->peak_lufs[0] = peak_lufs_left;
41 this->peak_lufs[1] = peak_lufs_right;
42 QMetaObject::invokeMethod(this, "update", Qt::AutoConnection);
45 double lufs_to_pos(float level_lu, int height)
47 return ::lufs_to_pos(level_lu, height, min_level, max_level);
50 void set_min_level(float min_level)
52 this->min_level = min_level;
53 recalculate_pixmaps();
56 void set_max_level(float max_level)
58 this->max_level = max_level;
59 recalculate_pixmaps();
62 void set_ref_level(float ref_level_lufs)
64 this->ref_level_lufs = ref_level_lufs;
68 void resizeEvent(QResizeEvent *event) override;
69 void paintEvent(QPaintEvent *event) override;
70 void recalculate_pixmaps();
72 std::mutex level_mutex;
73 float level_lufs[2] { -HUGE_VALF, -HUGE_VALF };
74 float peak_lufs[2] { -HUGE_VALF, -HUGE_VALF };
75 float min_level = -18.0f, max_level = 9.0f, ref_level_lufs = -23.0f;
77 QPixmap full_on_pixmap, on_pixmap, off_pixmap;