use encoders for gain control
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 17 Jun 2016 12:37:39 +0000 (08:37 -0400)
committerPaul Davis <paul@linuxaudiosystems.com>
Tue, 27 Sep 2016 19:59:29 +0000 (14:59 -0500)
libs/surfaces/push2/push2.cc
libs/surfaces/push2/push2.h

index 369af80f9e9a1ad7ddc68ff233ab10142d9213a4..0cb3c522ac2df2665514c20efc97c627581e9cc9 100644 (file)
@@ -548,12 +548,62 @@ void
 Push2::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* ev)
 {
        CCButtonMap::iterator b = cc_button_map.find (ev->controller_number);
+
        if (b != cc_button_map.end()) {
                if (ev->value == 0) {
                        (this->*b->second->release_method)();
                } else {
                        (this->*b->second->press_method)();
                }
+       } else {
+
+               /* encoder/vpot */
+
+               int delta = ev->value;
+
+               if (delta > 63) {
+                       delta = -(128 - delta);
+               }
+
+               switch (ev->controller_number) {
+               case 71:
+                       strip_vpot (0, delta);
+                       break;
+               case 72:
+                       strip_vpot (1, delta);
+                       break;
+               case 73:
+                       strip_vpot (2, delta);
+                       break;
+               case 74:
+                       strip_vpot (3, delta);
+                       break;
+               case 75:
+                       strip_vpot (4, delta);
+                       break;
+               case 76:
+                       strip_vpot (5, delta);
+                       break;
+               case 77:
+                       strip_vpot (6, delta);
+                       break;
+               case 78:
+                       strip_vpot (7, delta);
+                       break;
+
+                       /* left side pair */
+               case 14:
+                       strip_vpot (8, delta);
+                       break;
+               case 15:
+                       other_vpot (1, delta);
+                       break;
+
+                       /* right side */
+               case 79:
+                       other_vpot (2, delta);
+                       break;
+               }
        }
 }
 
@@ -976,6 +1026,9 @@ Push2::switch_bank (uint32_t base)
                mute_change (n);
 
        }
+
+       /* master cannot be removed, so no need to connect to going-away signal */
+       master = session->master_out ();
 }
 
 void
@@ -1076,3 +1129,34 @@ Push2::mute_change (int n)
        b->set_state (LED::OneShot24th);
        write (b->state_msg());
 }
+
+void
+Push2::strip_vpot (int n, int delta)
+{
+       if (stripable[n]) {
+               boost::shared_ptr<AutomationControl> ac = stripable[n]->gain_control();
+               if (ac) {
+                       ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
+               }
+       }
+}
+
+void
+Push2::other_vpot (int n, int delta)
+{
+       switch (n) {
+       case 0:
+               break;
+       case 1:
+               break;
+       case 2:
+               /* master gain control */
+               if (master) {
+                       boost::shared_ptr<AutomationControl> ac = master->gain_control();
+                       if (ac) {
+                               ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup);
+                       }
+               }
+               break;
+       }
+}
index 0ddfad2f15a098be92da537aedacdf12177957d9..2ffbb29d4d74af4f36a256897bcebffd7a17dc38 100644 (file)
@@ -376,6 +376,11 @@ class Push2 : public ARDOUR::ControlProtocol
        void button_fwd4t ();
        void button_fwd4 ();
 
+       /* encoders */
+
+       void strip_vpot (int, int);
+       void other_vpot (int, int);
+
        /* widgets */
 
        Cairo::RefPtr<Cairo::Context> context;