mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
UI: Change meter color to red when audio is clipping
Closes jp9000/obs-studio#738
This commit is contained in:
+10
-4
@@ -3,6 +3,7 @@
|
||||
#include "obs-app.hpp"
|
||||
#include "mute-checkbox.hpp"
|
||||
#include "slider-absoluteset-style.hpp"
|
||||
#include <obs-audio-controls.h>
|
||||
#include <util/platform.h>
|
||||
#include <util/threading.h>
|
||||
#include <QHBoxLayout>
|
||||
@@ -265,7 +266,10 @@ VolumeMeter::VolumeMeter(QWidget *parent)
|
||||
magColor.setRgb(0x20, 0x7D, 0x17);
|
||||
peakColor.setRgb(0x3E, 0xF1, 0x2B);
|
||||
peakHoldColor.setRgb(0x00, 0x00, 0x00);
|
||||
|
||||
|
||||
clipColor1.setRgb(0x7F, 0x00, 0x00);
|
||||
clipColor2.setRgb(0xFF, 0x00, 0x00);
|
||||
|
||||
updateTimerRef = updateTimer.toStrongRef();
|
||||
if (!updateTimerRef) {
|
||||
updateTimerRef = QSharedPointer<VolumeMeterTimer>::create();
|
||||
@@ -329,15 +333,17 @@ void VolumeMeter::paintEvent(QPaintEvent *event)
|
||||
int scaledPeak = int((float)width * curPeak);
|
||||
int scaledPeakHold = int((float)width * curPeakHold);
|
||||
|
||||
float db = obs_volmeter_get_cur_db(OBS_FADER_LOG, curPeakHold);
|
||||
|
||||
gradient.setStart(qreal(scaledMag), 0);
|
||||
gradient.setFinalStop(qreal(scaledPeak), 0);
|
||||
gradient.setColorAt(0, magColor);
|
||||
gradient.setColorAt(1, peakColor);
|
||||
gradient.setColorAt(0, db == 0.0f ? clipColor1 : magColor);
|
||||
gradient.setColorAt(1, db == 0.0f ? clipColor2 : peakColor);
|
||||
|
||||
// RMS
|
||||
painter.fillRect(0, 0,
|
||||
scaledMag, height,
|
||||
magColor);
|
||||
db == 0.0f ? clipColor1 : magColor);
|
||||
|
||||
// RMS - Peak gradient
|
||||
painter.fillRect(scaledMag, 0,
|
||||
|
||||
@@ -31,6 +31,7 @@ private:
|
||||
uint64_t lastUpdateTime = 0;
|
||||
|
||||
QColor bkColor, magColor, peakColor, peakHoldColor;
|
||||
QColor clipColor1, clipColor2;
|
||||
|
||||
public:
|
||||
explicit VolumeMeter(QWidget *parent = 0);
|
||||
|
||||
Reference in New Issue
Block a user