From 0d7183f398856c9331e58808d0374e63593334b6 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 8 Nov 2015 23:01:34 +0100 Subject: [PATCH] Hook up the reset meters button. --- mainwindow.cpp | 8 ++++++++ mainwindow.h | 1 + mixer.cpp | 9 ++++++++- mixer.h | 4 +++- ui_mainwindow.ui | 2 +- 5 files changed, 21 insertions(+), 3 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 7ec6f0c..854eb08 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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([=]() { diff --git a/mainwindow.h b/mainwindow.h index 317d292..6b41b0a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -31,6 +31,7 @@ public slots: void wb_button_clicked(int channel_number); void set_transition_names(std::vector transition_names); void cutoff_knob_changed(int value); + void reset_meters_button_clicked(); void relayout(); private: diff --git a/mixer.cpp b/mixer.cpp index 656cdfa..a91b3d8 100644 --- 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(peak, find_peak(samples_out)); vector 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 31886fd..6725a7f 100644 --- 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 peak{0.0f}; StereoFilter locut; // Default cutoff 150 Hz, 24 dB/oct. std::atomic locut_cutoff_hz; diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 4e43711..81b9b1a 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -361,7 +361,7 @@ - + 30 -- 2.39.2