X-Git-Url: https://git.sesse.net/?p=nageru;a=blobdiff_plain;f=vumeter.h;h=7a9420058358f30047f8f2d3645eaa972ec51895;hp=1fecf7e9cfcd34a0af9e05bad31bccf2df59a30b;hb=703e00da89118df9be0354dda621bed023e6030e;hpb=2240961e8ff2285171fb236c9a8566613b682cee diff --git a/vumeter.h b/vumeter.h index 1fecf7e..7a94200 100644 --- a/vumeter.h +++ b/vumeter.h @@ -2,13 +2,17 @@ #define VUMETER_H #include -#include -#include +#include +#include #include #include #include "vu_common.h" +class QObject; +class QPaintEvent; +class QResizeEvent; + class VUMeter : public QWidget { Q_OBJECT @@ -27,6 +31,17 @@ public: QMetaObject::invokeMethod(this, "update", Qt::AutoConnection); } + void set_peak(float peak_lufs) { + set_peak(peak_lufs, peak_lufs); + } + + void set_peak(float peak_lufs_left, float peak_lufs_right) { + std::unique_lock lock(level_mutex); + this->peak_lufs[0] = peak_lufs_left; + this->peak_lufs[1] = peak_lufs_right; + 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); @@ -49,12 +64,6 @@ public: this->ref_level_lufs = ref_level_lufs; } - void set_flip(bool flip) - { - this->flip = flip; - recalculate_pixmaps(); - } - private: void resizeEvent(QResizeEvent *event) override; void paintEvent(QPaintEvent *event) override; @@ -62,10 +71,10 @@ private: std::mutex level_mutex; float level_lufs[2] { -HUGE_VALF, -HUGE_VALF }; + float peak_lufs[2] { -HUGE_VALF, -HUGE_VALF }; float min_level = -18.0f, max_level = 9.0f, ref_level_lufs = -23.0f; - bool flip = false; - QPixmap on_pixmap, off_pixmap; + QPixmap full_on_pixmap, on_pixmap, off_pixmap; }; #endif