From c2169d6d5111e517b4fe99497cb72f69e149002d Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Tue, 13 Aug 2024 19:43:36 +0200 Subject: [PATCH] Add GUI to toggle pre/post region fade FX --- gtk2_ardour/audio_region_editor.cc | 20 ++++++++++++++++++++ gtk2_ardour/audio_region_editor.h | 5 +++++ gtk2_ardour/region_editor.cc | 11 ++++++++--- gtk2_ardour/region_editor.h | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/gtk2_ardour/audio_region_editor.cc b/gtk2_ardour/audio_region_editor.cc index 613a395149..aff876dc3b 100644 --- a/gtk2_ardour/audio_region_editor.cc +++ b/gtk2_ardour/audio_region_editor.cc @@ -60,6 +60,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv) , _audio_region (arv->audio_region ()) , gain_adjustment(accurate_coefficient_to_dB(fabsf (_audio_region->scale_amplitude())), -40.0, +40.0, 0.1, 1.0, 0) , _polarity_toggle (_("Invert")) + , _pre_fade_fx_toggle (_("Pre Fade Fx")) , _show_on_touch (_("Show on Touch")) , _peak_channel (false) { @@ -94,6 +95,7 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv) _polarity_label.set_alignment (1, 0.5); _table.attach (_polarity_label, 0, 1, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL); _table.attach (_polarity_toggle, 1, 2, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL); + _table.attach (_pre_fade_fx_toggle, 2, 3, _table_row, _table_row + 1, Gtk::FILL, Gtk::FILL); ++_table_row; _region_line_label.set_name ("AudioRegionEditorLabel"); @@ -105,10 +107,12 @@ AudioRegionEditor::AudioRegionEditor (Session* s, AudioRegionView* arv) ++_table_row; gain_changed (); + pre_fade_fx_changed (); refill_region_line (); gain_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed)); _polarity_toggle.signal_toggled().connect (sigc::mem_fun (*this, &AudioRegionEditor::gain_adjustment_changed)); + _pre_fade_fx_toggle.signal_toggled().connect (sigc::mem_fun (*this, &AudioRegionEditor::pre_fade_fx_toggle_changed)); _show_on_touch.signal_toggled().connect (sigc::mem_fun (*this, &AudioRegionEditor::show_on_touch_changed)); arv->region_line_changed.connect ((sigc::mem_fun (*this, &AudioRegionEditor::refill_region_line))); @@ -141,6 +145,10 @@ AudioRegionEditor::region_changed (const PBD::PropertyChange& what_changed) gain_changed (); } + if (what_changed.contains (ARDOUR::Properties::fade_before_fx)) { + pre_fade_fx_changed (); + } + if (what_changed.contains (ARDOUR::Properties::start) || what_changed.contains (ARDOUR::Properties::length)) { /* ask the peak thread to run again */ signal_peak_thread (); @@ -178,6 +186,18 @@ AudioRegionEditor::gain_adjustment_changed () } } +void +AudioRegionEditor::pre_fade_fx_changed () +{ + _pre_fade_fx_toggle.set_active (_audio_region->fade_before_fx ()); +} + +void +AudioRegionEditor::pre_fade_fx_toggle_changed () +{ + _audio_region->set_fade_before_fx (_pre_fade_fx_toggle.get_active ()); +} + void AudioRegionEditor::signal_peak_thread () { diff --git a/gtk2_ardour/audio_region_editor.h b/gtk2_ardour/audio_region_editor.h index a941840682..b2b9e7589e 100644 --- a/gtk2_ardour/audio_region_editor.h +++ b/gtk2_ardour/audio_region_editor.h @@ -74,6 +74,9 @@ private: void show_on_touch_changed (); void show_touched_automation (std::weak_ptr); + void pre_fade_fx_changed (); + void pre_fade_fx_toggle_changed (); + AudioRegionView* _arv; std::shared_ptr _audio_region; @@ -84,6 +87,8 @@ private: Gtk::Label _polarity_label; Gtk::CheckButton _polarity_toggle; + Gtk::CheckButton _pre_fade_fx_toggle; + Gtk::Label _peak_amplitude_label; Gtk::Entry _peak_amplitude; diff --git a/gtk2_ardour/region_editor.cc b/gtk2_ardour/region_editor.cc index bb7a2b5973..6fc4f04d38 100644 --- a/gtk2_ardour/region_editor.cc +++ b/gtk2_ardour/region_editor.cc @@ -598,7 +598,8 @@ RegionEditor::RegionFxBox::add_fx_to_display (std::weak_ptr wfx) if (!fx) { return; } - RegionFxEntry* e = new RegionFxEntry (fx); + std::shared_ptr ar = std::dynamic_pointer_cast (_region); + RegionFxEntry* e = new RegionFxEntry (fx, ar && ar->fade_before_fx ()); _display.add_child (e, drag_targets ()); } @@ -936,7 +937,7 @@ RegionEditor::RegionFxBox::show_plugin_gui (std::weak_ptr wfx, b /* ****************************************************************************/ -RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr rfx) +RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr rfx, bool pre) : _fx_btn (ArdourWidgets::ArdourButton::default_elements) , _rfx (rfx) { @@ -947,7 +948,11 @@ RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr rfx) _fx_btn.set_fallthrough_to_parent (true); _fx_btn.set_text (name ()); _fx_btn.set_active (true); - _fx_btn.set_name ("processor postfader"); + if (pre) { + _fx_btn.set_name ("processor prefader"); + } else { + _fx_btn.set_name ("processor postfader"); + } if (rfx->plugin ()->has_editor ()) { set_tooltip (_fx_btn, string_compose (_("%1\nDouble-click to show GUI.\n%2+double-click to show generic GUI."), name (), Keyboard::secondary_modifier_name ())); diff --git a/gtk2_ardour/region_editor.h b/gtk2_ardour/region_editor.h index ecc5f9f6b1..9d7d8676ae 100644 --- a/gtk2_ardour/region_editor.h +++ b/gtk2_ardour/region_editor.h @@ -75,7 +75,7 @@ private: class RegionFxEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable { public: - RegionFxEntry (std::shared_ptr); + RegionFxEntry (std::shared_ptr, bool pre); Gtk::EventBox& action_widget () { return _fx_btn; } Gtk::Widget& widget () { return _box; }