13
0

Enable controlling of plugin

This commit is contained in:
Hoger Dehnhardt 2023-05-16 22:45:11 +02:00 committed by Paul Davis
parent 835598c802
commit 4dd58961d2
5 changed files with 345 additions and 233 deletions

View File

@ -6,8 +6,6 @@
namespace ArdourSurface {
using namespace PBD;
using ControllerID = Console1::ControllerID;
class Controller
@ -22,7 +20,7 @@ class Controller
METER
};
Controller (Console1& console1, ControllerID id)
Controller (Console1* console1, ControllerID id)
: console1 (console1)
, _id (id)
{
@ -30,7 +28,7 @@ class Controller
virtual ~Controller () {}
Console1& console1;
Console1* console1;
ControllerID id () const { return _id; }
virtual ControllerType get_type () { return CONTROLLER; }
@ -42,22 +40,23 @@ class Controller
class ControllerButton : public Controller
{
public:
ControllerButton (Console1& console1,
ControllerButton (Console1* console1,
ControllerID id,
boost::function<void (uint32_t)> action,
boost::function<void (uint32_t)> shift_action = 0,
boost::function<void (uint32_t)> plugin_action = 0
)
boost::function<void (uint32_t)> plugin_action = 0)
: Controller (console1, id)
, action (action)
, shift_action (shift_action)
, plugin_action (plugin_action)
, plugin_action (plugin_action)
{
console1.buttons.insert (std::make_pair (id, *this));
console1->buttons.insert (std::make_pair (id, this));
}
ControllerType get_type () { return CONTROLLER_BUTTON; }
void set_plugin_action (boost::function<void (uint32_t)> action) { plugin_action = action; }
virtual void set_led_state (bool onoff)
{
// DEBUG_TRACE(DEBUG::Console1, "ControllerButton::set_led_state ...\n");
@ -66,7 +65,7 @@ class ControllerButton : public Controller
buf[1] = _id;
buf[2] = onoff ? 127 : 0;
console1.write (buf, 3);
console1->write (buf, 3);
}
virtual void set_led_value (uint32_t val)
@ -77,7 +76,7 @@ class ControllerButton : public Controller
buf[1] = _id;
buf[2] = val;
console1.write (buf, 3);
console1->write (buf, 3);
}
boost::function<void (uint32_t)> action;
boost::function<void (uint32_t)> shift_action;
@ -87,7 +86,7 @@ class ControllerButton : public Controller
class MultiStateButton : public Controller
{
public:
MultiStateButton (Console1& console1,
MultiStateButton (Console1* console1,
ControllerID id,
std::vector<uint32_t> state_values,
boost::function<void (uint32_t)> action,
@ -97,7 +96,7 @@ class MultiStateButton : public Controller
, shift_action (shift_action)
, state_values (state_values)
{
console1.multi_buttons.insert (std::make_pair (id, *this));
console1->multi_buttons.insert (std::make_pair (id, this));
}
ControllerType get_type () { return MULTISTATE_BUTTON; }
@ -111,7 +110,7 @@ class MultiStateButton : public Controller
buf[1] = _id;
buf[2] = state_values[state];
console1.write (buf, 3);
console1->write (buf, 3);
}
uint32_t state_count () { return state_values.size (); }
@ -126,7 +125,7 @@ class MultiStateButton : public Controller
class Meter : public Controller
{
public:
Meter (Console1& console1,
Meter (Console1* console1,
ControllerID id,
boost::function<void ()> action,
boost::function<void ()> shift_action = 0)
@ -134,7 +133,7 @@ class Meter : public Controller
, action (action)
, shift_action (shift_action)
{
console1.meters.insert (std::make_pair (id, *this));
console1->meters.insert (std::make_pair (id, this));
}
ControllerType get_type () { return METER; }
@ -146,7 +145,7 @@ class Meter : public Controller
buf[1] = _id;
buf[2] = value;
console1.write (buf, 3);
console1->write (buf, 3);
}
boost::function<void ()> action;
boost::function<void ()> shift_action;
@ -155,19 +154,23 @@ class Meter : public Controller
class Encoder : public Controller
{
public:
Encoder (Console1& console1,
Encoder (Console1* console1,
ControllerID id,
boost::function<void (uint32_t)> action,
boost::function<void (uint32_t)> shift_action = 0)
boost::function<void (uint32_t)> shift_action = 0,
boost::function<void (uint32_t)> plugin_action = 0)
: Controller (console1, id)
, action (action)
, shift_action (shift_action)
, plugin_action (plugin_action)
{
console1.encoders.insert (std::make_pair (id, *this));
console1->encoders.insert (std::make_pair (id, this));
}
ControllerType get_type () { return ENCODER; }
void set_plugin_action (boost::function<void (uint32_t)> action) { plugin_action = action; }
virtual void set_value (uint32_t value)
{
MIDI::byte buf[3];
@ -175,10 +178,13 @@ class Encoder : public Controller
buf[1] = _id;
buf[2] = value;
console1.write (buf, 3);
console1->write (buf, 3);
}
boost::function<void (uint32_t)> action;
boost::function<void (uint32_t val)> shift_action;
boost::function<void (uint32_t val)> plugin_action;
PBD::Signal1<void, uint32_t>* plugin_signal;
};
}

View File

@ -123,7 +123,7 @@ Console1::rude_solo (const uint32_t value)
session->cancel_all_solo ();
} else {
try {
get_button (ControllerID::DISPLAY_ON).set_led_state (false);
get_button (ControllerID::DISPLAY_ON)->set_led_state (false);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -547,8 +547,8 @@ Console1::map_bank ()
{
uint32_t list_size = strip_inventory.size ();
try {
get_button (PAGE_UP).set_led_state (list_size > (current_bank + 1) * bank_size);
get_button (PAGE_DOWN).set_led_state (current_bank > 0);
get_button (PAGE_UP)->set_led_state (list_size > (current_bank + 1) * bank_size);
get_button (PAGE_DOWN)->set_led_state (current_bank > 0);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -581,7 +581,7 @@ Console1::map_mute ()
DEBUG_TRACE (DEBUG::Console1, "Console1::map_mute ...\n");
if (_current_stripable) {
if (_current_stripable->mute_control ()->muted ()) {
get_button (MUTE).set_led_state (true);
get_button (MUTE)->set_led_state (true);
} else if (_current_stripable->mute_control ()->muted_by_others_soloing () ||
_current_stripable->mute_control ()->muted_by_masters ()) {
@ -611,7 +611,7 @@ void
Console1::map_phase ()
{
DEBUG_TRACE (DEBUG::Console1, "map_phase \n");
ControllerButton& controllerButton = static_cast<ControllerButton&> (get_button (PHASE_INV));
ControllerButton* controllerButton = get_button (PHASE_INV);
if (_current_stripable) {
uint32_t channels = _current_stripable->phase_control ()->size ();
uint32_t inverted = 0;
@ -621,14 +621,14 @@ Console1::map_phase ()
}
if (inverted == 0) {
stop_blinking (PHASE_INV);
controllerButton.set_led_state (false);
controllerButton->set_led_state (false);
} else if (inverted == channels) {
stop_blinking (PHASE_INV);
controllerButton.set_led_state (true);
controllerButton->set_led_state (true);
} else
start_blinking (PHASE_INV);
} else {
controllerButton.set_led_state (false);
controllerButton->set_led_state (false);
}
}
@ -648,7 +648,7 @@ Console1::map_select ()
{
DEBUG_TRACE (DEBUG::Console1, "map_select())\n");
for (uint32_t i = 0; i < bank_size; ++i) {
get_button (ControllerID (FOCUS1 + i)).set_led_state (i == current_strippable_index);
get_button (ControllerID (FOCUS1 + i))->set_led_state (i == current_strippable_index);
}
}
@ -657,8 +657,8 @@ Console1::map_shift (bool shift)
{
DEBUG_TRACE (DEBUG::Console1, "map_shift()\n");
try {
ControllerButton& controllerButton = static_cast<ControllerButton&> (get_button (PRESET));
controllerButton.set_led_state (shift);
ControllerButton* controllerButton = get_button (PRESET);
controllerButton->set_led_state (shift);
map_stripable_state ();
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
@ -670,8 +670,8 @@ Console1::map_plugin_state (bool plugin_state)
{
DEBUG_TRACE (DEBUG::Console1, "map_plugin_state()\n");
try {
ControllerButton& controllerButton = static_cast<ControllerButton&> (get_button (TRACK_GROUP));
controllerButton.set_led_state (in_plugin_state);
ControllerButton* controllerButton = get_button (TRACK_GROUP);
controllerButton->set_led_state (in_plugin_state);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -692,11 +692,11 @@ Console1::map_solo ()
{
DEBUG_TRACE (DEBUG::Console1, "map_solo()\n");
try {
ControllerButton& controllerButton = static_cast<ControllerButton&> (get_button (SOLO));
ControllerButton* controllerButton = get_button (SOLO);
if (_current_stripable) {
controllerButton.set_led_state (_current_stripable->solo_control ()->soloed ());
controllerButton->set_led_state (_current_stripable->solo_control ()->soloed ());
} else {
controllerButton.set_led_state (false);
controllerButton->set_led_state (false);
}
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
@ -722,7 +722,7 @@ Console1::map_filter ()
}
try {
get_button (ControllerID::FILTER_TO_COMPRESSORS)
.set_led_state (_current_stripable->filter_enable_controllable (true)
->set_led_state (_current_stripable->filter_enable_controllable (true)
? _current_stripable->filter_enable_controllable (true)->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -758,7 +758,7 @@ Console1::map_gate ()
return;
try {
get_button (ControllerID::SHAPE)
.set_led_state (_current_stripable->gate_enable_controllable ()
->set_led_state (_current_stripable->gate_enable_controllable ()
? _current_stripable->gate_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -774,7 +774,7 @@ Console1::map_gate_scf ()
try {
DEBUG_TRACE (DEBUG::Console1, string_compose ("map_gate_scf() - shift: %1\n", shift_state));
get_button (ControllerID::HARD_GATE)
.set_led_state (_current_stripable->gate_key_filter_enable_controllable ()
->set_led_state (_current_stripable->gate_key_filter_enable_controllable ()
? _current_stripable->gate_key_filter_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -790,7 +790,7 @@ Console1::map_gate_listen ()
try {
DEBUG_TRACE (DEBUG::Console1, string_compose ("map_gate_listen() - shift: %1\n", shift_state));
get_button (ControllerID::HARD_GATE)
.set_led_state (_current_stripable->gate_key_listen_controllable ()
->set_led_state (_current_stripable->gate_key_listen_controllable ()
? _current_stripable->gate_key_listen_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -893,7 +893,7 @@ Console1::map_eq ()
if (!_current_stripable)
return;
try {
get_button (EQ).set_led_state (_current_stripable->eq_enable_controllable ()
get_button (EQ)->set_led_state (_current_stripable->eq_enable_controllable ()
? _current_stripable->eq_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -936,7 +936,7 @@ Console1::map_eq_low_shape ()
uint32_t led_value = _current_stripable->eq_shape_controllable (0)
? _current_stripable->eq_shape_controllable (0)->get_value () == 0 ? 0 : 63
: 0;
get_button (ControllerID::LOW_SHAPE).set_led_state (led_value);
get_button (ControllerID::LOW_SHAPE)->set_led_state (led_value);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -951,7 +951,7 @@ Console1::map_eq_high_shape ()
uint32_t led_value = _current_stripable->eq_shape_controllable (3)
? _current_stripable->eq_shape_controllable (3)->get_value () == 0 ? 0 : 63
: 0;
get_button (ControllerID::HIGH_SHAPE).set_led_state (led_value);
get_button (ControllerID::HIGH_SHAPE)->set_led_state (led_value);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -969,7 +969,7 @@ Console1::map_drive ()
double val = control->get_value ();
DEBUG_TRACE (DEBUG::Console1, string_compose ("map_drive audio track %1\n", val));
try {
get_encoder (controllerID).set_value (val == 1 ? 127 : 0);
get_encoder (controllerID)->set_value (val == 1 ? 127 : 0);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}
@ -1011,7 +1011,7 @@ Console1::map_comp ()
return;
try {
get_button (ControllerID::COMP)
.set_led_state (_current_stripable->comp_enable_controllable ()
->set_led_state (_current_stripable->comp_enable_controllable ()
? _current_stripable->comp_enable_controllable ()->get_value ()
: false);
} catch (ControlNotFoundException& e) {
@ -1029,7 +1029,7 @@ Console1::map_comp_mode ()
? _current_stripable->comp_mode_controllable ()->get_value ()
: false;
DEBUG_TRACE (DEBUG::Console1, string_compose ("****value from comp-type %1\n", value));
get_mbutton (ControllerID::ORDER).set_led_state (value);
get_mbutton (ControllerID::ORDER)->set_led_state (value);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Button not found\n");
}
@ -1100,7 +1100,7 @@ Console1::map_encoder (ControllerID controllerID)
{
if (!_current_stripable) {
try {
get_encoder (controllerID).set_value (0);
get_encoder (controllerID)->set_value (0);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
return false;
@ -1116,7 +1116,7 @@ Console1::map_encoder (ControllerID controllerID, std::shared_ptr<ARDOUR::Automa
if (!_current_stripable) {
try {
get_encoder (controllerID).set_value (0);
get_encoder (controllerID)->set_value (0);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}
@ -1133,7 +1133,7 @@ Console1::map_encoder (ControllerID controllerID, std::shared_ptr<ARDOUR::Automa
gain = control_to_midi (control, val);
}
try {
get_encoder (controllerID).set_value (gain);
get_encoder (controllerID)->set_value (gain);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Encoder not found\n");
}

View File

@ -130,6 +130,24 @@ void
Console1::select_plugin (uint32_t plugin_index)
{
DEBUG_TRACE (DEBUG::Console1, "Console1::select_plugin\n");
if (current_plugin_index == plugin_index) {
std::shared_ptr<Route> r = std::dynamic_pointer_cast<Route> (_current_stripable);
if (!r) {
return;
}
std::shared_ptr<Processor> proc = r->nth_plugin (plugin_index);
if (!proc) {
return;
}
if (!proc->display_to_user ()) {
return;
}
std::shared_ptr<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc);
if (!plugin_insert)
return;
plugin_insert->ToggleUI ();
return;
}
current_plugin_index = plugin_index;
map_select_plugin ();
}
@ -157,21 +175,22 @@ Console1::spill_plugins (uint32_t plugin_index)
return false;
}
// drop_ctrl_connections ();
plugin_connections.drop_connections ();
// switching to "Mode Track" -> calls FaderPort8::notify_fader_mode_changed()
// which drops the references, disconnects the signal and re-spills tracks
/*r->DropReferences.connect (
processor_connections, MISSING_INVALIDATOR, boost::bind (&FP8Controls::set_fader_mode, &_ctrls, ModeTrack), this);
for (auto& e : encoders) {
e.second->set_plugin_action (0);
e.second->set_value (0);
}
for (auto& c : buttons) {
if( c.first == ControllerID::TRACK_GROUP )
continue;
if( c.first >= ControllerID::FOCUS1 && c.first <= ControllerID::FOCUS20 )
continue;
c.second->set_plugin_action (0);
c.second->set_led_state (false);
}
// update when processor change
r->processors_changed.connect (
processor_connections, MISSING_INVALIDATOR, boost::bind (&FaderPort8::spill_plugins, this), this);*/
// count available
std::shared_ptr<Processor> proc;
proc = r->nth_plugin (plugin_index);
std::shared_ptr<Processor> proc = r->nth_plugin (plugin_index);
if (!proc) {
return false;
}
@ -186,7 +205,7 @@ Console1::spill_plugins (uint32_t plugin_index)
}
#endif
int n_controls = 0;
int32_t n_controls = -1;
DEBUG_TRACE (DEBUG::Console1, string_compose ("Found plugin %1\n", proc->name ()));
std::shared_ptr<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc);
if (!plugin_insert)
@ -200,7 +219,7 @@ Console1::spill_plugins (uint32_t plugin_index)
PluginMappingMap::iterator pmmit = pluginMappingMap.find (plugin->unique_id ());
if (pmmit == pluginMappingMap.end ()) {
return false;
return true;
}
PluginMapping pluginMapping = pmmit->second;
@ -209,7 +228,27 @@ Console1::spill_plugins (uint32_t plugin_index)
set<Evoral::Parameter> p = proc->what_can_be_automated ();
PluginParameterMapping enableMapping = pluginMapping.parameters[-1];
if (enableMapping.controllerId != 0) {
try {
ControllerButton* cb = get_button (enableMapping.controllerId);
boost::function<void ()> plugin_mapping = [=] () -> void { cb->set_led_state (plugin_insert->enabled ()); };
cb->set_plugin_action ([=] (uint32_t val) {
plugin_insert->enable (val == 127);
DEBUG_TRACE (DEBUG::Console1,
string_compose ("ControllerButton Plugin parameter %1: %2 \n", n_controls, val));
});
plugin_insert->ActiveChanged.connect (
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping), this);
plugin_insert->ActiveChanged ();
} catch (ControlNotFoundException&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
}
}
for (set<Evoral::Parameter>::iterator j = p.begin (); j != p.end (); ++j) {
++n_controls;
std::string n = proc->describe_parameter (*j);
DEBUG_TRACE (DEBUG::Console1, string_compose ("Plugin parameter %1: %2\n", n_controls, n));
if (n == "hidden") {
@ -217,6 +256,15 @@ Console1::spill_plugins (uint32_t plugin_index)
}
ParameterDescriptor parameterDescriptor;
plugin->get_parameter_descriptor (n_controls, parameterDescriptor);
if (plugin->parameter_is_control (n_controls)) {
DEBUG_TRACE (DEBUG::Console1, "parameter is control\n");
}
if (plugin->parameter_is_output (n_controls)) {
DEBUG_TRACE (DEBUG::Console1, "parameter is output\n");
}
if (plugin->parameter_is_audio (n_controls)) {
DEBUG_TRACE (DEBUG::Console1, "parameter is audio\n");
}
if (plugin->parameter_is_input (n_controls)) {
std::shared_ptr<AutomationControl> c =
plugin_insert->automation_control (Evoral::Parameter (PluginAutomation, 0, n_controls));
@ -226,15 +274,60 @@ Console1::spill_plugins (uint32_t plugin_index)
swtch = true;
}
PluginParameterMapping ppm = pluginMapping.parameters[n_controls];
ppm.controllerId;
// c->Changed.connect (plugin_connections, MISSING_INVALIDATOR, boost::bind
// (&OSCSelectObserver::plugin_parameter_changed, this, pid, swtch, c), OSC::instance());
// plugin_parameter_changed (pid, swtch, c);
try {
Encoder* e = get_encoder (ppm.controllerId);
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
double v = parameterDescriptor.to_interface (c->get_value (), true);
e->set_value (v * 127);
};
e->set_plugin_action ([=] (uint32_t val) {
double v = val / 127.f;
c->set_value (parameterDescriptor.from_interface (v, true),
PBD::Controllable::GroupControlDisposition::UseGroup);
DEBUG_TRACE (DEBUG::Console1,
string_compose ("Encoder Plugin parameter %1: %2 - %3\n", n_controls, val, v));
});
c->Changed.connect (
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
continue;
} catch (ControlNotFoundException&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No Encoder found %1\n", n_controls));
}
try {
ControllerButton* cb = get_button (ppm.controllerId);
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
// double v = parameterDescriptor.to_interface (c->get_value (), true);
// e->set_value (v * 127);
cb->set_led_state (c->get_value ());
};
cb->set_plugin_action ([=] (uint32_t val) {
double v = val / 127.f;
c->set_value (parameterDescriptor.from_interface (v, true),
PBD::Controllable::GroupControlDisposition::UseGroup);
DEBUG_TRACE (
DEBUG::Console1,
string_compose ("ControllerButton Plugin parameter %1: %2 - %3\n", n_controls, val, v));
});
c->Changed.connect (
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
continue;
} catch (ControlNotFoundException&) {
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
}
}
}
++n_controls;
}
return true;
}
void
Console1::map_p ()
{
DEBUG_TRACE (DEBUG::Console1, "Console1::map_p");
}
}

View File

@ -63,6 +63,19 @@ Console1::~Console1 ()
tear_down_gui ();
for( const auto &[a, b] : buttons ){
delete b;
}
for( const auto &[a, b] : encoders ){
delete b;
}
for( const auto &[a, b] : meters ){
delete b;
}
for( const auto &[a, b] : multi_buttons ){
delete b;
}
/* stop event loop */
DEBUG_TRACE (DEBUG::Console1, "BaseUI::quit ()\n");
@ -73,7 +86,7 @@ void
Console1::all_lights_out ()
{
for (ButtonMap::iterator b = buttons.begin (); b != buttons.end (); ++b) {
b->second.set_led_state (false);
b->second->set_led_state (false);
}
}
@ -94,7 +107,7 @@ Console1::set_active (bool yn)
BaseUI::run ();
connect_session_signals ();
// connect_session_signals ();
} else {
/* Control Protocol Manager never calls us with false, but
@ -227,161 +240,150 @@ Console1::setup_controls ()
{
for (uint32_t i = 0; i < 20; ++i) {
ControllerButton track_select_button (
*this,
ControllerID (FOCUS1 + i),
boost::function<void (uint32_t)> (boost::bind (&Console1::select, this, i)),
0,
boost::function<void (uint32_t)> (boost::bind (&Console1::select_plugin, this, i)));
new ControllerButton (this,
ControllerID (FOCUS1 + i),
boost::function<void (uint32_t)> (boost::bind (&Console1::select, this, i)),
0,
boost::function<void (uint32_t)> (boost::bind (&Console1::select_plugin, this, i)));
}
ControllerButton shift_button (
*this, ControllerID::PRESET, boost::function<void (uint32_t)> (boost::bind (&Console1::shift, this, _1)));
new ControllerButton (
this, ControllerID::PRESET, boost::function<void (uint32_t)> (boost::bind (&Console1::shift, this, _1)));
ControllerButton plugin_state_button (
*this,
ControllerID::TRACK_GROUP,
boost::function<void (uint32_t)> (boost::bind (&Console1::plugin_state, this, _1)));
new ControllerButton (this,
ControllerID::TRACK_GROUP,
boost::function<void (uint32_t)> (boost::bind (&Console1::plugin_state, this, _1)));
ControllerButton rude_solo (
*this, ControllerID::DISPLAY_ON, boost::function<void (uint32_t)> (boost::bind (&Console1::rude_solo, this, _1)));
ControllerButton zoom_button (
*this, ControllerID::MODE, boost::function<void (uint32_t)> (boost::bind (&Console1::zoom, this, _1)));
MultiStateButton view (*this,
ControllerID::EXTERNAL_SIDECHAIN,
std::vector<uint32_t>{ 0, 63, 127 },
boost::function<void (uint32_t)> (boost::bind (&Console1::window, this, _1)));
new ControllerButton (
this, ControllerID::DISPLAY_ON, boost::function<void (uint32_t)> (boost::bind (&Console1::rude_solo, this, _1)));
new ControllerButton (
this, ControllerID::MODE, boost::function<void (uint32_t)> (boost::bind (&Console1::zoom, this, _1)));
new MultiStateButton (this,
ControllerID::EXTERNAL_SIDECHAIN,
std::vector<uint32_t>{ 0, 63, 127 },
boost::function<void (uint32_t)> (boost::bind (&Console1::window, this, _1)));
ControllerButton bank_up_button (
*this, ControllerID::PAGE_UP, boost::function<void (uint32_t)> (boost::bind (&Console1::bank, this, true)));
ControllerButton bank_down_button (
*this, ControllerID::PAGE_DOWN, boost::function<void (uint32_t)> (boost::bind (&Console1::bank, this, false)));
new ControllerButton (
this, ControllerID::PAGE_UP, boost::function<void (uint32_t)> (boost::bind (&Console1::bank, this, true)));
new ControllerButton (
this, ControllerID::PAGE_DOWN, boost::function<void (uint32_t)> (boost::bind (&Console1::bank, this, false)));
ControllerButton mute_button (
*this, ControllerID::MUTE, boost::function<void (uint32_t)> (boost::bind (&Console1::mute, this, _1)));
ControllerButton solo_button (
*this, ControllerID::SOLO, boost::function<void (uint32_t)> (boost::bind (&Console1::solo, this, _1)));
ControllerButton phase_button (
*this, ControllerID::PHASE_INV, boost::function<void (uint32_t)> (boost::bind (&Console1::phase, this, _1)));
new ControllerButton (
this, ControllerID::MUTE, boost::function<void (uint32_t)> (boost::bind (&Console1::mute, this, _1)));
new ControllerButton (
this, ControllerID::SOLO, boost::function<void (uint32_t)> (boost::bind (&Console1::solo, this, _1)));
new ControllerButton (
this, ControllerID::PHASE_INV, boost::function<void (uint32_t)> (boost::bind (&Console1::phase, this, _1)));
/*
Console 1: Input Gain - Ardour / Mixbus: Trim
*/
Encoder trim_encoder (
*this, ControllerID::GAIN, boost::function<void (uint32_t)> (boost::bind (&Console1::trim, this, _1)));
new Encoder (this, ControllerID::GAIN, boost::function<void (uint32_t)> (boost::bind (&Console1::trim, this, _1)));
/*
Console 1: Volume - Ardour / Mixbus: Gain
*/
Encoder gain_encoder (
*this, ControllerID::VOLUME, boost::function<void (uint32_t)> (boost::bind (&Console1::gain, this, _1)));
new Encoder (
this, ControllerID::VOLUME, boost::function<void (uint32_t)> (boost::bind (&Console1::gain, this, _1)));
Encoder pan_encoder (
*this, ControllerID::PAN, boost::function<void (uint32_t)> (boost::bind (&Console1::pan, this, _1)));
new Encoder (this, ControllerID::PAN, boost::function<void (uint32_t)> (boost::bind (&Console1::pan, this, _1)));
/* Filter Section*/
ControllerButton filter_button (*this,
ControllerID::FILTER_TO_COMPRESSORS,
boost::function<void (uint32_t)> (boost::bind (&Console1::filter, this, _1)));
Encoder low_cut_encoder (
*this, ControllerID::LOW_CUT, boost::function<void (uint32_t)> (boost::bind (&Console1::low_cut, this, _1)));
Encoder high_cut_encoder (
*this, ControllerID::HIGH_CUT, boost::function<void (uint32_t)> (boost::bind (&Console1::high_cut, this, _1)));
new ControllerButton (this,
ControllerID::FILTER_TO_COMPRESSORS,
boost::function<void (uint32_t)> (boost::bind (&Console1::filter, this, _1)));
new Encoder (
this, ControllerID::LOW_CUT, boost::function<void (uint32_t)> (boost::bind (&Console1::low_cut, this, _1)));
new Encoder (
this, ControllerID::HIGH_CUT, boost::function<void (uint32_t)> (boost::bind (&Console1::high_cut, this, _1)));
/* Gate Section */
ControllerButton gate_on_off (
*this, ControllerID::SHAPE, boost::function<void (uint32_t)> (boost::bind (&Console1::gate, this, _1)));
ControllerButton gate_scf_listen (
*this,
ControllerID::HARD_GATE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_scf, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_listen, this, _1)));
Encoder gate_thresh_encoder (*this,
ControllerID::SHAPE_GATE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_thresh, this, _1)));
Encoder gate_release_encoder (*this,
ControllerID::SHAPE_RELEASE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_release, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_hyst, this, _1)));
Encoder gate_attack_encoder (*this,
ControllerID::SHAPE_SUSTAIN,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_attack, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_hold, this, _1)));
Encoder gate_depth_encoder (*this,
ControllerID::SHAPE_PUNCH,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_depth, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_filter_freq, this, _1)));
new ControllerButton (
this, ControllerID::SHAPE, boost::function<void (uint32_t)> (boost::bind (&Console1::gate, this, _1)));
new ControllerButton (this,
ControllerID::HARD_GATE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_scf, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_listen, this, _1)));
new Encoder (this,
ControllerID::SHAPE_GATE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_thresh, this, _1)));
new Encoder (this,
ControllerID::SHAPE_RELEASE,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_release, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_hyst, this, _1)));
new Encoder (this,
ControllerID::SHAPE_SUSTAIN,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_attack, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_hold, this, _1)));
new Encoder (this,
ControllerID::SHAPE_PUNCH,
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_depth, this, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::gate_filter_freq, this, _1)));
Meter gate_meter (*this, ControllerID::SHAPE_METER, boost::function<void ()> ([] () {}));
new Meter (this, ControllerID::SHAPE_METER, boost::function<void ()> ([] () {}));
/* EQ Section */
ControllerButton eq_on_off (
*this, ControllerID::EQ, boost::function<void (uint32_t)> (boost::bind (&Console1::eq, this, _1)));
new ControllerButton (
this, ControllerID::EQ, boost::function<void (uint32_t)> (boost::bind (&Console1::eq, this, _1)));
for (uint32_t i = 0; i < 4; ++i) {
Encoder low_freq_encoder (
*this,
eq_freq_controller_for_band (i),
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_freq, this, i, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, i, _1)));
Encoder low_gain_encoder (
*this,
eq_gain_controller_for_band (i),
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_gain, this, i, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, i + 4, _1)));
new Encoder (this,
eq_freq_controller_for_band (i),
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_freq, this, i, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, i, _1)));
new Encoder (this,
eq_gain_controller_for_band (i),
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_gain, this, i, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, i + 4, _1)));
}
Encoder low_mid_shape_encoder (
*this,
ControllerID::LOW_MID_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 10, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 8, _1)));
Encoder high_mid_shape_encoder (
*this,
ControllerID::HIGH_MID_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 11, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 9, _1)));
new Encoder (this,
ControllerID::LOW_MID_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 10, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 8, _1)));
new Encoder (this,
ControllerID::HIGH_MID_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 11, _1)),
boost::function<void (uint32_t)> (boost::bind (&Console1::mb_send_level, this, 9, _1)));
ControllerButton eq_low_shape (*this,
ControllerID::LOW_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_low_shape, this, _1)));
ControllerButton eq_high_shape (
*this,
ControllerID::HIGH_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_high_shape, this, _1)));
new ControllerButton (this,
ControllerID::LOW_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_low_shape, this, _1)));
new ControllerButton (this,
ControllerID::HIGH_SHAPE,
boost::function<void (uint32_t)> (boost::bind (&Console1::eq_high_shape, this, _1)));
Encoder drive_encoder (
*this, ControllerID::CHARACTER, boost::function<void (uint32_t)> (boost::bind (&Console1::drive, this, _1)));
new Encoder (
this, ControllerID::CHARACTER, boost::function<void (uint32_t)> (boost::bind (&Console1::drive, this, _1)));
/* Compressor Section */
ControllerButton comp_on_off (
*this, ControllerID::COMP, boost::function<void (uint32_t)> (boost::bind (&Console1::comp, this, _1)));
MultiStateButton comp_mode (*this,
ControllerID::ORDER,
std::vector<uint32_t>{ 0, 63, 127 },
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_mode, this, _1)));
new ControllerButton (
this, ControllerID::COMP, boost::function<void (uint32_t)> (boost::bind (&Console1::comp, this, _1)));
new MultiStateButton (this,
ControllerID::ORDER,
std::vector<uint32_t>{ 0, 63, 127 },
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_mode, this, _1)));
Encoder comp_thresh_encoder (*this,
ControllerID::COMP_THRESH,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_thresh, this, _1)));
Encoder comp_attack_encoder (*this,
ControllerID::COMP_ATTACK,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_attack, this, _1)));
Encoder comp_release_encoder (*this,
ControllerID::COMP_RELEASE,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_release, this, _1)));
Encoder comp_ratio_encoder (*this,
ControllerID::COMP_RATIO,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_ratio, this, _1)));
Encoder comp_makeup_encoder (
*this, ControllerID::COMP_PAR, boost::function<void (uint32_t)> (boost::bind (&Console1::comp_makeup, this, _1)));
Encoder comp_emph_encoder (
*this, ControllerID::DRIVE, boost::function<void (uint32_t)> (boost::bind (&Console1::comp_emph, this, _1)));
new Encoder (this,
ControllerID::COMP_THRESH,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_thresh, this, _1)));
new Encoder (this,
ControllerID::COMP_ATTACK,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_attack, this, _1)));
new Encoder (this,
ControllerID::COMP_RELEASE,
boost::function<void (uint32_t)> (boost::bind (&Console1::comp_release, this, _1)));
new Encoder (
this, ControllerID::COMP_RATIO, boost::function<void (uint32_t)> (boost::bind (&Console1::comp_ratio, this, _1)));
new Encoder (
this, ControllerID::COMP_PAR, boost::function<void (uint32_t)> (boost::bind (&Console1::comp_makeup, this, _1)));
new Encoder (
this, ControllerID::DRIVE, boost::function<void (uint32_t)> (boost::bind (&Console1::comp_emph, this, _1)));
Meter compressor_meter (*this, ControllerID::COMP_METER, boost::function<void ()> ([] () {}));
new Meter (this, ControllerID::COMP_METER, boost::function<void ()> ([] () {}));
/* Output Section */
Meter output_meter_l (*this, ControllerID::OUTPUT_METER_L, boost::function<void ()> ([] () {}));
Meter output_meter_r (*this, ControllerID::OUTPUT_METER_R, boost::function<void ()> ([] () {}));
new Meter (this, ControllerID::OUTPUT_METER_L, boost::function<void ()> ([] () {}));
new Meter (this, ControllerID::OUTPUT_METER_R, boost::function<void ()> ([] () {}));
}
int
@ -404,11 +406,13 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
DEBUG_TRACE (DEBUG::Console1,
string_compose ("handle_midi_controller_message cn: '%1' val: '%2'\n", controller_number, value));
try {
Encoder e = get_encoder (ControllerID (controller_number));
if (shift_state && e.shift_action) {
e.shift_action (value);
Encoder* e = get_encoder (ControllerID (controller_number));
if (in_plugin_state && e->plugin_action) {
e->plugin_action (value);
} else if (shift_state && e->shift_action) {
e->shift_action (value);
} else {
e.action (value);
e->action (value);
}
return;
} catch (ControlNotFoundException& e) {
@ -420,16 +424,16 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
}
try {
ControllerButton& b = get_button (ControllerID (controller_number));
if (in_plugin_state && b.plugin_action) {
ControllerButton* b = get_button (ControllerID (controller_number));
if (in_plugin_state && b->plugin_action) {
DEBUG_TRACE (DEBUG::Console1, "Executing plugin_action\n");
b.plugin_action (value);
} else if (shift_state && b.shift_action) {
b->plugin_action (value);
} else if (shift_state && b->shift_action) {
DEBUG_TRACE (DEBUG::Console1, "Executing shift_action\n");
b.shift_action (value);
b->shift_action (value);
} else {
DEBUG_TRACE (DEBUG::Console1, "Executing action\n");
b.action (value);
b->action (value);
}
return;
} catch (ControlNotFoundException& e) {
@ -441,11 +445,11 @@ Console1::handle_midi_controller_message (MIDI::Parser&, MIDI::EventTwoBytes* tb
}
try {
MultiStateButton mb = get_mbutton (ControllerID (controller_number));
if (shift_state && mb.shift_action) {
mb.shift_action (value);
MultiStateButton* mb = get_mbutton (ControllerID (controller_number));
if (shift_state && mb->shift_action) {
mb->shift_action (value);
} else {
mb.action (value);
mb->action (value);
}
return;
@ -469,7 +473,7 @@ Console1::notify_solo_active_changed (bool state)
{
DEBUG_TRACE (DEBUG::Console1, "notify_active_solo_changed() \n");
try {
get_button (ControllerID::DISPLAY_ON).set_led_value (state ? 127 : 0);
get_button (ControllerID::DISPLAY_ON)->set_led_value (state ? 127 : 0);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "button not found");
}
@ -518,6 +522,8 @@ Console1::set_current_stripable (std::shared_ptr<Stripable> r)
if (_current_stripable) {
DEBUG_TRACE (DEBUG::Console1, "current_stripable found: \n");
current_plugin_index = -1;
PresentationInfo pi = _current_stripable->presentation_info ();
DEBUG_TRACE (DEBUG::Console1, string_compose ("current_stripable %1 - %2\n", pi.order (), pi.flags ()));
@ -835,14 +841,14 @@ void
Console1::stop_blinking (ControllerID id)
{
blinkers.remove (id);
get_button (id).set_led_state (false);
get_button (id)->set_led_state (false);
}
void
Console1::start_blinking (ControllerID id)
{
blinkers.push_back (id);
get_button (id).set_led_state (true);
get_button (id)->set_led_state (true);
}
bool
@ -852,7 +858,7 @@ Console1::blinker ()
for (Blinkers::iterator b = blinkers.begin (); b != blinkers.end (); b++) {
try {
get_button (*b).set_led_state (blink_state);
get_button (*b)->set_led_state (blink_state);
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Blinking Button not found ...\n");
}
@ -861,40 +867,40 @@ Console1::blinker ()
return true;
}
ControllerButton&
ControllerButton*
Console1::get_button (ControllerID id) const
{
ButtonMap::const_iterator b = buttons.find (id);
if (b == buttons.end ())
throw (ControlNotFoundException ());
return const_cast<ControllerButton&> (b->second);
return const_cast<ControllerButton*> (b->second);
}
Meter&
Meter*
Console1::get_meter (ControllerID id) const
{
MeterMap::const_iterator m = meters.find (id);
if (m == meters.end ())
throw (ControlNotFoundException ());
return const_cast<Meter&> (m->second);
return const_cast<Meter*> (m->second);
}
Encoder&
Encoder*
Console1::get_encoder (ControllerID id) const
{
EncoderMap::const_iterator m = encoders.find (id);
if (m == encoders.end ())
throw (ControlNotFoundException ());
return const_cast<Encoder&> (m->second);
return const_cast<Encoder*> (m->second);
}
MultiStateButton&
MultiStateButton*
Console1::get_mbutton (ControllerID id) const
{
MultiStateButtonMap::const_iterator m = multi_buttons.find (id);
if (m == multi_buttons.end ())
throw (ControlNotFoundException ());
return const_cast<MultiStateButton&> (m->second);
return const_cast<MultiStateButton*> (m->second);
}
ControllerID
@ -934,11 +940,11 @@ Console1::periodic_update_meter ()
}
try {
if (val_l != last_output_meter_l) {
get_meter (OUTPUT_METER_L).set_value (val_l);
get_meter (OUTPUT_METER_L)->set_value (val_l);
last_output_meter_l = val_l;
}
if (val_r != last_output_meter_r) {
get_meter (OUTPUT_METER_R).set_value (val_r);
get_meter (OUTPUT_METER_R)->set_value (val_r);
last_output_meter_r = val_r;
}
} catch (ControlNotFoundException& e) {
@ -955,7 +961,7 @@ Console1::periodic_update_meter ()
}
try {
if (val != last_gate_meter) {
get_meter (SHAPE_METER).set_value (val);
get_meter (SHAPE_METER)->set_value (val);
last_gate_meter = val;
}
} catch (ControlNotFoundException& e) {
@ -975,7 +981,7 @@ Console1::periodic_update_meter ()
if (val != last_comp_redux) {
last_comp_redux = val;
val = val * 0.6 + last_comp_redux * 0.4;
get_meter (COMP_METER).set_value (val);
get_meter (COMP_METER)->set_value (val);
}
} catch (ControlNotFoundException& e) {
DEBUG_TRACE (DEBUG::Console1, "Meter not found ...\n");

View File

@ -93,6 +93,8 @@ class Console1 : public MIDISurface
public:
Console1 (ARDOUR::Session&);
virtual ~Console1 ();
void map_p();
int set_active (bool yn);
@ -295,6 +297,10 @@ class Console1 : public MIDISurface
std::weak_ptr<ARDOUR::Stripable> pre_master_stripable;
std::weak_ptr<ARDOUR::Stripable> pre_monitor_stripable;
void create_encoder (ControllerID id,
boost::function<void (uint32_t)> action,
boost::function<void (uint32_t)> shift_action = 0);
void setup_controls ();
bool strip_recenabled = false;
@ -327,22 +333,22 @@ class Console1 : public MIDISurface
void select_rid_by_index (const uint32_t index);
/* Controller Maps*/
typedef std::map<ControllerID, ArdourSurface::ControllerButton> ButtonMap;
typedef std::map<ControllerID, ArdourSurface::MultiStateButton> MultiStateButtonMap;
typedef std::map<ControllerID, ArdourSurface::Meter> MeterMap;
typedef std::map<ControllerID, ArdourSurface::Encoder> EncoderMap;
typedef std::map<ControllerID, ArdourSurface::ControllerButton*> ButtonMap;
typedef std::map<ControllerID, ArdourSurface::MultiStateButton*> MultiStateButtonMap;
typedef std::map<ControllerID, ArdourSurface::Meter*> MeterMap;
typedef std::map<ControllerID, ArdourSurface::Encoder*> EncoderMap;
ButtonMap buttons;
ControllerButton& get_button (ControllerID) const;
ControllerButton* get_button (ControllerID) const;
MultiStateButtonMap multi_buttons;
MultiStateButton& get_mbutton (ControllerID id) const;
MultiStateButton* get_mbutton (ControllerID id) const;
MeterMap meters;
Meter& get_meter (ControllerID) const;
Meter* get_meter (ControllerID) const;
EncoderMap encoders;
Encoder& get_encoder (ControllerID) const;
Encoder* get_encoder (ControllerID) const;
typedef std::map<uint32_t, ControllerID> SendControllerMap;
SendControllerMap send_controllers{ { 0, LOW_FREQ }, { 1, LOW_MID_FREQ }, { 2, HIGH_MID_FREQ },
@ -389,6 +395,7 @@ class Console1 : public MIDISurface
/*PBD::ScopedConnection selection_connection;*/
PBD::ScopedConnectionList stripable_connections;
PBD::ScopedConnectionList console1_connections;
PBD::ScopedConnectionList plugin_connections;
void map_stripable_state ();