From a8bb49e5d89f2689d6aeb61381e3c4bd3560d859 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 21 Jan 2012 16:38:45 +0000 Subject: Add a send amp's gain control as a send controllable. Tweak AutomationControl now that PBD::Controllable has a default implementation of user_to_ui and ui_to_user. Add correct implementations of these methods to Amp::GainControl. Hence allow SendProcessorEntry to use the generic mini-fader-adding code from ProcessorEntry. git-svn-id: svn://localhost/ardour2/branches/3.0@11292 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/processor_box.cc | 152 ++++++++------------------------ gtk2_ardour/processor_box.h | 23 +---- libs/ardour/amp.cc | 21 ++++- libs/ardour/ardour/amp.h | 3 + libs/ardour/ardour/automation_control.h | 11 +-- libs/ardour/send.cc | 2 + 6 files changed, 61 insertions(+), 151 deletions(-) diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 60e87ab77e..70d35d053a 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -28,7 +28,6 @@ #include #include "pbd/convert.h" -#include "pbd/stacktrace.h" #include @@ -112,6 +111,7 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) _button.set_text (name (_width)); if (_processor) { + _vbox.pack_start (_button, true, true); if (_processor->active()) { @@ -126,10 +126,17 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) set p = _processor->what_can_be_automated (); for (set::iterator i = p.begin(); i != p.end(); ++i) { if (boost::dynamic_pointer_cast (_processor)) { + /* Don't give Fader processors separate controls here */ continue; } - - Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), _processor->describe_parameter (*i)); + + string d = _processor->describe_parameter (*i); + if (boost::dynamic_pointer_cast (_processor)) { + /* Little hack; don't label send level faders */ + d = ""; + } + + Control* c = new Control (_slider_pixbuf, _processor->automation_control (*i), d); _controls.push_back (c); _vbox.pack_start (c->box); } @@ -141,6 +148,13 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr p, Width w) } } +ProcessorEntry::~ProcessorEntry () +{ + for (list::iterator i = _controls.begin(); i != _controls.end(); ++i) { + delete *i; + } +} + EventBox& ProcessorEntry::action_widget () { @@ -373,12 +387,12 @@ ProcessorEntry::Control::Control (Glib::RefPtr s, boost::shared_ptr double const lo = c->user_to_ui (c->lower ()); double const up = c->user_to_ui (c->upper ()); - + _adjustment.set_lower (lo); _adjustment.set_upper (up); _adjustment.set_step_increment ((up - lo) / 100); _adjustment.set_page_increment ((up - lo) / 10); - _slider.set_default_value (up); + _slider.set_default_value (c->user_to_ui (c->normal ())); _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &Control::slider_adjusted)); c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ()); @@ -404,7 +418,7 @@ ProcessorEntry::Control::slider_adjusted () if (!c) { return; } - + c->set_value (c->ui_to_user (_adjustment.get_value ())); } @@ -417,7 +431,18 @@ ProcessorEntry::Control::control_changed () } _ignore_slider_adjustment = true; + _adjustment.set_value (c->user_to_ui (c->get_value ())); + + /* XXX: general presentation of values to the user */ + stringstream s; + s.precision (1); + s.setf (ios::fixed, ios::floatfield); + s << accurate_coefficient_to_dB (c->get_value ()); + s << _("dB"); + + _slider.set_tooltip_text (s.str ()); + _ignore_slider_adjustment = false; } @@ -485,111 +510,6 @@ BlankProcessorEntry::BlankProcessorEntry (Width w) { } -SendProcessorEntry::SendProcessorEntry (boost::shared_ptr s, Width w) - : ProcessorEntry (s, w) - , _send (s) - , _adjustment (gain_to_slider_position_with_max (1.0, Config->get_max_gain()), 0, 1, 0.01, 0.1) - , _fader (_slider_pixbuf, &_adjustment, 0, false) - , _ignore_gain_change (false) - , _data_type (DataType::AUDIO) -{ - _fader.set_name ("SendFader"); - _fader.set_controllable (_send->amp()->gain_control ()); - _vbox.pack_start (_fader); - - _fader.show (); - - _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted)); - - _send->amp()->gain_control()->Changed.connect ( - _send_connections, invalidator (*this), boost::bind (&SendProcessorEntry::show_gain, this), gui_context() - ); - - _send->amp()->ConfigurationChanged.connect ( - _send_connections, invalidator (*this), ui_bind (&SendProcessorEntry::setup_gain_adjustment, this), gui_context () - ); - - setup_gain_adjustment (); - show_gain (); -} - -void -SendProcessorEntry::setup_gain_adjustment () -{ - if (_send->amp()->output_streams().n_midi() == 0) { - _data_type = DataType::AUDIO; - _adjustment.set_lower (0); - _adjustment.set_upper (1); - _adjustment.set_step_increment (0.01); - _adjustment.set_page_increment (0.1); - _fader.set_default_value (gain_to_slider_position (1)); - } else { - _data_type = DataType::MIDI; - _adjustment.set_lower (0); - _adjustment.set_upper (2); - _adjustment.set_step_increment (0.05); - _adjustment.set_page_increment (0.1); - _fader.set_default_value (1); - } -} - -void -SendProcessorEntry::show_gain () -{ - gain_t value = 0; - - switch (_data_type) { - case DataType::AUDIO: - value = gain_to_slider_position_with_max (_send->amp()->gain (), Config->get_max_gain()); - break; - case DataType::MIDI: - value = _send->amp()->gain (); - break; - } - - if (_adjustment.get_value() != value) { - _ignore_gain_change = true; - _adjustment.set_value (value); - _ignore_gain_change = false; - - stringstream s; - s.precision (1); - s.setf (ios::fixed, ios::floatfield); - s << accurate_coefficient_to_dB (_send->amp()->gain ()); - if (_data_type == DataType::AUDIO) { - s << _("dB"); - } - - _fader.set_tooltip_text (s.str ()); - } -} - -void -SendProcessorEntry::gain_adjusted () -{ - if (_ignore_gain_change) { - return; - } - - gain_t value = 0; - - switch (_data_type) { - case DataType::AUDIO: - value = slider_position_to_gain_with_max (_adjustment.get_value(), Config->get_max_gain()); - break; - case DataType::MIDI: - value = _adjustment.get_value (); - } - - _send->amp()->set_gain (value, this); -} - -void -SendProcessorEntry::set_pixel_width (int p) -{ - _fader.set_fader_length (p); -} - PluginInsertProcessorEntry::PluginInsertProcessorEntry (boost::shared_ptr p, Width w) : ProcessorEntry (p, w) , _plugin_insert (p) @@ -1450,12 +1370,9 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr p) return; } - boost::shared_ptr send = boost::dynamic_pointer_cast (processor); boost::shared_ptr plugin_insert = boost::dynamic_pointer_cast (processor); ProcessorEntry* e = 0; - if (send) { - e = new SendProcessorEntry (send, _width); - } else if (plugin_insert) { + if (plugin_insert) { e = new PluginInsertProcessorEntry (plugin_insert, _width); } else { e = new ProcessorEntry (processor, _width); @@ -1469,6 +1386,11 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr p) e->set_control_state (proc); } + if (boost::dynamic_pointer_cast (processor)) { + /* Always show send controls */ + e->show_all_controls (); + } + processor_display.add_child (e); } diff --git a/gtk2_ardour/processor_box.h b/gtk2_ardour/processor_box.h index c949fa9176..364ab7b116 100644 --- a/gtk2_ardour/processor_box.h +++ b/gtk2_ardour/processor_box.h @@ -69,7 +69,6 @@ namespace ARDOUR { class PluginInsert; class PortInsert; class Route; - class Send; class Session; } @@ -103,6 +102,7 @@ class ProcessorEntry : public Gtkmm2ext::DnDVBoxChild, public sigc::trackable { public: ProcessorEntry (boost::shared_ptr, Width); + ~ProcessorEntry (); Gtk::EventBox& action_widget (); Gtk::Widget& widget (); @@ -189,27 +189,6 @@ class BlankProcessorEntry : public ProcessorEntry BlankProcessorEntry (Width w); }; -class SendProcessorEntry : public ProcessorEntry -{ -public: - SendProcessorEntry (boost::shared_ptr, Width); - - void set_enum_width (Width, int); - void set_pixel_width (int); - -private: - void show_gain (); - void gain_adjusted (); - void setup_gain_adjustment (); - - boost::shared_ptr _send; - Gtk::Adjustment _adjustment; - Gtkmm2ext::HSliderController _fader; - bool _ignore_gain_change; - PBD::ScopedConnectionList _send_connections; - ARDOUR::DataType _data_type; -}; - class PluginInsertProcessorEntry : public ProcessorEntry { public: diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index bbbaa9b331..01a31329cf 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -42,8 +42,11 @@ Amp::Amp (Session& s) , _apply_gain_automation(false) , _current_gain(1.0) { - boost::shared_ptr gl(new AutomationList(Evoral::Parameter(GainAutomation))); - _gain_control = boost::shared_ptr( new GainControl(X_("gaincontrol"), s, this, Evoral::Parameter(GainAutomation), gl )); + Evoral::Parameter p (GainAutomation); + /* gain range of -inf to +6dB, default 0dB */ + p.set_range (0, 1.99526231f, 1, false); + boost::shared_ptr gl (new AutomationList (p)); + _gain_control = boost::shared_ptr (new GainControl (X_("gaincontrol"), s, this, p, gl)); add_control(_gain_control); } @@ -371,8 +374,6 @@ Amp::set_gain (gain_t val, void *src) val = 1.99526231f; } - //cerr << "set desired gain to " << val << " when curgain = " << _gain_control->get_value () << endl; - if (src != _gain_control.get()) { _gain_control->set_value (val); // bit twisty, this will come back and call us again @@ -427,6 +428,18 @@ Amp::GainControl::get_value (void) const return AutomationControl::get_value(); } +double +Amp::GainControl::user_to_ui (double v) const +{ + return gain_to_slider_position (v); +} + +double +Amp::GainControl::ui_to_user (double v) const +{ + return slider_position_to_gain (v); +} + void Amp::setup_gain_automation (framepos_t start_frame, framepos_t end_frame, framecnt_t nframes) { diff --git a/libs/ardour/ardour/amp.h b/libs/ardour/ardour/amp.h index 35f084d04c..b811cca173 100644 --- a/libs/ardour/ardour/amp.h +++ b/libs/ardour/ardour/amp.h @@ -84,6 +84,9 @@ public: void set_value (double val); double get_value (void) const; + double user_to_ui (double) const; + double ui_to_user (double) const; + Amp* _amp; }; diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index e9801111d1..7e375de3ed 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -79,19 +79,10 @@ public: double lower() const { return parameter().min(); } double upper() const { return parameter().max(); } + double normal() const { return parameter().normal(); } const ARDOUR::Session& session() const { return _session; } - /** Convert user values to UI values. See pbd/controllable.h */ - virtual double user_to_ui (double val) const { - return val; - } - - /** Convert UI values to user values. See pbd/controllable.h */ - virtual double ui_to_user (double val) const { - return val; - } - protected: ARDOUR::Session& _session; diff --git a/libs/ardour/send.cc b/libs/ardour/send.cc index bacb381fe5..332f53556c 100644 --- a/libs/ardour/send.cc +++ b/libs/ardour/send.cc @@ -81,6 +81,8 @@ Send::Send (Session& s, boost::shared_ptr p, boost::shared_ptrgain_control ()); } Send::~Send () -- cgit v1.2.3