Fix fader in mackie control to work with groups.
authorLen Ovens <len@ovenwerks.net>
Sat, 14 Nov 2015 18:39:53 +0000 (10:39 -0800)
committerLen Ovens <len@ovenwerks.net>
Sat, 14 Nov 2015 18:39:53 +0000 (10:39 -0800)
libs/ardour/ardour/route.h
libs/ardour/route.cc
libs/surfaces/mackie/strip.cc

index 31c8b09ceceebe57b414a22141ed19c08306c1d3..af2a7f78a0c10835c1b669b6b98d151c78e84199 100644 (file)
@@ -423,6 +423,15 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
                uint32_t _current_phase;
        };
 
+       class LIBARDOUR_API GroupGainControllable : public AutomationControl {
+       public:
+               GroupGainControllable (std::string name, boost::shared_ptr<Route>);
+               void set_value (double);
+               // We get the value from the amp where we get the changed signal from
+               //double get_value () const;
+       private:
+               boost::weak_ptr<Route> _route;
+       };
 
        boost::shared_ptr<SoloControllable> solo_control() const {
                return _solo_control;
@@ -440,6 +449,10 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
                return _phase_control;
        }
 
+       boost::shared_ptr<GroupGainControllable> group_gain_control() const {
+               return _group_gain_control;
+       }
+
        /* Route doesn't own these items, but sub-objects that it does own have them
           and to make UI code a bit simpler, we provide direct access to them
           here.
@@ -579,6 +592,7 @@ class LIBARDOUR_API Route : public SessionObject, public Automatable, public Rou
        boost::shared_ptr<MuteControllable> _mute_control;
        boost::shared_ptr<MuteMaster> _mute_master;
        boost::shared_ptr<PhaseControllable> _phase_control;
+       boost::shared_ptr<GroupGainControllable> _group_gain_control;
 
        virtual void act_on_mute () {}
 
index babec9ea741c394e441159b16f64f822fb8f0b4e..48661794903985b953f9bc3d114cd47cdbe12978 100644 (file)
@@ -136,14 +136,17 @@ Route::init ()
        _solo_control.reset (new SoloControllable (X_("solo"), shared_from_this ()));
        _mute_control.reset (new MuteControllable (X_("mute"), shared_from_this ()));
        _phase_control.reset (new PhaseControllable (X_("phase"), shared_from_this ()));
+       _group_gain_control.reset (new GroupGainControllable (X_("groupgain"), shared_from_this ()));
 
        _solo_control->set_flags (Controllable::Flag (_solo_control->flags() | Controllable::Toggle));
        _mute_control->set_flags (Controllable::Flag (_mute_control->flags() | Controllable::Toggle));
        _phase_control->set_flags (Controllable::Flag (_phase_control->flags() | Controllable::Toggle));
+       _group_gain_control->set_flags (Controllable::Flag (_group_gain_control->flags() | Controllable::GainLike));
 
        add_control (_solo_control);
        add_control (_mute_control);
        add_control (_phase_control);
+       add_control (_group_gain_control);
 
        /* panning */
 
@@ -3973,12 +3976,34 @@ Route::MuteControllable::get_value () const
        return (r && r->muted()) ? GAIN_COEFF_UNITY : GAIN_COEFF_ZERO;
 }
 
