]> git.sesse.net Git - nageru/commitdiff
Make the faders in the expanded audio view work.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Mon, 22 Aug 2016 18:49:26 +0000 (20:49 +0200)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 19 Oct 2016 22:55:44 +0000 (00:55 +0200)
mainwindow.cpp
mainwindow.h

index 68f3aaf268df57f27a62263cba473186fcaa1a9a..99e8cc328bfeb1f77c58cd47dd7a4776cede46dd 100644 (file)
@@ -79,6 +79,18 @@ void slave_checkbox(QCheckBox *master, QCheckBox *slave)
        });
 }
 
+void slave_fader(NonLinearFader *master, NonLinearFader *slave)
+{
+       QWidget::connect(master, &NonLinearFader::dbValueChanged, [slave](double value) {
+               slave->blockSignals(true);
+               slave->setDbValue(value);
+               slave->blockSignals(false);
+       });
+       QWidget::connect(slave, &NonLinearFader::dbValueChanged, [master](double value){
+               master->setDbValue(value);
+       });
+}
+
 constexpr unsigned DB_NO_FLAGS = 0x0;
 constexpr unsigned DB_WITH_SIGN = 0x1;
 constexpr unsigned DB_BARE = 0x2;
@@ -296,7 +308,7 @@ void MainWindow::setup_audio_miniview()
                ui->faders->addWidget(channel);
 
                connect(ui_audio_miniview->fader, &NonLinearFader::dbValueChanged,
-                       bind(&MainWindow::mini_fader_changed, this, ui_audio_miniview, bus_index, _1));
+                       bind(&MainWindow::mini_fader_changed, this, bus_index, _1));
        }
 }
 
@@ -322,8 +334,7 @@ void MainWindow::setup_audio_expanded_view()
                // TODO: Set the fader position.
                ui->buses->addWidget(channel);
 
-               //connect(ui_audio_expanded_view->fader, &NonLinearFader::dbValueChanged,
-               //      bind(&MainWindow::mini_fader_changed, this, ui_audio_expanded_view, bus_index, _1));
+               slave_fader(audio_miniviews[bus_index]->fader, ui_audio_expanded_view->fader);
        }
 }
 
@@ -452,17 +463,13 @@ void MainWindow::compressor_threshold_knob_changed(int value)
                QString::fromStdString(format_db(threshold_dbfs, DB_WITH_SIGN)));
 }
 
-void MainWindow::mini_fader_changed(Ui::AudioMiniView *ui, int channel, double volume_db)
+void MainWindow::mini_fader_changed(int bus, 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");
-       }
+       QString label(QString::fromStdString(format_db(volume_db, DB_WITH_SIGN)));
+       audio_miniviews[bus]->fader_label->setText(label);
+       audio_expanded_views[bus]->fader_label->setText(label);
 
-       global_mixer->get_audio_mixer()->set_fader_volume(channel, volume_db);
+       global_mixer->get_audio_mixer()->set_fader_volume(bus, volume_db);
 }
 
 void MainWindow::reset_meters_button_clicked()
index ff05b1994039afe1426a163192a3e9712da4c8de..ff33b7ffa04964c3b6e6ba00e19c34b5a194fd49 100644 (file)
@@ -52,7 +52,7 @@ public slots:
        void cutoff_knob_changed(int value);
        void limiter_threshold_knob_changed(int value);
        void compressor_threshold_knob_changed(int value);
-       void mini_fader_changed(Ui::AudioMiniView *ui, int channel, double db_volume);
+       void mini_fader_changed(int bus, double db_volume);
        void reset_meters_button_clicked();
        void relayout();