From: Steinar H. Gunderson Date: Sun, 28 Aug 2016 21:47:52 +0000 (+0200) Subject: Make it possible to click the bus peak label to reset it. X-Git-Tag: 1.4.0~69 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=c3a08ff6100840205d295a58d6bf340aa20afde0 Make it possible to click the bus peak label to reset it. --- diff --git a/Makefile b/Makefile index b939b95..055f811 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ LDLIBS=$(shell pkg-config --libs $(PKG_MODULES)) -pthread -lva -lva-drm -lva-x11 # Qt objects OBJS=glwidget.o main.o mainwindow.o vumeter.o lrameter.o vu_common.o correlation_meter.o aboutdialog.o input_mapping_dialog.o nonlinear_fader.o -OBJS += glwidget.moc.o mainwindow.moc.o vumeter.moc.o lrameter.moc.o correlation_meter.moc.o aboutdialog.moc.o ellipsis_label.moc.o input_mapping_dialog.moc.o nonlinear_fader.moc.o +OBJS += glwidget.moc.o mainwindow.moc.o vumeter.moc.o lrameter.moc.o correlation_meter.moc.o aboutdialog.moc.o ellipsis_label.moc.o input_mapping_dialog.moc.o nonlinear_fader.moc.o clickable_label.moc.o # Mixer objects AUDIO_MIXER_OBJS = audio_mixer.o alsa_input.o ebu_r128_proc.o stereocompressor.o resampling_queue.o flags.o correlation_measurer.o filter.o disk_space_estimator.o diff --git a/audio_mixer.cpp b/audio_mixer.cpp index 18a669f..193d221 100644 --- a/audio_mixer.cpp +++ b/audio_mixer.cpp @@ -768,3 +768,16 @@ InputMapping AudioMixer::get_input_mapping() const lock_guard lock(audio_mutex); return input_mapping; } + +void AudioMixer::reset_peak(unsigned bus_index) +{ + lock_guard lock(audio_mutex); + for (unsigned channel = 0; channel < 2; ++channel) { + PeakHistory &history = peak_history[bus_index][channel]; + history.current_level = 0.0f; + history.historic_peak = 0.0f; + history.current_peak = 0.0f; + history.last_peak = 0.0f; + history.age_seconds = 0.0f; + } +} diff --git a/audio_mixer.h b/audio_mixer.h index 29016eb..88c2f88 100644 --- a/audio_mixer.h +++ b/audio_mixer.h @@ -201,6 +201,8 @@ public: return final_makeup_gain_auto; } + void reset_peak(unsigned bus_index); + struct BusLevel { float current_level_dbfs[2]; // Digital peak of last frame, left and right. float peak_level_dbfs[2]; // Digital peak with hold, left and right. @@ -280,7 +282,7 @@ private: float last_peak = 0.0f; float age_seconds = 0.0f; // Time since "last_peak" was set. }; - PeakHistory peak_history[MAX_BUSES][2]; // Separate for each channel. + PeakHistory peak_history[MAX_BUSES][2]; // Separate for each channel. Under audio_mutex. double final_makeup_gain = 1.0; // Under compressor_mutex. Read/write by the user. Note: Not in dB, we want the numeric precision so that we can change it slowly. bool final_makeup_gain_auto = true; // Under compressor_mutex. diff --git a/clickable_label.h b/clickable_label.h new file mode 100644 index 0000000..cc82168 --- /dev/null +++ b/clickable_label.h @@ -0,0 +1,26 @@ +#ifndef _CLICKABLE_LABEL_H +#define _CLICKABLE_LABEL_H 1 + +// Just like a normal QLabel, except that it can also emit a clicked signal. + +#include + +class QMouseEvent; + +class ClickableLabel : public QLabel { + Q_OBJECT + +public: + ClickableLabel(QWidget *parent) : QLabel(parent) {} + +signals: + void clicked(); + +protected: + void mousePressEvent(QMouseEvent *event) override + { + emit clicked(); + } +}; + +#endif // !defined(_CLICKABLE_LABEL_H) diff --git a/mainwindow.cpp b/mainwindow.cpp index 261269a..2ef1da4 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -343,6 +343,10 @@ void MainWindow::setup_audio_miniview() connect(ui_audio_miniview->fader, &NonLinearFader::dbValueChanged, bind(&MainWindow::mini_fader_changed, this, bus_index, _1)); + connect(ui_audio_miniview->peak_display_label, &ClickableLabel::clicked, + [bus_index]() { + global_mixer->get_audio_mixer()->reset_peak(bus_index); + }); } } @@ -395,6 +399,11 @@ void MainWindow::setup_audio_expanded_view() peak_meter->set_max_level(0.0f); peak_meter->set_ref_level(0.0f); + connect(ui_audio_expanded_view->peak_display_label, &ClickableLabel::clicked, + [bus_index]() { + global_mixer->get_audio_mixer()->reset_peak(bus_index); + }); + // Set up the compression attenuation meter. VUMeter *reduction_meter = ui_audio_expanded_view->reduction_meter; reduction_meter->set_min_level(0.0f); diff --git a/ui_audio_expanded_view.ui b/ui_audio_expanded_view.ui index d48721f..8e431b4 100644 --- a/ui_audio_expanded_view.ui +++ b/ui_audio_expanded_view.ui @@ -383,7 +383,7 @@ - + 60 @@ -452,6 +452,11 @@ QLabel
ellipsis_label.h
+ + ClickableLabel + QLabel +
clickable_label.h
+
diff --git a/ui_audio_miniview.ui b/ui_audio_miniview.ui index 96c0bd8..0761931 100644 --- a/ui_audio_miniview.ui +++ b/ui_audio_miniview.ui @@ -231,7 +231,7 @@
- + 30 @@ -344,6 +344,11 @@ QSlider
nonlinear_fader.h
+ + ClickableLabel + QLabel +
clickable_label.h
+