From 593173ffcdbccff777720b3c41c3e771fa93a10a Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 17 Jan 2016 21:01:21 +0100 Subject: [PATCH] Make the locut filter possible to disable. --- mainwindow.cpp | 3 +++ mixer.cpp | 4 +++- mixer.h | 8 +++++++- ui_mainwindow.ui | 17 ++++++++++------- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 77daf07..5535c15 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -110,6 +110,9 @@ void MainWindow::mixer_created(Mixer *mixer) connect(ui->locut_cutoff_knob, &QDial::valueChanged, this, &MainWindow::cutoff_knob_changed); cutoff_knob_changed(ui->locut_cutoff_knob->value()); + connect(ui->locut_enabled, &QCheckBox::stateChanged, [this](int state){ + global_mixer->set_locut_enabled(state == Qt::Checked); + }); // Not QDial::valueChanged, as we call setValue() all the time. connect(ui->gainstaging_knob, &QAbstractSlider::sliderMoved, this, &MainWindow::gain_staging_knob_changed); diff --git a/mixer.cpp b/mixer.cpp index 39bae19..cfdb5b1 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -709,7 +709,9 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples) // we don't need it for voice, and it will reduce headroom // and confuse the compressor. (In particular, any hums at 50 or 60 Hz // should be dampened.) - locut.render(samples_out.data(), samples_out.size() / 2, locut_cutoff_hz * 2.0 * M_PI / OUTPUT_FREQUENCY, 0.5f); + if (locut_enabled) { + locut.render(samples_out.data(), samples_out.size() / 2, locut_cutoff_hz * 2.0 * M_PI / OUTPUT_FREQUENCY, 0.5f); + } // Apply a level compressor to get the general level right. // Basically, if it's over about -40 dBFS, we squeeze it down to that level diff --git a/mixer.h b/mixer.h index 961c2a6..3c1a952 100644 --- a/mixer.h +++ b/mixer.h @@ -141,6 +141,11 @@ public: locut_cutoff_hz = cutoff_hz; } + void set_locut_enabled(bool enabled) + { + locut_enabled = enabled; + } + float get_limiter_threshold_dbfs() { return limiter_threshold_dbfs; @@ -295,8 +300,9 @@ private: Resampler peak_resampler; std::atomic peak{0.0f}; - StereoFilter locut; // Default cutoff 150 Hz, 24 dB/oct. + StereoFilter locut; // Default cutoff 120 Hz, 24 dB/oct. std::atomic locut_cutoff_hz; + std::atomic locut_enabled{true}; // First compressor; takes us up to about -12 dBFS. StereoCompressor level_compressor; // Under compressor_mutex. Used to set/override gain_staging_db if . diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index cc041a8..2d7031c 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -623,13 +623,6 @@ - - - - - - - @@ -824,6 +817,16 @@ + + + + Enabled + + + true + + + -- 2.39.2