X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=mainwindow.cpp;h=b542c1093243dc15af5ae006c0b274b5e9c06352;hb=e5a0d3dfb676087bdcef4c82876234782e46604c;hp=bbafc25d05ecf275bba006d4e14fe58c96bc7b2d;hpb=e2cfcb0bb745bb1869acbcb49e5a105715e28f2a;p=nageru diff --git a/mainwindow.cpp b/mainwindow.cpp index bbafc25..b542c10 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -301,6 +301,9 @@ MainWindow::MainWindow() } midi_mapper.refresh_highlights(); midi_mapper.refresh_lights(); + if (global_flags.fullscreen) { + QMainWindow::showFullScreen(); + } } void MainWindow::resizeEvent(QResizeEvent* event) @@ -557,6 +560,7 @@ void MainWindow::setup_audio_expanded_view() ui_audio_expanded_view->bus_desc_label->setFullText( QString::fromStdString(get_bus_desc_label(mapping.buses[bus_index]))); audio_expanded_views[bus_index] = ui_audio_expanded_view; + update_stereo_knob_and_label(bus_index, lrintf(100.0f * global_audio_mixer->get_stereo_width(bus_index))); 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)); update_eq_label(bus_index, EQ_BAND_BASS, global_audio_mixer->get_eq(bus_index, EQ_BAND_BASS)); @@ -572,6 +576,9 @@ void MainWindow::setup_audio_expanded_view() midi_mapper.refresh_lights(); }); + connect(ui_audio_expanded_view->stereo_width_knob, &QDial::valueChanged, + bind(&MainWindow::stereo_width_knob_changed, this, bus_index, _1)); + 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, @@ -805,6 +812,14 @@ void MainWindow::report_disk_space(off_t free_bytes, double estimated_seconds_le }); } +void MainWindow::stereo_width_knob_changed(unsigned bus_index, int value) +{ + float stereo_width = value * 0.01f; + global_audio_mixer->set_stereo_width(bus_index, stereo_width); + + update_stereo_label(bus_index, value); +} + void MainWindow::eq_knob_changed(unsigned bus_index, EQBand band, int value) { float gain_db = value * 0.1f; @@ -813,6 +828,34 @@ void MainWindow::eq_knob_changed(unsigned bus_index, EQBand band, int value) update_eq_label(bus_index, band, gain_db); } +void MainWindow::update_stereo_knob_and_label(unsigned bus_index, int stereo_width_percent) +{ + Ui::AudioExpandedView *view = audio_expanded_views[bus_index]; + + if (global_audio_mixer->is_mono(bus_index)) { + view->stereo_width_knob->setEnabled(false); + view->stereo_width_label->setEnabled(false); + } else { + view->stereo_width_knob->setEnabled(true); + view->stereo_width_label->setEnabled(true); + } + view->stereo_width_knob->setValue(stereo_width_percent); + update_stereo_label(bus_index, stereo_width_percent); +} + +void MainWindow::update_stereo_label(unsigned bus_index, int stereo_width_percent) +{ + Ui::AudioExpandedView *view = audio_expanded_views[bus_index]; + + if (global_audio_mixer->is_mono(bus_index)) { + view->stereo_width_label->setText("Mono"); + } else { + char buf[256]; + snprintf(buf, sizeof(buf), "Stereo: %d%%", stereo_width_percent); + view->stereo_width_label->setText(buf); + } +} + void MainWindow::update_eq_label(unsigned bus_index, EQBand band, float gain_db) { Ui::AudioExpandedView *view = audio_expanded_views[bus_index]; @@ -956,11 +999,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)); @@ -1096,6 +1141,11 @@ void MainWindow::set_makeup_gain(float value) set_relative_value(ui->makeup_gain_knob, value); } +void MainWindow::set_stereo_width(unsigned bus_idx, float value) +{ + set_relative_value_if_exists(bus_idx, &Ui::AudioExpandedView::stereo_width_knob, value); +} + void MainWindow::set_treble(unsigned bus_idx, float value) { set_relative_value_if_exists(bus_idx, &Ui::AudioExpandedView::treble_knob, value); @@ -1218,6 +1268,11 @@ void MainWindow::highlight_makeup_gain(bool highlight) }); } +void MainWindow::highlight_stereo_width(unsigned bus_idx, bool highlight) +{ + highlight_control_if_exists(bus_idx, &Ui::AudioExpandedView::stereo_width_knob, highlight); +} + void MainWindow::highlight_treble(unsigned bus_idx, bool highlight) { highlight_control_if_exists(bus_idx, &Ui::AudioExpandedView::treble_knob, highlight); @@ -1468,7 +1523,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 +1551,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]{