]> git.sesse.net Git - nageru/blobdiff - nageru/mainwindow.cpp
Add metrics for how many frames we are decoding, but did not have the time to display.
[nageru] / nageru / mainwindow.cpp
index f2adbf240c94a6e42afe8a2238553075f7cfcc38..20f8e50dbc6ec189310b20e6b7337d19b826062d 100644 (file)
@@ -198,7 +198,7 @@ MainWindow::MainWindow()
        global_mainwindow = this;
        ui->setupUi(this);
 
-       global_disk_space_estimator = new DiskSpaceEstimator(bind(&MainWindow::report_disk_space, this, _1, _2));
+       global_disk_space_estimator = new DiskSpaceEstimator(bind(&MainWindow::report_disk_space, this, _1, _2, _3));
        disk_free_label = new QLabel(this);
        disk_free_label->setStyleSheet("QLabel {padding-right: 5px;}");
        ui->menuBar->setCornerWidget(disk_free_label);
@@ -786,7 +786,7 @@ void MainWindow::update_cutoff_labels(float cutoff_hz)
        }
 }
 
-void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left)
+void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_left, double file_length_seconds)
 {
        char time_str[256];
        if (estimated_seconds_left < 60.0) {
@@ -811,7 +811,9 @@ void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_le
        char buf[256];
        snprintf(buf, sizeof(buf), "Disk free: %'.0f MB (approx. %s)", free_bytes / 1048576.0, time_str);
 
-       std::string label = buf;
+       // NOTE: The default formatter does not use file_length_seconds for anything,
+       // but the theme might want to do so.
+       std::string label = global_mixer->format_status_line(buf, file_length_seconds);
 
        post_to_main_thread([this, label]{
                disk_free_label->setText(QString::fromStdString(label));
@@ -1180,6 +1182,19 @@ void MainWindow::set_treble(unsigned bus_idx, float value)
        set_relative_value_if_exists(bus_idx, &Ui::AudioExpandedView::treble_knob, value);
 }
 
+void MainWindow::set_eq_absolute(unsigned bus_idx, EQBand eq_band, float value_db)
+{
+       if (eq_band == EQ_BAND_TREBLE) {
+               set_db_value_if_exists(bus_idx, &Ui::AudioExpandedView::treble_knob, value_db);
+       } else if (eq_band == EQ_BAND_MID) {
+               set_db_value_if_exists(bus_idx, &Ui::AudioExpandedView::mid_knob, value_db);
+       } else if (eq_band == EQ_BAND_BASS) {
+               set_db_value_if_exists(bus_idx, &Ui::AudioExpandedView::bass_knob, value_db);
+       } else {
+               assert(false);
+       }
+}
+
 void MainWindow::set_mid(unsigned bus_idx, float value)
 {
        set_relative_value_if_exists(bus_idx, &Ui::AudioExpandedView::mid_knob, value);
@@ -1205,6 +1220,15 @@ void MainWindow::set_fader(unsigned bus_idx, float value)
        set_relative_value_if_exists(bus_idx, &Ui::AudioExpandedView::fader, value);
 }
 
+void MainWindow::set_fader_absolute(unsigned bus_idx, float value_db)
+{
+       if (global_audio_mixer != nullptr &&
+           global_audio_mixer->get_mapping_mode() == AudioMixer::MappingMode::MULTICHANNEL &&
+           bus_idx < audio_expanded_views.size()) {
+               audio_expanded_views[bus_idx]->fader->setDbValue(value_db);
+       }
+}
+
 void MainWindow::toggle_mute(unsigned bus_idx)
 {
        click_button_if_exists(bus_idx, &Ui::AudioExpandedView::mute_button);
@@ -1422,6 +1446,18 @@ void MainWindow::set_relative_value_if_exists(unsigned bus_idx, T *(Ui_AudioExpa
        }
 }
 
+void MainWindow::set_db_value_if_exists(unsigned bus_idx, QDial *(Ui_AudioExpandedView::*control), float value_db)
+{
+       post_to_main_thread([this, bus_idx, control, value_db]{
+               if (global_audio_mixer != nullptr &&
+                   global_audio_mixer->get_mapping_mode() == AudioMixer::MappingMode::MULTICHANNEL &&
+                   bus_idx < audio_expanded_views.size()) {
+                       int value = lrintf(value_db * 10.0f);
+                       (audio_expanded_views[bus_idx]->*control)->setValue(value);
+               }
+       });
+}
+
 template<class T>
 void MainWindow::click_button_if_exists(unsigned bus_idx, T *(Ui_AudioExpandedView::*control))
 {