From 43a8f1a2c2f1c61861d9499b2fdb02d325fbc559 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sun, 8 Nov 2015 20:11:23 +0100 Subject: [PATCH] Hook up the lo-cut knob. A bit crude for now, though. --- mainwindow.cpp | 10 ++++++++++ mixer.cpp | 2 +- mixer.h | 9 ++++++++- ui_mainwindow.ui | 4 ++-- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index d4e4d62..76293c8 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -91,6 +91,16 @@ void MainWindow::mixer_created(Mixer *mixer) connect(ui_display->wb_button, &QPushButton::clicked, std::bind(&MainWindow::wb_button_clicked, this, i)); } + connect(ui->locut_cutoff_knob, &QDial::valueChanged, [this](int value) { + float octaves = value * 0.1f; + float cutoff_hz = 20.0 * pow(2.0, octaves); + global_mixer->set_locut_cutoff(cutoff_hz); + + char buf[256]; + snprintf(buf, sizeof(buf), "%ld Hz", lrintf(cutoff_hz)); + ui->locut_cutoff_display->setText(buf); + }); + mixer->set_audio_level_callback([this](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([=]() { ui->vu_meter->set_level(level_lufs); diff --git a/mixer.cpp b/mixer.cpp index 506af4a..1e49407 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -544,7 +544,7 @@ void Mixer::process_audio_one_frame() // Cut away everything under 150 Hz; 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, 150.0 * 2.0 * M_PI / OUTPUT_FREQUENCY, 0.5f); + 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 312566d..e561a52 100644 --- a/mixer.h +++ b/mixer.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -130,6 +131,11 @@ public: theme->set_wb(channel, r, g, b); } + void set_locut_cutoff(float cutoff_hz) + { + locut_cutoff_hz = cutoff_hz; + } + private: void bm_frame(unsigned card_index, uint16_t timecode, FrameAllocator::Frame video_frame, size_t video_offset, uint16_t video_format, @@ -208,7 +214,8 @@ private: // TODO: Implement oversampled peak detection. float peak = 0.0f; - StereoFilter locut; // Cutoff 150 Hz, 24 dB/oct. + StereoFilter locut; // Default cutoff 150 Hz, 24 dB/oct. + std::atomic locut_cutoff_hz; // First compressor; takes us up to about -12 dBFS. StereoCompressor level_compressor; diff --git a/ui_mainwindow.ui b/ui_mainwindow.ui index 9a7030b..4e43711 100644 --- a/ui_mainwindow.ui +++ b/ui_mainwindow.ui @@ -454,7 +454,7 @@ - + 0 @@ -489,7 +489,7 @@ - + 150 Hz -- 2.39.2