]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Refactor the fade chain generation a bit.
[nageru] / mainwindow.cpp
index a19a4560ab1c69b5bae9f42d871d16fff511d47f..8a91a3f630dc031ac8414a07fda84af2feb5d768 100644 (file)
@@ -92,7 +92,15 @@ void MainWindow::mixer_created(Mixer *mixer)
                connect(ui_display->wb_button, &QPushButton::clicked, bind(&MainWindow::wb_button_clicked, this, i));
        }
 
+       char buf[256];
+       snprintf(buf, sizeof(buf), "%.1f dB", mixer->get_limiter_threshold_dbfs());
+       ui->limiter_threshold_db_display->setText(buf);
+       snprintf(buf, sizeof(buf), "%.1f dB", mixer->get_compressor_threshold_dbfs());
+       ui->compressor_threshold_db_display->setText(buf);
+
        connect(ui->locut_cutoff_knob, &QDial::valueChanged, this, &MainWindow::cutoff_knob_changed);
+       cutoff_knob_changed(ui->locut_cutoff_knob->value());
+
        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){
@@ -145,6 +153,18 @@ void MainWindow::reset_meters_button_clicked()
 
 void MainWindow::audio_level_callback(float level_lufs, float peak_db, float global_level_lufs, float range_low_lufs, float range_high_lufs, float auto_gain_staging_db)
 {
+       timeval now;
+       gettimeofday(&now, nullptr);
+
+       // The meters are somewhat inefficient to update. Only update them
+       // every 100 ms or so (we get updates every 5–20 ms).
+       double last_update_age = now.tv_sec - last_audio_level_callback.tv_sec +
+               1e-6 * (now.tv_usec - last_audio_level_callback.tv_usec);
+       if (last_update_age < 0.100) {
+               return;
+       }
+       last_audio_level_callback = now;
+
        post_to_main_thread([=]() {
                ui->vu_meter->set_level(level_lufs);
                ui->lra_meter->set_levels(global_level_lufs, range_low_lufs, range_high_lufs);