]> git.sesse.net Git - nageru/commitdiff
Hook up the lo-cut knob. A bit crude for now, though.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 19:11:23 +0000 (20:11 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 8 Nov 2015 19:11:23 +0000 (20:11 +0100)
mainwindow.cpp
mixer.cpp
mixer.h
ui_mainwindow.ui

index d4e4d62d3fab6cb87fafb089dd458f2937ac7905..76293c83167994a207a6524e03ae7d4fe63efbde 100644 (file)
@@ -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);
index 506af4aeabb95fa8d554cc32baf80dfe5c61b3ff..1e494073f8f568a965d17b80970dcd7ee9f59629 100644 (file)
--- 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 312566d891e0371eac7ebf765299480fec074f42..e561a52edd37b856b936fe4c47f163bbf7da622e 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -10,6 +10,7 @@
 
 #include <movit/effect_chain.h>
 #include <movit/flat_input.h>
+#include <atomic>
 #include <condition_variable>
 #include <cstddef>
 #include <functional>
@@ -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<float> locut_cutoff_hz;
 
        // First compressor; takes us up to about -12 dBFS.
        StereoCompressor level_compressor;
index 9a7030be9c709aaa5d592e3edca17cb38fde4686..4e43711aa1a6ebfe5f8de58c3fe07159578a6301 100644 (file)
          </widget>
         </item>
         <item row="1" column="0">
-         <widget class="QDial" name="dial_2">
+         <widget class="QDial" name="locut_cutoff_knob">
           <property name="sizePolicy">
            <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
             <horstretch>0</horstretch>
          </widget>
         </item>
         <item row="2" column="0">
-         <widget class="QLabel" name="label_4">
+         <widget class="QLabel" name="locut_cutoff_display">
           <property name="text">
            <string>150 Hz</string>
           </property>