change ownership of the AutomationControl used by Amp.
authorPaul Davis <paul@linuxaudiosystems.com>
Tue, 12 Jan 2016 19:09:24 +0000 (14:09 -0500)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 18 Jan 2016 17:11:08 +0000 (12:11 -0500)
It used to be owned by Amp. Now it is owned by Amp's owner

gtk2_ardour/processor_box.cc
libs/ardour/amp.cc
libs/ardour/ardour/amp.h
libs/ardour/ardour/return.h
libs/ardour/ardour/route.h
libs/ardour/ardour/send.h
libs/ardour/automatable.cc
libs/ardour/return.cc
libs/ardour/route.cc
libs/ardour/send.cc
libs/ardour/session.cc

index 29e230920c1c876a887fb7ac31ba739ae743e167..68beac400abf8028e429219b75eaf462e0b71613 100644 (file)
@@ -2027,7 +2027,8 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
                         )
           ) {
 
-               if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>(processor) && 
+                   boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
                        *amp_seen = true;
                } else {
                        if (!*amp_seen) {
@@ -2117,7 +2118,8 @@ ProcessorBox::setup_entry_positions ()
 
        uint32_t num = 0;
        for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
-               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && 
+                   boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
                        pre_fader = false;
                        (*i)->set_position (ProcessorEntry::Fader, num++);
                } else {
@@ -2689,7 +2691,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
                }
        }
 
-       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
+       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
 
                if (_parent_strip) {
                        _parent_strip->revert_to_default_display ();
index 924a77e66663f7314933696073b569413ab75d30..1d4ffc1cd7f0601c0de4ce573af9c02473b9d9dc 100644 (file)
@@ -38,23 +38,18 @@ using namespace PBD;
 // used for low-pass filter denormal protection
 #define GAIN_COEFF_TINY (1e-10) // -200dB
 
-Amp::Amp (Session& s, std::string type)
+Amp::Amp (Session& s, const std::string& name, boost::shared_ptr<AutomationControl> gc, bool control_midi_also)
        : Processor(s, "Amp")
        , _apply_gain(true)
        , _apply_gain_automation(false)
        , _current_gain(GAIN_COEFF_ZERO)
        , _current_automation_frame (INT64_MAX)
+       , _gain_control (gc)
        , _gain_automation_buffer(0)
-       , _type (type)
-       , _midi_amp (type != "trim")
+       , _midi_amp (control_midi_also)
 {
-       Evoral::Parameter p (_type == "trim" ? TrimAutomation : GainAutomation);
-       boost::shared_ptr<AutomationList> gl (new AutomationList (p));
-       _gain_control = boost::shared_ptr<GainControl> (new GainControl ((_type == "trim") ? X_("trimcontrol") : X_("gaincontrol"), s, this, p, gl));
-       _gain_control->set_flags (Controllable::GainLike);
-
-       add_control(_gain_control);
-       set_display_name (_type == "trim" ? _("Trim") : _("Fader"));
+       set_display_name (name);
+       add_control (_gain_control);
 }
 
 bool
@@ -375,8 +370,8 @@ XMLNode&
 Amp::state (bool full_state)
 {
        XMLNode& node (Processor::state (full_state));
-       node.add_property("type", _type);
-        node.add_child_nocopy (_gain_control->get_state());
+       node.add_property("type", _gain_control->parameter().type() == GainAutomation ? "amp" : "trim");
+       node.add_child_nocopy (_gain_control->get_state());
 
        return node;
 }
@@ -395,6 +390,17 @@ Amp::set_state (const XMLNode& node, int version)
        return 0;
 }
 
