]> git.sesse.net Git - nageru/commitdiff
Hook up the reset meters button.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 22:01:34 +0000 (23:01 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 22:01:34 +0000 (23:01 +0100)
mainwindow.cpp
mainwindow.h
mixer.cpp
mixer.h
ui_mainwindow.ui

index 7ec6f0c311077ea613ce3663f3d7da045e362fff..854eb08663176a4a1e1a1fcf627e48d30c2edf98 100644 (file)
@@ -93,6 +93,7 @@ void MainWindow::mixer_created(Mixer *mixer)
        }
 
        connect(ui->locut_cutoff_knob, &QDial::valueChanged, this, &MainWindow::cutoff_knob_changed);
+       connect(ui->reset_meters_button, &QPushButton::clicked, this, &MainWindow::reset_meters_button_clicked);
        mixer->set_audio_level_callback(bind(&MainWindow::audio_level_callback, this, _1, _2, _3, _4, _5, _6));
 }
 
@@ -107,6 +108,13 @@ void MainWindow::cutoff_knob_changed(int value)
        ui->locut_cutoff_display->setText(buf);
 }
 
+void MainWindow::reset_meters_button_clicked()
+{
+       global_mixer->reset_meters();
+       ui->peak_display->setText("-inf");
+       ui->peak_display->setStyleSheet("");
+}
+
 void MainWindow::audio_level_callback(float level_lufs, float peak_db, float global_level_lufs, float range_low_lufs, float range_high_lufs, float auto_gain_staging_db)
 {
        post_to_main_thread([=]() {
index 317d2929c005550dbc565ce409178012e9fdabe6..6b41b0aceb987a4f9b7ff24299eacff36de3a9e0 100644 (file)
@@ -31,6 +31,7 @@ public slots:
        void wb_button_clicked(int channel_number);
        void set_transition_names(std::vector<std::string> transition_names);
        void cutoff_knob_changed(int value);
+       void reset_meters_button_clicked();
        void relayout();
 
 private:
index 656cdfaf39feb9ef67b79464fffacde678c2e5c1..a91b3d8cc843c556dd376946eb05be9988e78e3a 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -599,7 +599,7 @@ void Mixer::process_audio_one_frame()
 //     printf("limiter=%+5.1f  compressor=%+5.1f\n", 20.0*log10(limiter_att), 20.0*log10(compressor_att));
 
        // Find peak and R128 levels.
-       peak = std::max(peak, find_peak(samples_out));
+       peak = max<float>(peak, find_peak(samples_out));
        vector<float> left, right;
        deinterleave_samples(samples_out, &left, &right);
        float *ptrs[] = { left.data(), right.data() };
@@ -694,6 +694,13 @@ void Mixer::channel_clicked(int preview_num)
        theme->channel_clicked(preview_num);
 }
 
+void Mixer::reset_meters()
+{
+       peak = 0.0f;
+       r128.reset();
+       r128.integr_start();
+}
+
 Mixer::OutputChannel::~OutputChannel()
 {
        if (has_current_frame) {
diff --git a/mixer.h b/mixer.h
index 31886fd707a2c411f9167346add045ca3154edcb..6725a7f46e242fe44bdba8a7c0e583b422b42102 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -136,6 +136,8 @@ public:
                locut_cutoff_hz = cutoff_hz;
        }
 
+       void reset_meters();
+
 private:
        void bm_frame(unsigned card_index, uint16_t timecode,
                FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format,
@@ -212,7 +214,7 @@ private:
        Ebu_r128_proc r128;
 
        // TODO: Implement oversampled peak detection.
-       float peak = 0.0f;
+       std::atomic<float> peak{0.0f};
 
        StereoFilter locut;  // Default cutoff 150 Hz, 24 dB/oct.
        std::atomic<float> locut_cutoff_hz;
index 4e43711aa1a6ebfe5f8de58c3fe07159578a6301..81b9b1a4aa47736b9ca6a24f819246f3d172b131 100644 (file)
            </layout>
           </item>
           <item>
-           <widget class="QPushButton" name="pushButton">
+           <widget class="QPushButton" name="reset_meters_button">
             <property name="maximumSize">
              <size>
               <width>30</width>