From: Paul Davis Date: Fri, 17 Jun 2016 12:37:39 +0000 (-0400) Subject: use encoders for gain control X-Git-Tag: 5.4~194 X-Git-Url: https://main.carlh.net/gitweb/?a=commitdiff_plain;h=c26de72870e3ea2cb68eda8a39d86f450651615d;hp=f290be21ee896912553efbe5ec7f75d1d027ac13;p=ardour.git use encoders for gain control --- diff --git a/libs/surfaces/push2/push2.cc b/libs/surfaces/push2/push2.cc index 369af80f9e..0cb3c522ac 100644 --- a/libs/surfaces/push2/push2.cc +++ b/libs/surfaces/push2/push2.cc @@ -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 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 ac = master->gain_control(); + if (ac) { + ac->set_value (ac->get_value() + ((2.0/64.0) * delta), PBD::Controllable::UseGroup); + } + } + break; + } +} diff --git a/libs/surfaces/push2/push2.h b/libs/surfaces/push2/push2.h index 0ddfad2f15..2ffbb29d4d 100644 --- a/libs/surfaces/push2/push2.h +++ b/libs/surfaces/push2/push2.h @@ -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 context;