+Route::GroupGainControllable::GroupGainControllable (std::string name, boost::shared_ptr<Route> r)
+       : AutomationControl (r->session(),
+                                               Evoral::Parameter (GainAutomation),
+                                               ParameterDescriptor (Evoral::Parameter (GainAutomation)),
+                                               boost::shared_ptr<AutomationList>(),
+                                               name)
+       , _route (r)
+{
+       boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(GainAutomation)));
+       gl->set_interpolation(Evoral::ControlList::Discrete);
+       set_list (gl);
+}
+
+void
+Route::GroupGainControllable::set_value (double val)
+{
+       boost::shared_ptr<Route> r = _route.lock ();
+       // I am not sure why I need the * .5 to make this work
+       float normalized_position = r->gain_control()->interface_to_internal (val * 0.5);
+       r->set_gain ((gain_t)normalized_position, this);
+}
+
 Route::PhaseControllable::PhaseControllable (std::string name, boost::shared_ptr<Route> r)
        : AutomationControl (r->session(),
-                            Evoral::Parameter (PhaseAutomation),
-                            ParameterDescriptor (Evoral::Parameter (PhaseAutomation)),
-                            boost::shared_ptr<AutomationList>(),
-                            name)
+                                               Evoral::Parameter (PhaseAutomation),
+                                               ParameterDescriptor (Evoral::Parameter (PhaseAutomation)),
+                                               boost::shared_ptr<AutomationList>(),
+                                               name)
        , _route (r)
 {
        boost::shared_ptr<AutomationList> gl(new AutomationList(Evoral::Parameter(PhaseAutomation)));
index c7dc929710d8f69bbfe02a5debd4bccac5da409f..5b22484961591aa8dfe34453b889767d7101627c 100644 (file)
@@ -1305,7 +1305,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                pannable = _route->pannable ();
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, pan azi to fader */
-                       _vpot->set_control (_route->gain_control());
+                       _vpot->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (pannable) {
                                _fader->set_control (pannable->pan_azimuth_control);
@@ -1316,7 +1316,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                        }
                } else {
                        /* gain to fader, pan azi to vpot */
-                       _fader->set_control (_route->gain_control());
+                       _fader->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (pannable) {
                                _vpot->set_control (pannable->pan_azimuth_control);
@@ -1332,7 +1332,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                pannable = _route->pannable ();
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, pan width to fader */
-                       _vpot->set_control (_route->gain_control());
+                       _vpot->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (pannable) {
                                _fader->set_control (pannable->pan_width_control);
@@ -1343,7 +1343,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                        }
                } else {
                        /* gain to fader, pan width to vpot */
-                       _fader->set_control (_route->gain_control());
+                       _fader->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (pannable) {
                                _vpot->set_control (pannable->pan_width_control);
@@ -1364,7 +1364,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                _trim_mode = TrimAutomation;
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, trim to fader */
-                       _vpot->set_control (_route->gain_control());
+                       _vpot->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (_route->trim() && route()->trim()->active()) {
                                _fader->set_control (_route->trim_control());
@@ -1375,7 +1375,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                        }
                } else {
                        /* gain to fader, trim to vpot */
-                       _fader->set_control (_route->gain_control());
+                       _fader->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (_route->trim() && route()->trim()->active()) {
                                _vpot->set_control (_route->trim_control());
@@ -1390,7 +1390,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                _trim_mode = PhaseAutomation;
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        /* gain to vpot, phase to fader */
-                       _vpot->set_control (_route->gain_control());
+                       _vpot->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        if (_route->phase_invert().size()) {
                                _fader->set_control (_route->phase_control());
@@ -1401,7 +1401,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                        }
                } else {
                        /* gain to fader, phase to vpot */
-                       _fader->set_control (_route->gain_control());
+                       _fader->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        if (_route->phase_invert().size()) {
                                _vpot->set_control (_route->phase_control());
@@ -1415,7 +1415,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
        case SendAutomation:
                if (_surface->mcp().flip_mode() != MackieControlProtocol::Normal) {
                        // gain to vpot, send to fader
-                       _vpot->set_control (_route->gain_control());
+                       _vpot->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _vpot;
                        // test for send to control
                        boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
@@ -1433,7 +1433,7 @@ Strip::set_vpot_parameter (Evoral::Parameter p)
                        }
                } else {
                        // gain to fader, send to vpot
-                       _fader->set_control (_route->gain_control());
+                       _fader->set_control (_route->group_gain_control());
                        control_by_parameter[GainAutomation] = _fader;
                        boost::shared_ptr<Processor> p = _route->nth_send (_current_send);
                        if (p && p->name() != "Monitor 1") {