+Amp::GainControl::GainControl (Session& session, const Evoral::Parameter &param, boost::shared_ptr<AutomationList> al)
+       : AutomationControl (session, param, ParameterDescriptor(param),
+                            al ? al : boost::shared_ptr<AutomationList> (new AutomationList (param)),
+                            param.type() == GainAutomation ? X_("gaincontrol") : X_("trimcontrol")) {
+
+       alist()->reset_default (1.0);
+
+       lower_db = accurate_coefficient_to_dB (_desc.lower);
+       range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
+}
+
 void
 Amp::GainControl::set_value (double val, PBD::Controllable::GroupControlDisposition /* group_override */)
 {
@@ -407,7 +413,7 @@ void
 Amp::GainControl::set_value_unchecked (double val)
 {
        AutomationControl::set_value (std::max (std::min (val, (double)_desc.upper), (double)_desc.lower), Controllable::NoGroup);
-       _amp->session().set_dirty ();
+       _session.set_dirty ();
 }
 
 double
index c92edcc5fc22ceb76c47095bca39691eb68e8de4..108694de9092ef8e1f7bc38790a231ca18976f2f 100644 (file)
@@ -36,13 +36,11 @@ class IO;
  */
 class LIBARDOUR_API Amp : public Processor {
 public:
-       Amp(Session& s, std::string type = "amp");
+       Amp(Session& s, const std::string& display_name, boost::shared_ptr<AutomationControl> control, bool control_midi_also);
 
        std::string display_name () const { return _display_name; }
        void set_display_name (const std::string& name) { _display_name = name; }
 
-       std::string type() const { return _type;}
-
        bool visible () const;
 
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
@@ -81,16 +79,8 @@ public:
        /* automation */
 
        struct GainControl : public AutomationControl {
-               GainControl (std::string name, Session& session, Amp* a, const Evoral::Parameter &param,
-                               boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>() )
-                       : AutomationControl (session, param, ParameterDescriptor(param), al, name)
-                       , _amp (a) {
-                       set_flags (Controllable::Flag (flags() | Controllable::GainLike));
-                       alist()->reset_default (1.0);
-
-                       lower_db = accurate_coefficient_to_dB (_desc.lower);
-                       range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db;
-               }
+               GainControl (Session& session, const Evoral::Parameter &param,
+                            boost::shared_ptr<AutomationList> al = boost::shared_ptr<AutomationList>());
 
                void set_value (double val, PBD::Controllable::GroupControlDisposition group_override);
                void set_value_unchecked (double);
@@ -101,17 +91,17 @@ public:
                double user_to_internal (double) const;
                std::string get_user_string () const;
 
-               Amp* _amp;
                double lower_db;
                double range_db;
        };
 
+
        boost::shared_ptr<GainControl> gain_control() {
-               return _gain_control;
+               return boost::dynamic_pointer_cast<GainControl> (_gain_control);
        }
 
        boost::shared_ptr<const GainControl> gain_control() const {
-               return _gain_control;
+               return boost::dynamic_pointer_cast<GainControl> (_gain_control);
        }
 
        std::string value_as_string (boost::shared_ptr<AutomationControl>) const;
@@ -125,11 +115,10 @@ private:
 
        std::string _display_name;
 
-       boost::shared_ptr<GainControl> _gain_control;
+       boost::shared_ptr<AutomationControl> _gain_control;
 
        /** Buffer that we should use for gain automation */
        gain_t* _gain_automation_buffer;
-       std::string _type;
        bool _midi_amp;
 };
 
index 45bb5573b264c943bc490345573a4b82c174d666..e2e326d7d0fe9099c7050369b03d17aeba7273e7 100644 (file)
@@ -64,6 +64,7 @@ public:
 
   protected:
        bool _metering;
+       boost::shared_ptr<AutomationControl> _gain_control;
        boost::shared_ptr<Amp> _amp;
        boost::shared_ptr<PeakMeter> _meter;
 
index 2086f32119840f2ea20ffac823ccf0debfe70f91..9a0cf9ee0b58057b72a5371953cf489dcf4a1c65 100644 (file)
@@ -675,7 +675,9 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
 
        virtual void maybe_declick (BufferSet&, framecnt_t, int);
 
+       boost::shared_ptr<AutomationControl> _gain_control;
        boost::shared_ptr<Amp>       _amp;
+       boost::shared_ptr<AutomationControl> _trim_control;
        boost::shared_ptr<Amp>       _trim;
        boost::shared_ptr<PeakMeter> _meter;
        boost::shared_ptr<DelayLine> _delayline;
index f944dcabfbac92f4fcf4da3d28b4ac9b5aa7b7be..5db0b94b872c9a1e031868757c7bf9e86aedf9f5 100644 (file)
@@ -78,6 +78,7 @@ class LIBARDOUR_API Send : public Delivery
 
   protected:
        bool _metering;
+       boost::shared_ptr<AutomationControl> _gain_control;
        boost::shared_ptr<Amp> _amp;
        boost::shared_ptr<PeakMeter> _meter;
        boost::shared_ptr<DelayLine> _delayline;
index 9670f68689355d838804025beb2daae8cff6204c..c9d8374db95ef97f42914f8935202de8e28b613b 100644 (file)
@@ -449,19 +449,9 @@ Automatable::control_factory(const Evoral::Parameter& param)
                        warning << "PluginPropertyAutomation for non-Plugin" << endl;
                }
        } else if (param.type() == GainAutomation) {
-               Amp* amp = dynamic_cast<Amp*>(this);
-               if (amp) {
-                       control = new Amp::GainControl(X_("gaincontrol"), _a_session, amp, param);
-               } else {
-                       warning << "GainAutomation for non-Amp" << endl;
-               }
+               control = new Amp::GainControl(_a_session, param);
        } else if (param.type() == TrimAutomation) {
-               Amp* amp = dynamic_cast<Amp*>(this);
-               if (amp) {
-                       control = new Amp::GainControl(X_("trimcontrol"), _a_session, amp, param);
-               } else {
-                       warning << "TrimAutomation for non-Amp" << endl;
-               }
+               control = new Amp::GainControl(_a_session, param);
        } else if (param.type() == PanAzimuthAutomation || param.type() == PanWidthAutomation || param.type() == PanElevationAutomation) {
                Pannable* pannable = dynamic_cast<Pannable*>(this);
                if (pannable) {
index 4f9e8b958a4aad86db00df92f50d4fd9e3133dfb..d9c9e21a9822135eb36b4f358a8b1a6030d89c6e 100644 (file)
@@ -49,7 +49,11 @@ Return::Return (Session& s, bool internal)
 {
        /* never muted */
 
-       _amp.reset (new Amp (_session));
+       boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
+       _gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter (GainAutomation), gl));
+       add_control (_gain_control);
+
+       _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
        _meter.reset (new PeakMeter (_session, name()));
 }
 
