X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=839f1b359e1a9060fdb64a8cfdd942b0f42c26ea;hb=a5746714e6ca1e665bf9e74344e67712443f947a;hp=077942ec11afdaea8c6c2ec84d8b8291928f15cc;hpb=c3cbe8c3093e818311a133d0cb8141e5125b9b27;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index 077942e..839f1b3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -175,6 +175,21 @@ void set_peak_label(QLabel *peak_label, float peak_db) } } +string get_bus_desc_label(const InputMapping::Bus &bus) +{ + string suffix; + if (bus.device.type == InputSourceType::ALSA_INPUT) { + ALSAPool::Device::State state = global_audio_mixer->get_alsa_card_state(bus.device.index); + if (state == ALSAPool::Device::State::STARTING) { + suffix = " (busy)"; + } else if (state == ALSAPool::Device::State::DEAD) { + suffix = " (dead)"; + } + } + + return bus.name + suffix; +} + } // namespace MainWindow::MainWindow() @@ -321,8 +336,15 @@ void MainWindow::mixer_created(Mixer *mixer) connect(ui_display->display, &GLWidget::color_updated, this, &MainWindow::update_channel_color); // Hook up the keyboard key. - QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); - connect(shortcut, &QShortcut::activated, bind(&MainWindow::channel_clicked, this, i)); + QShortcut *shortcut = nullptr; + if (i < 9) { + shortcut = new QShortcut(QKeySequence(Qt::Key_1 + i), this); + } else if (i == 9) { + shortcut = new QShortcut(QKeySequence(Qt::Key_0), this); + } + if (shortcut != nullptr) { + connect(shortcut, &QShortcut::activated, bind(&MainWindow::channel_clicked, this, i)); + } // Hook up the quick-cut key. if (i < strlen(qwerty)) { @@ -490,7 +512,7 @@ void MainWindow::setup_audio_miniview() Ui::AudioMiniView *ui_audio_miniview = new Ui::AudioMiniView; ui_audio_miniview->setupUi(channel); ui_audio_miniview->bus_desc_label->setFullText( - QString::fromStdString(mapping.buses[bus_index].name)); + QString::fromStdString(get_bus_desc_label(mapping.buses[bus_index]))); audio_miniviews[bus_index] = ui_audio_miniview; // Set up the peak meter. @@ -533,7 +555,7 @@ void MainWindow::setup_audio_expanded_view() Ui::AudioExpandedView *ui_audio_expanded_view = new Ui::AudioExpandedView; ui_audio_expanded_view->setupUi(channel); ui_audio_expanded_view->bus_desc_label->setFullText( - QString::fromStdString(mapping.buses[bus_index].name)); + QString::fromStdString(get_bus_desc_label(mapping.buses[bus_index]))); audio_expanded_views[bus_index] = ui_audio_expanded_view; update_eq_label(bus_index, EQ_BAND_TREBLE, global_audio_mixer->get_eq(bus_index, EQ_BAND_TREBLE)); update_eq_label(bus_index, EQ_BAND_MID, global_audio_mixer->get_eq(bus_index, EQ_BAND_MID)); @@ -934,11 +956,13 @@ void MainWindow::audio_level_callback(float level_lufs, float peak_db, vectorpeak_display, peak_db); // NOTE: Will be invisible when using multitrack audio. - ui->gainstaging_knob->blockSignals(true); - ui->gainstaging_knob->setValue(lrintf(bus_levels[0].gain_staging_db * 10.0f)); - ui->gainstaging_knob->blockSignals(false); - ui->gainstaging_db_display->setText( - QString::fromStdString(format_db(bus_levels[0].gain_staging_db, DB_WITH_SIGN))); + if (!bus_levels.empty()) { + ui->gainstaging_knob->blockSignals(true); + ui->gainstaging_knob->setValue(lrintf(bus_levels[0].gain_staging_db * 10.0f)); + ui->gainstaging_knob->blockSignals(false); + ui->gainstaging_db_display->setText( + QString::fromStdString(format_db(bus_levels[0].gain_staging_db, DB_WITH_SIGN))); + } ui->makeup_gain_knob->blockSignals(true); ui->makeup_gain_knob->setValue(lrintf(final_makeup_gain_db * 10.0f)); @@ -1446,7 +1470,9 @@ bool MainWindow::eventFilter(QObject *watched, QEvent *event) QApplication::restoreOverrideCursor(); if (watched == previews[current_wb_pick_display]->display) { const QMouseEvent *mouse_event = (QMouseEvent *)event; - set_white_balance(current_wb_pick_display, mouse_event->x(), mouse_event->y()); + previews[current_wb_pick_display]->display->grab_white_balance( + current_wb_pick_display, + mouse_event->x(), mouse_event->y()); } else { // The user clicked on something else, give up. // (The click goes through, which might not be ideal, but, yes.) @@ -1472,34 +1498,6 @@ void MainWindow::closeEvent(QCloseEvent *event) event->accept(); } -namespace { - -double srgb_to_linear(double x) -{ - if (x < 0.04045) { - return x / 12.92; - } else { - return pow((x + 0.055) / 1.055, 2.4); - } -} - -} // namespace - -void MainWindow::set_white_balance(int channel_number, int x, int y) -{ - // Set the white balance to neutral for the grab. It's probably going to - // flicker a bit, but hopefully this display is not live anyway. - global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, 0.5, 0.5, 0.5); - previews[channel_number]->display->updateGL(); - QRgb reference_color = previews[channel_number]->display->grabFrameBuffer().pixel(x, y); - - double r = srgb_to_linear(qRed(reference_color) / 255.0); - double g = srgb_to_linear(qGreen(reference_color) / 255.0); - double b = srgb_to_linear(qBlue(reference_color) / 255.0); - global_mixer->set_wb(Mixer::OUTPUT_INPUT0 + channel_number, r, g, b); - previews[channel_number]->display->updateGL(); -} - void MainWindow::audio_state_changed() { post_to_main_thread([this]{ @@ -1508,21 +1506,11 @@ void MainWindow::audio_state_changed() } InputMapping mapping = global_audio_mixer->get_input_mapping(); for (unsigned bus_index = 0; bus_index < mapping.buses.size(); ++bus_index) { - const InputMapping::Bus &bus = mapping.buses[bus_index]; - string suffix; - if (bus.device.type == InputSourceType::ALSA_INPUT) { - ALSAPool::Device::State state = global_audio_mixer->get_alsa_card_state(bus.device.index); - if (state == ALSAPool::Device::State::STARTING) { - suffix = " (busy)"; - } else if (state == ALSAPool::Device::State::DEAD) { - suffix = " (dead)"; - } - } - + string label = get_bus_desc_label(mapping.buses[bus_index]); audio_miniviews[bus_index]->bus_desc_label->setFullText( - QString::fromStdString(bus.name + suffix)); + QString::fromStdString(label)); audio_expanded_views[bus_index]->bus_desc_label->setFullText( - QString::fromStdString(bus.name + suffix)); + QString::fromStdString(label)); } }); }