diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc index 2642862e4c..c6087bc746 100644 --- a/gtk2_ardour/editor.cc +++ b/gtk2_ardour/editor.cc @@ -1890,7 +1890,7 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items) edit_items.push_back (MenuElem (_("Loudness Analysis"), sigc::mem_fun(*this, &Editor::loudness_analyze_range_selection))); edit_items.push_back (MenuElem (_("Spectral Analysis"), sigc::mem_fun(*this, &Editor::spectral_analyze_range_selection))); edit_items.push_back (SeparatorElem()); - edit_items.push_back (MenuElem (_("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::measure_master_loudness), true))); + edit_items.push_back (MenuElem (_("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::loudness_assistant), true))); edit_items.push_back (SeparatorElem()); edit_items.push_back ( diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h index 6adbf8dff0..786516c5c4 100644 --- a/gtk2_ardour/editor.h +++ b/gtk2_ardour/editor.h @@ -311,7 +311,9 @@ public: void export_region (); /* export for analysis only */ - void measure_master_loudness (bool); + void loudness_assistant (bool); + void loudness_assistant_marker (); + void measure_master_loudness (samplepos_t start, samplepos_t end, bool); bool process_midi_export_dialog (MidiExportDialog& dialog, boost::shared_ptr midi_region); diff --git a/gtk2_ardour/editor_actions.cc b/gtk2_ardour/editor_actions.cc index 4d91367bf1..e18fab93df 100644 --- a/gtk2_ardour/editor_actions.cc +++ b/gtk2_ardour/editor_actions.cc @@ -685,7 +685,7 @@ Editor::register_actions () act = reg_sens (editor_actions, X_("addExistingPTFiles"), _("Import PT session"), sigc::mem_fun (*this, &Editor::external_pt_dialog)); ActionManager::write_sensitive_actions.push_back (act); - act = reg_sens (editor_actions, X_("LoudnessAssistant"), _("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::measure_master_loudness), false)); + act = reg_sens (editor_actions, X_("LoudnessAssistant"), _("Loudness Assistant..."), sigc::bind (sigc::mem_fun (*this, &Editor::loudness_assistant), false)); ActionManager::write_sensitive_actions.push_back (act); /* the next two are duplicate items with different names for use in two different contexts */ diff --git a/gtk2_ardour/editor_export_audio.cc b/gtk2_ardour/editor_export_audio.cc index 93588b6426..91ab3babd1 100644 --- a/gtk2_ardour/editor_export_audio.cc +++ b/gtk2_ardour/editor_export_audio.cc @@ -95,7 +95,40 @@ Editor::export_selection () } void -Editor::measure_master_loudness (bool range_selection) +Editor::loudness_assistant_marker () +{ + ArdourMarker* marker; + + if ((marker = reinterpret_cast (marker_menu_item->get_data ("marker"))) == 0) { + fatal << _("programming error: marker canvas item has no marker object pointer!") << endmsg; + abort(); /*NOTREACHED*/ + } + + Location* l; + bool is_start; + + if (((l = find_location_from_marker (marker, is_start)) != 0) && (l->end() > l->start())) { + measure_master_loudness (l->start(), l->end(), true); + } +} + +void +Editor::loudness_assistant (bool range_selection) +{ + samplepos_t start, end; + TimeSelection const& ts (get_selection().time); + if (range_selection && !ts.empty ()) { + start = ts.start(); + end = ts.end_sample(); + } else { + start = _session->current_start_sample(); + end = _session->current_end_sample(); + } + measure_master_loudness (start, end, range_selection); +} + +void +Editor::measure_master_loudness (samplepos_t start, samplepos_t end, bool is_range_selection) { if (!Config->get_use_master_volume ()) { ArdourMessageDialog md (_("Master bus output gain control is disabled.\nVisit preferences to enable it?"), false, @@ -106,18 +139,8 @@ Editor::measure_master_loudness (bool range_selection) return; } - samplepos_t start, end; - TimeSelection const& ts (get_selection().time); - if (range_selection && !ts.empty ()) { - start = ts.start(); - end = ts.end_sample(); - } else { - start = _session->current_start_sample(); - end = _session->current_end_sample(); - } - if (start >= end) { - if (range_selection) { + if (is_range_selection) { ArdourMessageDialog (_("Loudness Analysis requires a session-range or range-selection."), false, MESSAGE_ERROR).run (); } else { ArdourMessageDialog (_("Loudness Analysis requires a session-range."), false, MESSAGE_ERROR).run (); @@ -137,7 +160,7 @@ Editor::measure_master_loudness (bool range_selection) ARDOUR::AudioRange ar (start, end, 0); - LoudnessDialog ld (_session, ar, range_selection); + LoudnessDialog ld (_session, ar, is_range_selection); if (own_window ()) { ld.set_transient_for (*own_window ()); diff --git a/gtk2_ardour/editor_markers.cc b/gtk2_ardour/editor_markers.cc index 76782ee3dc..ab594f7f70 100644 --- a/gtk2_ardour/editor_markers.cc +++ b/gtk2_ardour/editor_markers.cc @@ -967,6 +967,7 @@ Editor::build_range_marker_menu (Location* loc, bool loop_or_punch, bool session glue_item->signal_activate().connect (sigc::mem_fun (*this, &Editor::toggle_marker_menu_glue)); items.push_back (SeparatorElem()); + items.push_back (MenuElem (_("Loudness Assistant..."), sigc::mem_fun(*this, &Editor::loudness_assistant_marker))); items.push_back (MenuElem (_("Export Range..."), sigc::mem_fun(*this, &Editor::export_range))); items.push_back (SeparatorElem()); diff --git a/gtk2_ardour/mixer_strip.cc b/gtk2_ardour/mixer_strip.cc index 3e83d63e0f..8a9b4b29ab 100644 --- a/gtk2_ardour/mixer_strip.cc +++ b/gtk2_ardour/mixer_strip.cc @@ -1321,7 +1321,7 @@ MixerStrip::width_button_pressed (GdkEventButton* ev) void MixerStrip::loudess_analysis_button_clicked () { - PublicEditor::instance().measure_master_loudness (false); + PublicEditor::instance().loudness_assistant (false); } bool diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h index 426e14f030..d778710fdb 100644 --- a/gtk2_ardour/public_editor.h +++ b/gtk2_ardour/public_editor.h @@ -280,7 +280,7 @@ public: /** Open export dialog with current range pre-selected */ virtual void export_range () = 0; - virtual void measure_master_loudness (bool) = 0; + virtual void loudness_assistant (bool) = 0; virtual void register_actions () = 0; virtual void set_zoom_focus (Editing::ZoomFocus) = 0;