From: Steinar H. Gunderson Date: Mon, 11 Jan 2016 20:45:34 +0000 (+0100) Subject: Hook up the level compressor auto checkbox. X-Git-Tag: 1.0.0~23 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=a76872873dda7a4fc9f41972486c234699f43b23 Hook up the level compressor auto checkbox. --- diff --git a/mainwindow.cpp b/mainwindow.cpp index b78751f..fbfbecd 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -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){ diff --git a/mixer.cpp b/mixer.cpp index 618ce31..dd8cc60 100644 --- 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 db6db15..682aea4 100644 --- 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 level_compressor_enabled{true}; static constexpr float ref_level_dbfs = -14.0f;