]> git.sesse.net Git - nageru/commitdiff
Make it possible to click the bus peak label to reset it.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 28 Aug 2016 21:47:52 +0000 (23:47 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
Makefile
audio_mixer.cpp
audio_mixer.h
clickable_label.h [new file with mode: 0644]
mainwindow.cpp
ui_audio_expanded_view.ui
ui_audio_miniview.ui

index b939b95fb03de3b88a52dac0262f7ebbeaa856f0..055f811557e0cfd80d5ab7e114fadb6497a083f0 100644 (file)
--- 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
index 18a669f0eb8bcfe399b09cbf305d8718617b6203..193d221627cfce48738795d5200476bf972d3c76 100644 (file)
@@ -768,3 +768,16 @@ InputMapping AudioMixer::get_input_mapping() const
        lock_guard<timed_mutex> lock(audio_mutex);
        return input_mapping;
 }
+
+void AudioMixer::reset_peak(unsigned bus_index)
+{
+       lock_guard<timed_mutex> 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;
+       }
+}
index 29016eb9ea7e07a68257bb8c02b6617edc4c4b6d..88c2f880cac0fee500d087abec37d1ff9eed1230 100644 (file)
@@ -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 (file)
index 0000000..cc82168
--- /dev/null
@@ -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 <QLabel>
+
+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)
index 261269add87ddd6002ee753eb5aa00b7e7886ce8..2ef1da4502435bffe0a2ceb1354c134b1bd1a345 100644 (file)
@@ -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);
index d48721face3bcc5e10c3b97cb3e8c0b3ce9f86a9..8e431b47d6b09f5bf89d3aa512c901b0f143266d 100644 (file)
         </layout>
        </item>
        <item>
-        <widget class="QLabel" name="peak_display_label">
+        <widget class="ClickableLabel" name="peak_display_label">
          <property name="minimumSize">
           <size>
            <width>60</width>
    <extends>QLabel</extends>
    <header>ellipsis_label.h</header>
   </customwidget>
+  <customwidget>
+   <class>ClickableLabel</class>
+   <extends>QLabel</extends>
+   <header>clickable_label.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
index 96c0bd8ebd4469291f91bc159d09847ddcdfc8f1..0761931d29202cc2dddf87db6c608e4ddf0d9572 100644 (file)
                </layout>
               </item>
               <item>
-               <widget class="QLabel" name="peak_display_label">
+               <widget class="ClickableLabel" name="peak_display_label">
                 <property name="minimumSize">
                  <size>
                   <width>30</width>
    <extends>QSlider</extends>
    <header>nonlinear_fader.h</header>
   </customwidget>
+  <customwidget>
+   <class>ClickableLabel</class>
+   <extends>QLabel</extends>
+   <header>clickable_label.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>