+ // The label will be updated by the audio level callback.
+}
+
+void MainWindow::final_makeup_gain_knob_changed(int value)
+{
+ ui->makeup_gain_auto_checkbox->setCheckState(Qt::Unchecked);
+
+ float gain_db = value * 0.1f;
+ global_mixer->get_audio_mixer()->set_final_makeup_gain_db(gain_db);
+
+ // The label will be updated by the audio level callback.
+}
+
+void MainWindow::cutoff_knob_changed(int value)
+{
+ float octaves = value * 0.1f;
+ float cutoff_hz = 20.0 * pow(2.0, octaves);
+ global_mixer->get_audio_mixer()->set_locut_cutoff(cutoff_hz);
+
+ char buf[256];
+ snprintf(buf, sizeof(buf), "%ld Hz", lrintf(cutoff_hz));
+ ui->locut_cutoff_display->setText(buf);
+}
+
+void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left)
+{
+ char time_str[256];
+ if (estimated_seconds_left < 60.0) {
+ strcpy(time_str, "<font color=\"red\">Less than a minute</font>");
+ } else if (estimated_seconds_left < 1800.0) { // Less than half an hour: Xm Ys (red).
+ int s = lrintf(estimated_seconds_left);
+ int m = s / 60;
+ s %= 60;
+ snprintf(time_str, sizeof(time_str), "<font color=\"red\">%dm %ds</font>", m, s);
+ } else if (estimated_seconds_left < 3600.0) { // Less than an hour: Xm.
+ int m = lrintf(estimated_seconds_left / 60.0);
+ snprintf(time_str, sizeof(time_str), "%dm", m);
+ } else if (estimated_seconds_left < 36000.0) { // Less than ten hours: Xh Ym.
+ int m = lrintf(estimated_seconds_left / 60.0);
+ int h = m / 60;
+ m %= 60;
+ snprintf(time_str, sizeof(time_str), "%dh %dm", h, m);
+ } else { // More than ten hours: Xh.
+ int h = lrintf(estimated_seconds_left / 3600.0);
+ snprintf(time_str, sizeof(time_str), "%dh", h);
+ }
+ char buf[256];
+ snprintf(buf, sizeof(buf), "Disk free: %'.0f MB (approx. %s)", free_bytes / 1048576.0, time_str);
+
+ std::string label = buf;
+
+ post_to_main_thread([this, label]{
+ disk_free_label->setText(QString::fromStdString(label));
+ ui->menuBar->setCornerWidget(disk_free_label); // Need to set this again for the sizing to get right.
+ });
+}
+
+void MainWindow::limiter_threshold_knob_changed(int value)
+{
+ float threshold_dbfs = value * 0.1f;
+ global_mixer->get_audio_mixer()->set_limiter_threshold_dbfs(threshold_dbfs);
+ ui->limiter_threshold_db_display->setText(
+ QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
+}
+
+void MainWindow::compressor_threshold_knob_changed(int value)
+{
+ float threshold_dbfs = value * 0.1f;
+ global_mixer->get_audio_mixer()->set_compressor_threshold_dbfs(threshold_dbfs);
+ ui->compressor_threshold_db_display->setText(
+ QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
+}
+
+void MainWindow::mini_fader_changed(Ui::AudioMiniView *ui, int channel, double volume_db)
+{
+ char buf[256];
+ if (isfinite(volume_db)) {
+ snprintf(buf, sizeof(buf), "%+.1f dB", volume_db);
+ ui->fader_label->setText(buf);
+ } else {
+ ui->fader_label->setText("-∞ dB");
+ }
+
+ global_mixer->get_audio_mixer()->set_fader_volume(channel, volume_db);
+}
+
+void MainWindow::reset_meters_button_clicked()
+{
+ global_mixer->get_audio_mixer()->reset_meters();
+ ui->peak_display->setText(QString::fromStdString(format_db(-HUGE_VAL, DB_WITH_SIGN | DB_BARE)));
+ ui->peak_display->setStyleSheet("");
+}
+
+void MainWindow::audio_level_callback(float level_lufs, float peak_db, vector<float> bus_level_lufs,
+ float global_level_lufs,
+ float range_low_lufs, float range_high_lufs,
+ float gain_staging_db, float final_makeup_gain_db,
+ float correlation)
+{
+ steady_clock::time_point now = steady_clock::now();
+
+ // 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 = duration<double>(now - last_audio_level_callback).count();
+ if (last_update_age < 0.100) {
+ return;
+ }
+ last_audio_level_callback = now;
+
+ post_to_main_thread([=]() {