]> git.sesse.net Git - nageru/commitdiff
Hook up the level compressor auto checkbox.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 11 Jan 2016 20:45:34 +0000 (21:45 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 11 Jan 2016 20:45:34 +0000 (21:45 +0100)
mainwindow.cpp
mixer.cpp
mixer.h

index b78751f4de2d933d514d74b5cbbd209b12311b89..fbfbecda05fbb3eb4afe92ce03766d3bb1ea9376 100644 (file)
@@ -109,6 +109,10 @@ 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->gainstaging_auto_checkbox, &QCheckBox::stateChanged, [this](int state){
+               global_mixer->set_gainstaging_auto(state == Qt::Checked);
+       });
+
        connect(ui->limiter_threshold_knob, &QDial::valueChanged, this, &MainWindow::limiter_threshold_knob_changed);
        connect(ui->compressor_threshold_knob, &QDial::valueChanged, this, &MainWindow::compressor_threshold_knob_changed);
        connect(ui->limiter_enabled, &QCheckBox::stateChanged, [this](int state){
index 618ce31eccebf9ff8a6d40303fb187768dc611bf..dd8cc6013d72559bb08b89c6d5605953ac6b4269 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -715,7 +715,7 @@ void Mixer::process_audio_one_frame(int64_t frame_pts_int, int num_samples)
        // then apply a makeup gain to get it to -14 dBFS. -14 dBFS is, of course,
        // entirely arbitrary, but from practical tests with speech, it seems to
        // put ut around -23 LUFS, so it's a reasonable starting point for later use.
-       {
+       if (level_compressor_enabled) {
                float threshold = 0.01f;   // -40 dBFS.
                float ratio = 20.0f;
                float attack_time = 0.5f;
diff --git a/mixer.h b/mixer.h
index db6db15155bacb85fd0fe011296cf770422039f5..682aea4dc24902b6343659867a61e855f7ec0e5c 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -169,6 +169,11 @@ public:
                compressor_enabled = enabled;
        }
 
+       void set_gainstaging_auto(bool enabled)
+       {
+               level_compressor = enabled;
+       }
+
        void schedule_cut()
        {
                should_cut = true;
@@ -272,6 +277,7 @@ private:
        // First compressor; takes us up to about -12 dBFS.
        StereoCompressor level_compressor;
        float last_gain_staging_db = 0.0f;
+       std::atomic<bool> level_compressor_enabled{true};
 
        static constexpr float ref_level_dbfs = -14.0f;