diff options
| author | Carl Hetherington <cth@carlh.net> | 2026-04-09 00:20:52 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2026-04-09 00:20:52 +0200 |
| commit | 89153136197b3cfa33101235b72d4e1df932b9d4 (patch) | |
| tree | 0c0bf4730ed29d1a1350af02848a6186cf064d38 /src | |
| parent | 6444512433d87e60975eb6243f968709a261b7ba (diff) | |
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/audio_dialog.cc | 238 | ||||
| -rw-r--r-- | src/wx/audio_dialog.h | 20 |
2 files changed, 129 insertions, 129 deletions
diff --git a/src/wx/audio_dialog.cc b/src/wx/audio_dialog.cc index e0fed493d..797c14356 100644 --- a/src/wx/audio_dialog.cc +++ b/src/wx/audio_dialog.cc @@ -59,12 +59,12 @@ using namespace boost::placeholders; * @param content Content to analyse, or 0 to analyse all of the film's audio. */ AudioDialog::AudioDialog(wxWindow* parent, shared_ptr<Film> film, shared_ptr<Content> content) - : wxDialog ( + : wxDialog( parent, wxID_ANY, _("Audio"), wxDefaultPosition, - wxSize (640, 512), + wxSize(640, 512), #ifdef DCPOMATIC_OSX /* I can't get wxFRAME_FLOAT_ON_PARENT to work on OS X, and although wxSTAY_ON_TOP keeps the window above all others (and not just our own) it's better than nothing for now. @@ -74,57 +74,57 @@ AudioDialog::AudioDialog(wxWindow* parent, shared_ptr<Film> film, shared_ptr<Con wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT #endif ) - , _film (film) - , _content (content) - , _channels (film->audio_channels ()) - , _plot (nullptr) + , _film(film) + , _content(content) + , _channels(film->audio_channels()) + , _plot(nullptr) { - wxFont subheading_font (*wxNORMAL_FONT); - subheading_font.SetWeight (wxFONTWEIGHT_BOLD); + wxFont subheading_font(*wxNORMAL_FONT); + subheading_font.SetWeight(wxFONTWEIGHT_BOLD); - auto overall_sizer = new wxBoxSizer (wxVERTICAL); - auto lr_sizer = new wxBoxSizer (wxHORIZONTAL); + auto overall_sizer = new wxBoxSizer(wxVERTICAL); + auto lr_sizer = new wxBoxSizer(wxHORIZONTAL); - auto left = new wxBoxSizer (wxVERTICAL); + auto left = new wxBoxSizer(wxVERTICAL); _cursor = new StaticText(this, char_to_wx("Cursor: none")); - left->Add (_cursor, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_cursor, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); _plot = new AudioPlot(this); - left->Add (_plot, 1, wxTOP | wxEXPAND, 12); + left->Add(_plot, 1, wxTOP | wxEXPAND, 12); _sample_peak = new StaticText(this, {}); - left->Add (_sample_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_sample_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); _true_peak = new StaticText(this, {}); - left->Add (_true_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_true_peak, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); _integrated_loudness = new StaticText(this, {}); - left->Add (_integrated_loudness, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_integrated_loudness, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); _loudness_range = new StaticText(this, {}); - left->Add (_loudness_range, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_loudness_range, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); _leqm = new StaticText(this, {}); - left->Add (_leqm, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); + left->Add(_leqm, 0, wxTOP, DCPOMATIC_SIZER_Y_GAP); - lr_sizer->Add (left, 1, wxALL | wxEXPAND, 12); + lr_sizer->Add(left, 1, wxALL | wxEXPAND, 12); - auto right = new wxBoxSizer (wxVERTICAL); + auto right = new wxBoxSizer(wxVERTICAL); { - auto m = new StaticText (this, _("Channels")); - m->SetFont (subheading_font); - right->Add (m, 1, wxTOP | wxBOTTOM, 16); + auto m = new StaticText(this, _("Channels")); + m->SetFont(subheading_font); + right->Add(m, 1, wxTOP | wxBOTTOM, 16); } for (int i = 0; i < MAX_DCP_AUDIO_CHANNELS; ++i) { - _channel_checkbox[i] = new CheckBox (this, std_to_wx(audio_channel_name(i))); + _channel_checkbox[i] = new CheckBox(this, std_to_wx(audio_channel_name(i))); _channel_checkbox[i]->SetForegroundColour(wxColour(_plot->colour(i))); - right->Add (_channel_checkbox[i], 0, wxEXPAND | wxALL, 3); + right->Add(_channel_checkbox[i], 0, wxEXPAND | wxALL, 3); _channel_checkbox[i]->bind(&AudioDialog::channel_clicked, this, _1); } - show_or_hide_channel_checkboxes (); + show_or_hide_channel_checkboxes(); { - auto m = new StaticText (this, _("Type")); - m->SetFont (subheading_font); - right->Add (m, 1, wxTOP, 16); + auto m = new StaticText(this, _("Type")); + m->SetFont(subheading_font); + right->Add(m, 1, wxTOP, 16); } wxString const types[] = { @@ -133,39 +133,39 @@ AudioDialog::AudioDialog(wxWindow* parent, shared_ptr<Film> film, shared_ptr<Con }; for (int i = 0; i < AudioPoint::COUNT; ++i) { - _type_checkbox[i] = new CheckBox (this, types[i]); - right->Add (_type_checkbox[i], 0, wxEXPAND | wxALL, 3); + _type_checkbox[i] = new CheckBox(this, types[i]); + right->Add(_type_checkbox[i], 0, wxEXPAND | wxALL, 3); _type_checkbox[i]->bind(&AudioDialog::type_clicked, this, _1); } { - auto m = new StaticText (this, _("Smoothing")); - m->SetFont (subheading_font); - right->Add (m, 1, wxTOP, 16); + auto m = new StaticText(this, _("Smoothing")); + m->SetFont(subheading_font); + right->Add(m, 1, wxTOP, 16); } - _smoothing = new wxSlider (this, wxID_ANY, AudioPlot::max_smoothing / 2, 1, AudioPlot::max_smoothing); - _smoothing->Bind (wxEVT_SCROLL_THUMBTRACK, boost::bind (&AudioDialog::smoothing_changed, this)); - right->Add (_smoothing, 0, wxEXPAND); + _smoothing = new wxSlider(this, wxID_ANY, AudioPlot::max_smoothing / 2, 1, AudioPlot::max_smoothing); + _smoothing->Bind(wxEVT_SCROLL_THUMBTRACK, boost::bind(&AudioDialog::smoothing_changed, this)); + right->Add(_smoothing, 0, wxEXPAND); - lr_sizer->Add (right, 0, wxALL, 12); + lr_sizer->Add(right, 0, wxALL, 12); - overall_sizer->Add (lr_sizer, 0, wxEXPAND); + overall_sizer->Add(lr_sizer, 0, wxEXPAND); #ifdef DCPOMATIC_LINUX - auto buttons = CreateSeparatedButtonSizer (wxCLOSE); + auto buttons = CreateSeparatedButtonSizer(wxCLOSE); if (buttons) { - overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + overall_sizer->Add(buttons, wxSizerFlags().Expand().DoubleBorder()); } #endif - SetSizer (overall_sizer); - overall_sizer->Layout (); - overall_sizer->SetSizeHints (this); + SetSizer(overall_sizer); + overall_sizer->Layout(); + overall_sizer->SetSizeHints(this); _plot->Click.connect(boost::ref(Seek)); - _film_connection = film->Change.connect (boost::bind(&AudioDialog::film_change, this, _1, _2)); + _film_connection = film->Change.connect(boost::bind(&AudioDialog::film_change, this, _1, _2)); _film_content_connection = film->ContentChange.connect(boost::bind(&AudioDialog::content_change, this, _1, _2)); if (content) { SetTitle(wxString::Format(_("%s audio - %s"), variant::wx::dcpomatic(), std_to_wx(content->path_for_display().string()))); @@ -179,80 +179,80 @@ AudioDialog::AudioDialog(wxWindow* parent, shared_ptr<Film> film, shared_ptr<Con _playlist = make_shared<Playlist>(); const_pointer_cast<Playlist>(_playlist)->add(film, content); } else { - _playlist = film->playlist (); + _playlist = film->playlist(); } - _plot->Cursor.connect (bind (&AudioDialog::set_cursor, this, _1, _2)); + _plot->Cursor.connect(bind(&AudioDialog::set_cursor, this, _1, _2)); } void -AudioDialog::show_or_hide_channel_checkboxes () +AudioDialog::show_or_hide_channel_checkboxes() { for (int i = 0; i < _channels; ++i) { - _channel_checkbox[i]->Show (); + _channel_checkbox[i]->Show(); } for (int i = _channels; i < MAX_DCP_AUDIO_CHANNELS; ++i) { - _channel_checkbox[i]->Hide (); + _channel_checkbox[i]->Hide(); } } void -AudioDialog::try_to_load_analysis () +AudioDialog::try_to_load_analysis() { - if (!IsShown ()) { + if (!IsShown()) { return; } - auto film = _film.lock (); - DCPOMATIC_ASSERT (film); + auto film = _film.lock(); + DCPOMATIC_ASSERT(film); auto check = _content.lock(); - auto const path = film->audio_analysis_path (_playlist); + auto const path = film->audio_analysis_path(_playlist); if (!dcp::filesystem::exists(path)) { - _plot->set_analysis (shared_ptr<AudioAnalysis> ()); - _analysis.reset (); + _plot->set_analysis(shared_ptr<AudioAnalysis>()); + _analysis.reset(); for (auto i: JobManager::instance()->get()) { if (dynamic_pointer_cast<AnalyseAudioJob>(i)) { - i->cancel (); + i->cancel(); } } - JobManager::instance()->analyse_audio ( - film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this) + JobManager::instance()->analyse_audio( + film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind(&AudioDialog::analysis_finished, this) ); return; } try { - _analysis.reset (new AudioAnalysis (path)); + _analysis.reset(new AudioAnalysis(path)); } catch (OldFormatError& e) { /* An old analysis file: recreate it */ - JobManager::instance()->analyse_audio ( - film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this) + JobManager::instance()->analyse_audio( + film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind(&AudioDialog::analysis_finished, this) ); return; } catch (xmlpp::exception& e) { /* Probably a (very) old-style analysis file: recreate it */ - JobManager::instance()->analyse_audio ( - film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind (&AudioDialog::analysis_finished, this) + JobManager::instance()->analyse_audio( + film, _playlist, !static_cast<bool>(check), _analysis_finished_connection, bind(&AudioDialog::analysis_finished, this) ); return; } - _plot->set_analysis (_analysis); - _plot->set_gain_correction (_analysis->gain_correction (_playlist)); - setup_statistics (); - show_or_hide_channel_checkboxes (); + _plot->set_analysis(_analysis); + _plot->set_gain_correction(_analysis->gain_correction(_playlist)); + setup_statistics(); + show_or_hide_channel_checkboxes(); /* Set up some defaults if no check boxes are checked */ int i = 0; - while (i < _channels && (!_channel_checkbox[i] || !_channel_checkbox[i]->GetValue ())) { + while (i < _channels && (!_channel_checkbox[i] || !_channel_checkbox[i]->GetValue())) { ++i; } @@ -260,41 +260,41 @@ AudioDialog::try_to_load_analysis () /* Nothing checked; check mapped ones */ list<int> mapped; - auto content = _content.lock (); + auto content = _content.lock(); if (content) { - mapped = content->audio->mapping().mapped_output_channels (); + mapped = content->audio->mapping().mapped_output_channels(); } else { - mapped = film->mapped_audio_channels (); + mapped = film->mapped_audio_channels(); } for (auto i: mapped) { if (_channel_checkbox[i]) { - _channel_checkbox[i]->SetValue (true); - _plot->set_channel_visible (i, true); + _channel_checkbox[i]->SetValue(true); + _plot->set_channel_visible(i, true); } } } i = 0; - while (i < AudioPoint::COUNT && !_type_checkbox[i]->GetValue ()) { + while (i < AudioPoint::COUNT && !_type_checkbox[i]->GetValue()) { i++; } if (i == AudioPoint::COUNT) { for (int i = 0; i < AudioPoint::COUNT; ++i) { - _type_checkbox[i]->SetValue (true); - _plot->set_type_visible (i, true); + _type_checkbox[i]->SetValue(true); + _plot->set_type_visible(i, true); } } - Refresh (); + Refresh(); } void -AudioDialog::analysis_finished () +AudioDialog::analysis_finished() { - auto film = _film.lock (); + auto film = _film.lock(); if (!film) { /* This should not happen, but if it does we should just give up quietly */ return; @@ -304,24 +304,24 @@ AudioDialog::analysis_finished () /* We analysed and still nothing showed up, so maybe it was cancelled or it failed. Give up. */ - _plot->set_message (_("Could not analyse audio.")); + _plot->set_message(_("Could not analyse audio.")); return; } - try_to_load_analysis (); + try_to_load_analysis(); } void -AudioDialog::channel_clicked (wxCommandEvent& ev) +AudioDialog::channel_clicked(wxCommandEvent& ev) { int c = 0; while (c < _channels && ev.GetEventObject() != _channel_checkbox[c]) { ++c; } - DCPOMATIC_ASSERT (c < _channels); + DCPOMATIC_ASSERT(c < _channels); - _plot->set_channel_visible (c, _channel_checkbox[c]->GetValue ()); + _plot->set_channel_visible(c, _channel_checkbox[c]->GetValue()); } void @@ -332,16 +332,16 @@ AudioDialog::film_change(ChangeType type, FilmProperty p) } if (p == FilmProperty::AUDIO_CHANNELS) { - auto film = _film.lock (); + auto film = _film.lock(); if (film) { - _channels = film->audio_channels (); - try_to_load_analysis (); + _channels = film->audio_channels(); + try_to_load_analysis(); } } } void -AudioDialog::content_change (ChangeType type, int p) +AudioDialog::content_change(ChangeType type, int p) { if (type != ChangeType::DONE) { return; @@ -349,61 +349,61 @@ AudioDialog::content_change (ChangeType type, int p) switch (p) { case AudioContentProperty::STREAMS: - try_to_load_analysis (); + try_to_load_analysis(); break; case AudioContentProperty::GAIN: if (_playlist->content().size() == 1 && _analysis) { /* We can use a short-cut to render the effect of this change, rather than recalculating everything. */ - _plot->set_gain_correction (_analysis->gain_correction (_playlist)); - setup_statistics (); + _plot->set_gain_correction(_analysis->gain_correction(_playlist)); + setup_statistics(); } else { - try_to_load_analysis (); + try_to_load_analysis(); } break; } } void -AudioDialog::type_clicked (wxCommandEvent& ev) +AudioDialog::type_clicked(wxCommandEvent& ev) { int t = 0; while (t < AudioPoint::COUNT && ev.GetEventObject() != _type_checkbox[t]) { ++t; } - DCPOMATIC_ASSERT (t < AudioPoint::COUNT); + DCPOMATIC_ASSERT(t < AudioPoint::COUNT); - _plot->set_type_visible (t, _type_checkbox[t]->GetValue ()); + _plot->set_type_visible(t, _type_checkbox[t]->GetValue()); } void -AudioDialog::smoothing_changed () +AudioDialog::smoothing_changed() { - _plot->set_smoothing (_smoothing->GetValue ()); + _plot->set_smoothing(_smoothing->GetValue()); } void -AudioDialog::setup_statistics () +AudioDialog::setup_statistics() { if (!_analysis) { return; } - auto film = _film.lock (); + auto film = _film.lock(); if (!film) { return; } - auto const peak = _analysis->overall_sample_peak (); + auto const peak = _analysis->overall_sample_peak(); float const peak_dB = linear_to_db(peak.first.peak) + _analysis->gain_correction(_playlist); - _sample_peak->SetLabel ( - wxString::Format ( + _sample_peak->SetLabel( + wxString::Format( _("Sample peak is %.2fdB at %s on %s"), peak_dB, - time_to_timecode (peak.first.time, film->video_frame_rate ()).data (), - std_to_wx (short_audio_channel_name (peak.second)).data () + time_to_timecode(peak.first.time, film->video_frame_rate()).data(), + std_to_wx(short_audio_channel_name(peak.second)).data() ) ); @@ -420,7 +420,7 @@ AudioDialog::setup_statistics () float const peak = _analysis->overall_true_peak().get(); float const peak_dB = linear_to_db(peak) + _analysis->gain_correction(_playlist); - _true_peak->SetLabel (wxString::Format (_("True peak is %.2fdB"), peak_dB)); + _true_peak->SetLabel(wxString::Format(_("True peak is %.2fdB"), peak_dB)); if (peak_dB > -3) { _true_peak->SetForegroundColour(peaking); @@ -432,19 +432,19 @@ AudioDialog::setup_statistics () /* XXX: check whether it's ok to add dB gain to these quantities */ if (static_cast<bool>(_analysis->integrated_loudness())) { - _integrated_loudness->SetLabel ( - wxString::Format ( + _integrated_loudness->SetLabel( + wxString::Format( _("Integrated loudness %.2f LUFS"), - _analysis->integrated_loudness().get() + _analysis->gain_correction (_playlist) + _analysis->integrated_loudness().get() + _analysis->gain_correction(_playlist) ) ); } if (static_cast<bool>(_analysis->loudness_range())) { - _loudness_range->SetLabel ( - wxString::Format ( + _loudness_range->SetLabel( + wxString::Format( _("Loudness range %.2f LU"), - _analysis->loudness_range().get() + _analysis->gain_correction (_playlist) + _analysis->loudness_range().get() + _analysis->gain_correction(_playlist) ) ); } @@ -459,22 +459,22 @@ AudioDialog::setup_statistics () } bool -AudioDialog::Show (bool show) +AudioDialog::Show(bool show) { - bool const r = wxDialog::Show (show); - try_to_load_analysis (); + bool const r = wxDialog::Show(show); + try_to_load_analysis(); return r; } void -AudioDialog::set_cursor (optional<DCPTime> time, optional<float> db) +AudioDialog::set_cursor(optional<DCPTime> time, optional<float> db) { if (!time || !db) { - _cursor->SetLabel (_("Cursor: none")); + _cursor->SetLabel(_("Cursor: none")); return; } auto film = _film.lock(); - DCPOMATIC_ASSERT (film); + DCPOMATIC_ASSERT(film); _cursor->SetLabel(wxString::Format(_("Cursor: %.1fdB at %s"), *db, std_to_wx(time->timecode(film->video_frame_rate())))); } diff --git a/src/wx/audio_dialog.h b/src/wx/audio_dialog.h index 2085a7220..d4a8a9b00 100644 --- a/src/wx/audio_dialog.h +++ b/src/wx/audio_dialog.h @@ -49,22 +49,22 @@ class AudioDialog : public wxDialog public: AudioDialog(wxWindow* parent, std::shared_ptr<Film> film, std::shared_ptr<Content> content = std::shared_ptr<Content>()); - bool Show (bool show = true) override; + bool Show(bool show = true) override; - void set_cursor (boost::optional<dcpomatic::DCPTime> time, boost::optional<float> db); + void set_cursor(boost::optional<dcpomatic::DCPTime> time, boost::optional<float> db); boost::signals2::signal<void (dcpomatic::DCPTime)> Seek; private: void film_change(ChangeType, FilmProperty); - void content_change (ChangeType, int); - void channel_clicked (wxCommandEvent &); - void type_clicked (wxCommandEvent &); - void smoothing_changed (); - void try_to_load_analysis (); - void analysis_finished (); - void setup_statistics (); - void show_or_hide_channel_checkboxes (); + void content_change(ChangeType, int); + void channel_clicked(wxCommandEvent &); + void type_clicked(wxCommandEvent &); + void smoothing_changed(); + void try_to_load_analysis(); + void analysis_finished(); + void setup_statistics(); + void show_or_hide_channel_checkboxes(); std::shared_ptr<AudioAnalysis> _analysis; std::weak_ptr<Film> _film; |
