X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=nageru%2Fmainwindow.cpp;h=e836d46fdc5ffd504256639c9a61f5773cf3b324;hb=f81ae3be1aae619fe4ad022f55d95a4a83ace076;hp=73362229ce35e8efc70f9cf5dcfe4c25a6e73037;hpb=2e1b69c339862fb9b8147bf0ac07d87ca4810d4e;p=nageru diff --git a/nageru/mainwindow.cpp b/nageru/mainwindow.cpp index 7336222..e836d46 100644 --- a/nageru/mainwindow.cpp +++ b/nageru/mainwindow.cpp @@ -23,16 +23,19 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include #include #include #include +#include #include #include #include @@ -40,10 +43,12 @@ #include #include #include -#include #include +#include #include +#include "audio_mixer.h" +#include "midi_mapper.h" #include "shared/aboutdialog.h" #include "alsa_pool.h" #include "analyzer.h" @@ -62,6 +67,7 @@ #include "mixer.h" #include "nonlinear_fader.h" #include "shared/post_to_main_thread.h" +#include "theme.h" #include "ui_audio_expanded_view.h" #include "ui_audio_miniview.h" #include "ui_display.h" @@ -198,7 +204,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); @@ -252,6 +258,9 @@ MainWindow::MainWindow() connect(ui->me_live, &GLWidget::transition_names_updated, this, &MainWindow::set_transition_names); qRegisterMetaType("Mixer::Output"); + connect(ui->me_live, &GLWidget::name_updated, this, &MainWindow::update_channel_name); + connect(ui->me_preview, &GLWidget::name_updated, this, &MainWindow::update_channel_name); + // Hook up the prev/next buttons on the audio views. connect(ui->compact_prev_page, &QAbstractButton::clicked, this, &MainWindow::prev_page); connect(ui->compact_next_page, &QAbstractButton::clicked, this, &MainWindow::next_page); @@ -274,6 +283,26 @@ MainWindow::MainWindow() global_flags.enable_quick_cut_keys = ui->quick_cut_enable_action->isChecked(); }); +#if HAVE_SRT + if (global_flags.srt_port >= 0) { + char title[256]; + snprintf(title, sizeof(title), "Accept new SRT connections on port %d", global_flags.srt_port); + ui->srt_enable_action->setChecked(true); + ui->srt_enable_action->setText(title); + connect(ui->srt_enable_action, &QAction::changed, [this](){ + global_flags.enable_srt = ui->srt_enable_action->isChecked(); + }); + } else { + ui->srt_enable_action->setChecked(false); + ui->srt_enable_action->setEnabled(false); + ui->srt_enable_action->setText("Accept new SRT connections"); + } +#else + ui->srt_enable_action->setChecked(false); + ui->srt_enable_action->setEnabled(false); + ui->srt_enable_action->setText("Accept new SRT connections"); +#endif + last_audio_level_callback = steady_clock::now() - seconds(1); if (!global_flags.midi_mapping_filename.empty()) { @@ -783,7 +812,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) { @@ -808,7 +837,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)); @@ -1177,6 +1208,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); @@ -1202,6 +1246,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); @@ -1419,6 +1472,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 void MainWindow::click_button_if_exists(unsigned bus_idx, T *(Ui_AudioExpandedView::*control)) { @@ -1503,7 +1568,11 @@ void MainWindow::set_transition_names(vector transition_names) void MainWindow::update_channel_name(Mixer::Output output, const string &name) { - if (output >= Mixer::OUTPUT_INPUT0) { + if (output == Mixer::OUTPUT_LIVE) { + ui->label_live->setText(name.c_str()); + } else if (output == Mixer::OUTPUT_PREVIEW) { + ui->label_preview->setText(name.c_str()); + } else if (output >= Mixer::OUTPUT_INPUT0) { unsigned channel = output - Mixer::OUTPUT_INPUT0; previews[channel]->label->setText(name.c_str()); }