]> git.sesse.net Git - nageru/blobdiff - mainwindow.cpp
Set a default locut cutoff, for the benchmark.
[nageru] / mainwindow.cpp
index 261269add87ddd6002ee753eb5aa00b7e7886ce8..f59824cabd053364246c22558df64147ed5991a8 100644 (file)
@@ -343,6 +343,10 @@ void MainWindow::setup_audio_miniview()
 
                connect(ui_audio_miniview->fader, &NonLinearFader::dbValueChanged,
                        bind(&MainWindow::mini_fader_changed, this, bus_index, _1));
+               connect(ui_audio_miniview->peak_display_label, &ClickableLabel::clicked,
+                       [bus_index]() {
+                               global_mixer->get_audio_mixer()->reset_peak(bus_index);
+                       });
        }
 }
 
@@ -365,6 +369,9 @@ void MainWindow::setup_audio_expanded_view()
                ui_audio_expanded_view->bus_desc_label->setFullText(
                        QString::fromStdString(mapping.buses[bus_index].name));
                audio_expanded_views[bus_index] = ui_audio_expanded_view;
+               update_eq_label(bus_index, EQ_BAND_TREBLE, global_mixer->get_audio_mixer()->get_eq(bus_index, EQ_BAND_TREBLE));
+               update_eq_label(bus_index, EQ_BAND_MID, global_mixer->get_audio_mixer()->get_eq(bus_index, EQ_BAND_MID));
+               update_eq_label(bus_index, EQ_BAND_BASS, global_mixer->get_audio_mixer()->get_eq(bus_index, EQ_BAND_BASS));
                // TODO: Set the fader position.
                ui->buses->addWidget(channel);
 
@@ -373,6 +380,13 @@ void MainWindow::setup_audio_expanded_view()
                        global_mixer->get_audio_mixer()->set_locut_enabled(bus_index, state == Qt::Checked);
                });
 
+               connect(ui_audio_expanded_view->treble_knob, &QDial::valueChanged,
+                       bind(&MainWindow::eq_knob_changed, this, bus_index, EQ_BAND_TREBLE, _1));
+               connect(ui_audio_expanded_view->mid_knob, &QDial::valueChanged,
+                       bind(&MainWindow::eq_knob_changed, this, bus_index, EQ_BAND_MID, _1));
+               connect(ui_audio_expanded_view->bass_knob, &QDial::valueChanged,
+                       bind(&MainWindow::eq_knob_changed, this, bus_index, EQ_BAND_BASS, _1));
+
                ui_audio_expanded_view->gainstaging_knob->setValue(global_mixer->get_audio_mixer()->get_gain_staging_db(bus_index));
                ui_audio_expanded_view->gainstaging_auto_checkbox->setChecked(global_mixer->get_audio_mixer()->get_gain_staging_auto(bus_index));
                ui_audio_expanded_view->compressor_enabled->setChecked(global_mixer->get_audio_mixer()->get_compressor_enabled(bus_index));
@@ -395,6 +409,11 @@ void MainWindow::setup_audio_expanded_view()
                peak_meter->set_max_level(0.0f);
                peak_meter->set_ref_level(0.0f);
 
+               connect(ui_audio_expanded_view->peak_display_label, &ClickableLabel::clicked,
+                       [bus_index]() {
+                               global_mixer->get_audio_mixer()->reset_peak(bus_index);
+                       });
+
                // Set up the compression attenuation meter.
                VUMeter *reduction_meter = ui_audio_expanded_view->reduction_meter;
                reduction_meter->set_min_level(0.0f);
@@ -402,6 +421,8 @@ void MainWindow::setup_audio_expanded_view()
                reduction_meter->set_ref_level(0.0f);
                reduction_meter->set_flip(true);
        }
+
+       update_cutoff_labels(global_mixer->get_audio_mixer()->get_locut_cutoff());
 }
 
 void MainWindow::mixer_shutting_down()
@@ -476,7 +497,11 @@ 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);
+       update_cutoff_labels(cutoff_hz);
+}
 
+void MainWindow::update_cutoff_labels(float cutoff_hz)
+{
        char buf[256];
        snprintf(buf, sizeof(buf), "%ld Hz", lrintf(cutoff_hz));
        ui->locut_cutoff_display->setText(buf);
@@ -521,6 +546,33 @@ void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_le
        });
 }
 
+void MainWindow::eq_knob_changed(unsigned bus_index, EQBand band, int value)
+{
+       float gain_db = value * 0.1f;
+       global_mixer->get_audio_mixer()->set_eq(bus_index, band, gain_db);
+
+       update_eq_label(bus_index, band, gain_db);
+}
+
+void MainWindow::update_eq_label(unsigned bus_index, EQBand band, float gain_db)
+{
+       Ui::AudioExpandedView *view = audio_expanded_views[bus_index];
+       string db_string = format_db(gain_db, DB_WITH_SIGN);
+       switch (band) {
+       case EQ_BAND_TREBLE:
+               view->treble_label->setText(QString::fromStdString("Treble: " + db_string));
+               break;
+       case EQ_BAND_MID:
+               view->mid_label->setText(QString::fromStdString("Mid: " + db_string));
+               break;
+       case EQ_BAND_BASS:
+               view->bass_label->setText(QString::fromStdString("Bass: " + db_string));
+               break;
+       default:
+               assert(false);
+       }
+}
+
 void MainWindow::limiter_threshold_knob_changed(int value)
 {
        float threshold_dbfs = value * 0.1f;