@@ -159,4 +163,3 @@ Return::configure_io (ChanCount in, ChanCount out)
 
        return true;
 }
-
index cb1af7f4a91b19fd8e5b0bde9e2618d410fbaf26..7f4146e0790a4513a3038416493f030c0f5394de 100644 (file)
@@ -171,7 +171,11 @@ Route::init ()
 
        /* add amp processor  */
 
-       _amp.reset (new Amp (_session));
+       boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
+       _gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(GainAutomation), gl));
+       add_control (_gain_control);
+
+       _amp.reset (new Amp (_session, X_("Fader"), _gain_control, true));
        add_processor (_amp, PostFader);
 
        if (is_monitor ()) {
@@ -179,7 +183,12 @@ Route::init ()
        }
 
        /* and input trim */
-       _trim.reset (new Amp (_session, "trim"));
+
+       boost::shared_ptr<AutomationList> tl (new AutomationList (Evoral::Parameter (TrimAutomation)));
+       _trim_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(TrimAutomation), tl));
+       add_control (_trim_control);
+
+       _trim.reset (new Amp (_session, X_("Trim"), _trim_control, false));
        _trim->set_display_to_user (false);
 
        if (dynamic_cast<AudioTrack*>(this)) {
index ec86686bef47d0e050ee31dfb5019b027475fe4f..771473e065ac6e96be8f004f00a006436116312a 100644 (file)
@@ -86,13 +86,15 @@ Send::Send (Session& s, boost::shared_ptr<Pannable> p, boost::shared_ptr<MuteMas
 
        //boost_debug_shared_ptr_mark_interesting (this, "send");
 
-       _amp.reset (new Amp (_session));
+       boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
+       _gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (_session, Evoral::Parameter(GainAutomation), gl));
+       add_control (_gain_control);
+
+       _amp.reset (new Amp (_session, _("Fader"), _gain_control, true));
        _meter.reset (new PeakMeter (_session, name()));
 
        _delayline.reset (new DelayLine (_session, name()));
 
-       add_control (_amp->gain_control ());
-
        if (panner_shell()) {
                panner_shell()->Changed.connect_same_thread (*this, boost::bind (&Send::panshell_changed, this));
        }
@@ -400,5 +402,3 @@ Send::value_as_string (boost::shared_ptr<AutomationControl> ac) const
 {
        return _amp->value_as_string (ac);
 }
-
-
index 43883f7fc638cf61a724e0daf8f1096c6f5f9933..af423af83189fb89322dcf82f88e285d1b3ee7dd 100644 (file)
@@ -733,8 +733,12 @@ void
 Session::setup_click ()
 {
        _clicking = false;
+
+       boost::shared_ptr<AutomationList> gl (new AutomationList (Evoral::Parameter (GainAutomation)));
+       boost::shared_ptr<AutomationControl> gain_control = boost::shared_ptr<Amp::GainControl> (new Amp::GainControl (*this, Evoral::Parameter(GainAutomation), gl));
+
        _click_io.reset (new ClickIO (*this, X_("Click")));
-       _click_gain.reset (new Amp (*this));
+       _click_gain.reset (new Amp (*this, _("Fader"), gain_control, true));
        _click_gain->activate ();
        if (state_tree) {
                setup_click_state (state_tree->root());