X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=839f1b359e1a9060fdb64a8cfdd942b0f42c26ea;hb=778fe6ec989e7ed640a6c3d209099b6be3945bba;hp=bbafc25d05ecf275bba006d4e14fe58c96bc7b2d;hpb=e2cfcb0bb745bb1869acbcb49e5a105715e28f2a;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index bbafc25..839f1b3 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -956,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)); @@ -1468,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.) @@ -1494,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]{