painter.fillRect(0, 0, width(), height(), parentWidget()->palette().window());
float level_lufs;
+ float range_low_lufs;
+ float range_high_lufs;
{
unique_lock<mutex> lock(level_mutex);
level_lufs = this->level_lufs;
+ range_low_lufs = this->range_low_lufs;
+ range_high_lufs = this->range_high_lufs;
}
float level_lu = level_lufs + 23.0f;
+ float range_low_lu = range_low_lufs + 23.0f;
+ float range_high_lu = range_high_lufs + 23.0f;
const int margin = 5;
- draw_vu_meter(painter, level_lu, width(), height(), margin);
+ draw_vu_meter(painter, range_low_lu, range_high_lu, width(), height(), margin);
// Draw the target area (+/-1 LU is allowed EBU range).
+ // It turns green when we're within.
int min_y = lufs_to_pos(1.0f, height());
int max_y = lufs_to_pos(-1.0f, height());
painter.setPen(pen);
painter.drawRect(2, min_y, width() - 5, max_y - min_y);
}
+
+ // Draw the integrated loudness meter, in the same color as the target area.
+ int y = lufs_to_pos(level_lu, height());
+ {
+ QPen pen(Qt::black);
+ pen.setWidth(5);
+ painter.setPen(pen);
+ painter.drawRect(2, y, width() - 5, 1);
+ }
+ {
+ QPen pen;
+ if (level_lu >= -1.0f && level_lu <= 1.0f) {
+ pen.setColor(Qt::green);
+ } else {
+ pen.setColor(Qt::red);
+ }
+ pen.setWidth(3);
+ painter.setPen(pen);
+ painter.drawRect(2, y, width() - 5, 1);
+ }
}
return y;
}
-void draw_vu_meter(QPainter &painter, float level_lu, int width, int height, int margin)
+void draw_vu_meter(QPainter &painter, float range_low_lu, float range_high_lu, int width, int height, int margin)
{
painter.fillRect(margin, 0, width - 2 * margin, height, Qt::black);
on.setColorAt(1.0f, QColor(0, 255, 0));
QColor off(80, 80, 80);
- int y = lufs_to_pos(level_lu, height);
+ int min_on_y = lufs_to_pos(range_high_lu, height);
+ int max_on_y = lufs_to_pos(range_low_lu, height);
// Draw bars colored up until the level, then gray from there.
for (int level = -18; level < 9; ++level) {
int min_y = lufs_to_pos(level + 1.0f, height) + 1;
int max_y = lufs_to_pos(level, height) - 1;
- if (y > max_y) {
- painter.fillRect(margin, min_y, width - 2 * margin, max_y - min_y, off);
- } else if (y < min_y) {
- painter.fillRect(margin, min_y, width - 2 * margin, max_y - min_y, on);
- } else {
- painter.fillRect(margin, min_y, width - 2 * margin, y - min_y, off);
- painter.fillRect(margin, y, width - 2 * margin, max_y - y, on);
+ painter.fillRect(margin, min_y, width - 2 * margin, max_y - min_y, off);
+ int min_draw_y = std::max(min_y, min_on_y);
+ int max_draw_y = std::min(max_y, max_on_y);
+ if (min_draw_y < max_draw_y) {
+ painter.fillRect(margin, min_draw_y, width - 2 * margin, max_draw_y - min_draw_y, on);
}
}
}
#include <QPainter>
int lufs_to_pos(float level_lu, int height);
-void draw_vu_meter(QPainter &painter, float level_lu, int width, int height, int margin);
+void draw_vu_meter(QPainter &painter, float range_low_lu, float range_high_lu, int width, int height, int margin);
#endif // !defined(_VU_COMMON_H)
{
QPainter painter(this);
- painter.fillRect(0, 0, width(), height(), Qt::black);
-
- // Draw some reference bars.
- for (int level = -18; level < 9; ++level) {
- int min_y = lufs_to_pos(level, height()) - 1;
- int max_y = lufs_to_pos(level + 1.0f, height()) + 1;
-
- // Recommended range is 0 LU +/- 1 LU.
- if (level == -1 || level == 0) {
- painter.fillRect(1, min_y, width() - 2, max_y - min_y, Qt::green);
- } else {
- painter.fillRect(1, min_y, width() - 2, max_y - min_y, QColor(80, 80, 80));
- }
- }
-
float level_lufs;
{
unique_lock<mutex> lock(level_mutex);
}
float level_lu = level_lufs + 23.0f;
- int y = lufs_to_pos(level_lu, height());
- painter.fillRect(0, y, width(), 2, Qt::white);
+ draw_vu_meter(painter, -HUGE_VAL, level_lu, width(), height(), 0);
}