13
0

Add GUI to toggle pre/post region fade FX

This commit is contained in:
Robin Gareus 2024-08-13 19:43:36 +02:00
parent 4bcf1d31c6
commit c2169d6d51
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
4 changed files with 34 additions and 4 deletions

View File

@ -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 ()
{

View File

@ -74,6 +74,9 @@ private:
void show_on_touch_changed ();
void show_touched_automation (std::weak_ptr<PBD::Controllable>);
void pre_fade_fx_changed ();
void pre_fade_fx_toggle_changed ();
AudioRegionView* _arv;
std::shared_ptr<ARDOUR::AudioRegion> _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;

View File

@ -598,7 +598,8 @@ RegionEditor::RegionFxBox::add_fx_to_display (std::weak_ptr<RegionFxPlugin> wfx)
if (!fx) {
return;
}
RegionFxEntry* e = new RegionFxEntry (fx);
std::shared_ptr<AudioRegion> ar = std::dynamic_pointer_cast<AudioRegion> (_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<RegionFxPlugin> wfx, b
/* ****************************************************************************/
RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr<RegionFxPlugin> rfx)
RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr<RegionFxPlugin> rfx, bool pre)
: _fx_btn (ArdourWidgets::ArdourButton::default_elements)
, _rfx (rfx)
{
@ -947,7 +948,11 @@ RegionEditor::RegionFxEntry::RegionFxEntry (std::shared_ptr<RegionFxPlugin> 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 (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI."), name (), Keyboard::secondary_modifier_name ()));

View File

@ -75,7 +75,7 @@ private:
class RegionFxEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable
{
public:
RegionFxEntry (std::shared_ptr<ARDOUR::RegionFxPlugin>);
RegionFxEntry (std::shared_ptr<ARDOUR::RegionFxPlugin>, bool pre);
Gtk::EventBox& action_widget () { return _fx_btn; }
Gtk::Widget& widget () { return _box; }