diff --git a/gtk2_ardour/audio_trigger_properties_box.cc b/gtk2_ardour/audio_trigger_properties_box.cc index 685c3a81ef..41aa16fb5d 100644 --- a/gtk2_ardour/audio_trigger_properties_box.cc +++ b/gtk2_ardour/audio_trigger_properties_box.cc @@ -53,8 +53,6 @@ using std::min; AudioTriggerPropertiesBox::AudioTriggerPropertiesBox () : _length_clock (X_("regionlength"), true, "", true, false, true) , _start_clock (X_("regionstart"), true, "", false, false) - , _gain_adjustment( 0.0, -20.0, +20.0, 1.0, 3.0, 0) - , _gain_spinner (_gain_adjustment) , _stretch_toggle (ArdourButton::led_default_elements) , _abpm_label (ArdourButton::Text) { @@ -115,25 +113,10 @@ AudioTriggerPropertiesBox::AudioTriggerPropertiesBox () _table.set_spacings (4); _table.set_border_width (2); - Gtk::Table* audio_t = manage (new Gtk::Table ()); - audio_t->set_homogeneous (true); - audio_t->set_spacings (4); - - row = 0; - - label = manage (new Gtk::Label (_("Gain:"))); - label->set_alignment (1.0, 0.5); - Gtk::Label *db_label = manage (new Gtk::Label (_("(dB)"))); - db_label->set_alignment (0.0, 0.5); - audio_t->attach (*label, 0, 1, row, row + 1, Gtk::FILL, Gtk::SHRINK); - audio_t->attach (_gain_spinner, 1, 2, row, row + 1, Gtk::FILL, Gtk::SHRINK); - audio_t->attach (*db_label, 2, 3, row, row + 1, Gtk::FILL, Gtk::SHRINK); - - row++; - attach (*eTempoBox, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); +#if 0 attach (_table, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); - attach (*audio_t, 0,1, 2,3, Gtk::FILL, Gtk::SHRINK); +#endif using namespace Menu_Helpers; @@ -145,10 +128,6 @@ AudioTriggerPropertiesBox::AudioTriggerPropertiesBox () _stretch_selector.AddMenuElem (MenuElem (TriggerUI::stretch_mode_to_string(Trigger::Smooth), sigc::bind (sigc::mem_fun(*this, &AudioTriggerPropertiesBox::set_stretch_mode), Trigger::Smooth))); _stretch_toggle.signal_clicked.connect (sigc::mem_fun (*this, &AudioTriggerPropertiesBox::toggle_stretch)); - - _gain_spinner.set_can_focus(false); - _gain_spinner.configure(_gain_adjustment, 0.0, 1); - _gain_spinner.signal_changed ().connect (sigc::mem_fun (*this, &AudioTriggerPropertiesBox::gain_changed)); } AudioTriggerPropertiesBox::~AudioTriggerPropertiesBox () @@ -219,22 +198,8 @@ AudioTriggerPropertiesBox::on_trigger_changed (const PBD::PropertyChange& what_c _stretch_selector.set_sensitive(trigger->stretchable ()); _stretch_selector.set_text(stretch_mode_to_string(trigger->stretch_mode ())); - - float gain = accurate_coefficient_to_dB(trigger->gain()); - if (gain != _gain_adjustment.get_value()) { - _gain_adjustment.set_value (gain); - } } -void -AudioTriggerPropertiesBox::gain_changed () -{ - float coeff = dB_to_coefficient(_gain_adjustment.get_value()); - - trigger()->set_gain(coeff); -} - - void AudioTriggerPropertiesBox::start_clock_changed () { diff --git a/gtk2_ardour/audio_trigger_properties_box.h b/gtk2_ardour/audio_trigger_properties_box.h index 7a04c9e0b5..b8b51763ab 100644 --- a/gtk2_ardour/audio_trigger_properties_box.h +++ b/gtk2_ardour/audio_trigger_properties_box.h @@ -64,7 +64,6 @@ protected: void length_clock_changed(); void follow_clock_changed(); - void gain_changed(); private: @@ -75,9 +74,6 @@ private: AudioClock _length_clock; AudioClock _start_clock; - Gtk::Adjustment _gain_adjustment; - Gtk::SpinButton _gain_spinner; - ArdourWidgets::ArdourButton _metrum_button; ArdourWidgets::ArdourButton _stretch_toggle; diff --git a/gtk2_ardour/slot_properties_box.cc b/gtk2_ardour/slot_properties_box.cc index 383e304840..f7a196d2fa 100644 --- a/gtk2_ardour/slot_properties_box.cc +++ b/gtk2_ardour/slot_properties_box.cc @@ -101,8 +101,12 @@ SlotPropertiesBox::set_slot (TriggerReference tref) SlotPropertyTable::SlotPropertyTable () : _color_button (ArdourButton::Element (ArdourButton::just_led_default_elements | ArdourButton::ColorBox)) + , _color_label (_("Color:")) , _velocity_adjustment(1.,0.,1.0,0.01,0.1) , _velocity_slider (&_velocity_adjustment, boost::shared_ptr(), 24/*length*/, 12/*girth*/ ) + , _gain_adjustment( 0.0, -20.0, +20.0, 1.0, 3.0, 0) + , _gain_spinner (_gain_adjustment) + , _gain_label (_("Gain (dB):")) , _follow_probability_adjustment(0,0,100,2,5) , _follow_probability_slider (&_follow_probability_adjustment, boost::shared_ptr(), 24/*length*/, 12/*girth*/ ) , _follow_count_adjustment (1, 1, 128, 1, 4) @@ -208,6 +212,13 @@ SlotPropertyTable::SlotPropertyTable () _name_frame.set_border_width (0); _name_frame.set_padding (0); +// _gain_label.set_alignment (1.0, 0.5); +// _color_label.set_alignment (1.0, 0.5); + + _gain_spinner.set_can_focus(false); + _gain_spinner.configure(_gain_adjustment, 0.0, 1); + _gain_spinner.signal_changed ().connect (sigc::mem_fun (*this, &SlotPropertyTable::gain_change_event)); + _load_button.set_name("FollowAction"); _load_button.set_text (_("Load")); _load_button.signal_clicked.connect (sigc::bind((sigc::mem_fun (*this, (&TriggerUI::choose_sample))), false)); @@ -232,9 +243,12 @@ SlotPropertyTable::SlotPropertyTable () _trigger_table.set_spacings (4); _trigger_table.set_homogeneous (false); - _trigger_table.attach(_name_frame, 0, 2, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); - _trigger_table.attach(_load_button, 2, 3, row, row+1, Gtk::SHRINK, Gtk::SHRINK ); - _trigger_table.attach(_color_button, 3, 4, row, row+1, Gtk::SHRINK, Gtk::SHRINK ); + _trigger_table.attach(_name_frame, 0, 2, row, row+1, Gtk::FILL|Gtk::EXPAND, Gtk::SHRINK ); + _trigger_table.attach(_load_button, 2, 3, row, row+1, Gtk::SHRINK, Gtk::SHRINK ); + _trigger_table.attach(_color_label, 3, 4, row, row + 1, Gtk::FILL, Gtk::SHRINK); + _trigger_table.attach(_color_button, 4, 5, row, row+1, Gtk::SHRINK, Gtk::SHRINK ); + _trigger_table.attach(_gain_label, 5, 6, row, row + 1, Gtk::FILL, Gtk::SHRINK); + _trigger_table.attach(_gain_spinner, 6, 7, row, row + 1, Gtk::FILL, Gtk::SHRINK); /* ---- Launch settings ----- */ @@ -316,7 +330,7 @@ SlotPropertyTable::SlotPropertyTable () eLaunchBox->set_edge_color (0x000000ff); // black eLaunchBox->add (_launch_table); - attach(_trigger_table, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK ); + attach(_trigger_table, 0,2, 0,1, Gtk::FILL, Gtk::SHRINK ); attach(*eLaunchBox, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK ); attach(*eFollowBox, 1,2, 1,2, Gtk::FILL, Gtk::SHRINK ); } @@ -405,6 +419,19 @@ SlotPropertyTable::use_follow_length_event (GdkEvent* ev) return false; } +void +SlotPropertyTable::gain_change_event () +{ + if (_ignore_changes) { + return; + } + + float coeff = dB_to_coefficient(_gain_adjustment.get_value()); + + trigger()->set_gain(coeff); +} + + bool SlotPropertyTable::legato_button_event (GdkEvent* ev) { @@ -457,6 +484,22 @@ SlotPropertyTable::on_trigger_changed (PropertyChange const& pc) if (pc.contains (Properties::color)) { _color_button.set_custom_led_color (trigger()->color()); } + + if (pc.contains (Properties::gain)) { + float gain = accurate_coefficient_to_dB(trigger()->gain()); + if (gain != _gain_adjustment.get_value()) { + _gain_adjustment.set_value (gain); + } + } + + if (triggerbox().data_type () == DataType::AUDIO) { + _gain_spinner.show(); + _gain_label.show(); + } else { + _gain_spinner.hide(); + _gain_label.hide(); + } + if (pc.contains (Properties::quantization)) { BBT_Offset bbo (trigger()->quantization()); _quantize_button.set_active (quantize_length_to_string (bbo)); diff --git a/gtk2_ardour/slot_properties_box.h b/gtk2_ardour/slot_properties_box.h index a585683b3d..9a76d09f1c 100644 --- a/gtk2_ardour/slot_properties_box.h +++ b/gtk2_ardour/slot_properties_box.h @@ -60,7 +60,9 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table ~SlotPropertyTable (); Glib::RefPtr _follow_size_group; - ArdourWidgets::ArdourButton _color_button; + + ArdourWidgets::ArdourButton _color_button; + Gtk::Label _color_label; ArdourWidgets::ArdourButton _load_button; @@ -71,6 +73,10 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table Gtk::Table _launch_table; Gtk::Table _follow_table; + Gtk::Adjustment _gain_adjustment; + Gtk::SpinButton _gain_spinner; + Gtk::Label _gain_label; + Gtk::Label _left_probability_label; Gtk::Label _right_probability_label; Gtk::Adjustment _follow_probability_adjustment; @@ -101,6 +107,8 @@ class SlotPropertyTable : public TriggerUI, public Gtk::Table bool legato_button_event (GdkEvent*); void follow_count_event (); + void gain_change_event (); + bool use_follow_length_event (GdkEvent*); void follow_length_event ();