summaryrefslogtreecommitdiff
path: root/libs/surfaces/cc121
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2018-07-05 16:48:47 +0200
committerRobin Gareus <robin@gareus.org>2018-07-05 16:49:01 +0200
commit7af016b089de825f67bceb5f85c92a3c520e251f (patch)
tree06f2a7a6e7bea1b8fc7cca209f6a199c22507721 /libs/surfaces/cc121
parentab6525a24f2432ee1b2484783d578272f11d9367 (diff)
Prepare CC121 ctrl surface for Mixbus
- fix Panner - implement touch-start when changing ctrls - map some well-known ctrls (not yet ideal)
Diffstat (limited to 'libs/surfaces/cc121')
-rw-r--r--libs/surfaces/cc121/cc121.cc30
-rw-r--r--libs/surfaces/cc121/cc121.h4
-rw-r--r--libs/surfaces/cc121/operations.cc87
3 files changed, 28 insertions, 93 deletions
diff --git a/libs/surfaces/cc121/cc121.cc b/libs/surfaces/cc121/cc121.cc
index 7c4f757eaf..afae36d524 100644
--- a/libs/surfaces/cc121/cc121.cc
+++ b/libs/surfaces/cc121/cc121.cc
@@ -388,46 +388,54 @@ CC121::encoder_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
{
DEBUG_TRACE (DEBUG::CC121, "encoder handler");
+ boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
/* Extract absolute value*/
float adj = static_cast<float>(tb->value & ~0x40);
-
/* Get direction (negative values start at 0x40)*/
float sign = (tb->value & 0x40) ? -1.0 : 1.0;
+
+ /* Get amount of change (encoder clicks) * (change per click)
+ * Create an exponential curve
+ */
+ float curve = sign * powf (adj, (1.f + 10.f) / 10.f);
+ adj = curve * (31.f / 1000.f);
+
switch(tb->controller_number) {
case 0x10:
/* pan */
- DEBUG_TRACE (DEBUG::CC121, "PAN encoder");
- if (_current_stripable) {
- /* Get amount of change (encoder clicks) * (change per click)*/
- /*Create an exponential curve*/
- float curve = sign * powf (adj, (1.f + 10.f) / 10.f);
- adj = curve * (31.f / 1000.f);
- ardour_pan_azimuth (adj);
- }
+ if (r) { set_controllable (r->pan_azimuth_control(), adj); }
break;
case 0x20:
/* EQ 1 Q */
+ if (r) { set_controllable (r->eq_q_controllable(0), adj); }
break;
case 0x21:
/* EQ 2 Q */
+ if (r) { set_controllable (r->eq_q_controllable(1), adj); }
break;
case 0x22:
/* EQ 3 Q */
+ if (r) { set_controllable (r->eq_q_controllable(2), adj); }
break;
case 0x23:
/* EQ 4 Q */
+ if (r) { set_controllable (r->eq_q_controllable(3), adj); }
break;
case 0x30:
/* EQ 1 Frequency */
+ if (r) { set_controllable (r->eq_freq_controllable(0), adj); }
break;
case 0x31:
/* EQ 2 Frequency */
+ if (r) { set_controllable (r->eq_freq_controllable(1), adj); }
break;
case 0x32:
/* EQ 3 Frequency */
+ if (r) { set_controllable (r->eq_freq_controllable(2), adj); }
break;
case 0x33:
/* EQ 4 Frequency */
+ if (r) { set_controllable (r->eq_freq_controllable(3), adj); }
break;
case 0x3C:
/* AI */
@@ -450,15 +458,19 @@ CC121::encoder_handler (MIDI::Parser &, MIDI::EventTwoBytes* tb)
break;
case 0x40:
/* EQ 1 Gain */
+ if (r) { set_controllable (r->eq_gain_controllable(0), adj); }
break;
case 0x41:
/* EQ 2 Gain */
+ if (r) { set_controllable (r->eq_gain_controllable(1), adj); }
break;
case 0x42:
/* EQ 3 Gain */
+ if (r) { set_controllable (r->eq_gain_controllable(2), adj); }
break;
case 0x43:
/* EQ 4 Gain */
+ if (r) { set_controllable (r->eq_gain_controllable(3), adj); }
break;
case 0x50:
/* Value */
diff --git a/libs/surfaces/cc121/cc121.h b/libs/surfaces/cc121/cc121.h
index ee9a3a5ccd..7c5bd39170 100644
--- a/libs/surfaces/cc121/cc121.h
+++ b/libs/surfaces/cc121/cc121.h
@@ -329,9 +329,7 @@ class CC121 : public ARDOUR::ControlProtocol, public AbstractUI<CC121Request> {
void jog ();
void rec_enable ();
- void ardour_pan_azimuth (float);
- void ardour_pan_width (float);
- void mixbus_pan (float);
+ void set_controllable (boost::shared_ptr<ARDOUR::AutomationControl>, float);
void punch ();
};
diff --git a/libs/surfaces/cc121/operations.cc b/libs/surfaces/cc121/operations.cc
index 67aafda777..f66f4fd2c8 100644
--- a/libs/surfaces/cc121/operations.cc
+++ b/libs/surfaces/cc121/operations.cc
@@ -246,92 +246,17 @@ CC121::use_monitor ()
}
void
-CC121::ardour_pan_azimuth (float delta)
+CC121::set_controllable (boost::shared_ptr<AutomationControl> ac, float delta)
{
- if (!_current_stripable) {
- return;
- }
-
- boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
-
- if (!r) {
- return;
- }
-
- boost::shared_ptr<Pannable> pannable = r->pannable ();
-
- if (!pannable) {
- return;
- }
-
- boost::shared_ptr<AutomationControl> azimuth = pannable->pan_azimuth_control;
-
- if (!azimuth) {
- return;
- }
-
- azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta)), Controllable::NoGroup);
-}
-
-
-void
-CC121::ardour_pan_width(float delta)
-{
- if (!_current_stripable) {
- return;
- }
-
- boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
-
- if (!r) {
- return;
- }
-
- boost::shared_ptr<Pannable> pannable = r->pannable ();
-
- if (!pannable) {
- return;
- }
-
- boost::shared_ptr<AutomationControl> width = pannable->pan_width_control;
-
- if (!width) {
+ if (!ac || delta == 0) {
return;
}
-
- width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta)), Controllable::NoGroup);
+ ac->start_touch (ac->session().transport_sample());
+ double v = ac->internal_to_interface (ac->get_value());
+ v = std::max (0.0, std::min (1.0, v + delta));
+ ac->set_value (ac->interface_to_internal(v), PBD::Controllable::NoGroup);
}
-void
-CC121::mixbus_pan (float delta)
-{
-#ifdef MIXBUS
- if (!_current_stripable) {
- return;
- }
- boost::shared_ptr<Route> r = boost::dynamic_pointer_cast<Route> (_current_stripable);
-
- if (!r) {
- return;
- }
-
-
- const uint32_t port_channel_post_pan = 2; // gtk2_ardour/mixbus_ports.h
- boost::shared_ptr<ARDOUR::PluginInsert> plug = r->ch_post();
-
- if (!plug) {
- return;
- }
-
- boost::shared_ptr<AutomationControl> azimuth = boost::dynamic_pointer_cast<ARDOUR::AutomationControl> (plug->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, port_channel_post_pan)));
-
- if (!azimuth) {
- return;
- }
-
- azimuth->set_value (azimuth->interface_to_internal (azimuth->internal_to_interface (azimuth->get_value()) + (delta)), Controllable::NoGroup);
-#endif
-}
void
CC121::punch ()