13
0

Prepare CC121 ctrl surface for Mixbus

- fix Panner
- implement touch-start when changing ctrls
- map some well-known ctrls (not yet ideal)
This commit is contained in:
Robin Gareus 2018-07-05 16:48:47 +02:00
parent ab6525a24f
commit 7af016b089
3 changed files with 28 additions and 93 deletions

View File

@ -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 */

View File

@ -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 ();
};

View File

@ -246,93 +246,18 @@ CC121::use_monitor ()
}
void
CC121::ardour_pan_azimuth (float delta)
CC121::set_controllable (boost::shared_ptr<AutomationControl> ac, float delta)
{
if (!_current_stripable) {
if (!ac || delta == 0) {
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);
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::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) {
return;
}
width->set_value (width->interface_to_internal (width->internal_to_interface (width->get_value()) + (delta)), 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 ()
{