fix plugin selection
This commit is contained in:
parent
4dd58961d2
commit
ac00b4a0bb
|
@ -126,50 +126,59 @@ Console1::load_mapping (FILE* fin)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
Console1::select_plugin (uint32_t plugin_index)
|
Console1::select_plugin (const uint32_t plugin_index)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::Console1, "Console1::select_plugin\n");
|
DEBUG_TRACE (DEBUG::Console1, "Console1::select_plugin\n");
|
||||||
if (current_plugin_index == plugin_index) {
|
if (current_plugin_index == plugin_index) {
|
||||||
std::shared_ptr<Route> r = std::dynamic_pointer_cast<Route> (_current_stripable);
|
std::shared_ptr<Route> r = std::dynamic_pointer_cast<Route> (_current_stripable);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
std::shared_ptr<Processor> proc = r->nth_plugin (plugin_index);
|
std::shared_ptr<Processor> proc = r->nth_plugin (plugin_index);
|
||||||
if (!proc) {
|
if (!proc) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
if (!proc->display_to_user ()) {
|
if (!proc->display_to_user ()) {
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
std::shared_ptr<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc);
|
std::shared_ptr<PluginInsert> plugin_insert = std::dynamic_pointer_cast<PluginInsert> (proc);
|
||||||
if (!plugin_insert)
|
if (!plugin_insert)
|
||||||
return;
|
return false;
|
||||||
plugin_insert->ToggleUI ();
|
plugin_insert->ToggleUI ();
|
||||||
return;
|
return true;
|
||||||
}
|
}
|
||||||
current_plugin_index = plugin_index;
|
if (map_select_plugin (plugin_index)) {
|
||||||
map_select_plugin ();
|
return true;
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
Console1::map_select_plugin ()
|
|
||||||
{
|
|
||||||
DEBUG_TRACE (DEBUG::Console1, "map_select_plugin())\n");
|
|
||||||
bool plugin_availabe = spill_plugins (current_plugin_index);
|
|
||||||
for (uint32_t i = 0; i < bank_size; ++i) {
|
|
||||||
if (i == current_plugin_index && plugin_availabe) {
|
|
||||||
start_blinking (ControllerID (FOCUS1 + i));
|
|
||||||
} else if (i != current_strippable_index) {
|
|
||||||
stop_blinking (ControllerID (FOCUS1 + i));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
Console1::spill_plugins (uint32_t plugin_index)
|
Console1::map_select_plugin (const uint32_t plugin_index)
|
||||||
|
{
|
||||||
|
DEBUG_TRACE (DEBUG::Console1, "map_select_plugin())\n");
|
||||||
|
if (spill_plugins (plugin_index)) {
|
||||||
|
for (uint32_t i = 0; i < bank_size; ++i) {
|
||||||
|
if (i == plugin_index) {
|
||||||
|
start_blinking (ControllerID (FOCUS1 + i));
|
||||||
|
} else if (i != current_strippable_index) {
|
||||||
|
stop_blinking (ControllerID (FOCUS1 + i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
current_plugin_index = plugin_index;
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
get_button (ControllerID (FOCUS1 + plugin_index))->set_led_state (plugin_index == current_strippable_index);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Console1::spill_plugins (const uint32_t plugin_index)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins(%1)\n", plugin_index));
|
DEBUG_TRACE (DEBUG::Console1, string_compose ("spill_plugins(%1)\n", plugin_index));
|
||||||
|
bool mapping_found = false;
|
||||||
std::shared_ptr<Route> r = std::dynamic_pointer_cast<Route> (_current_stripable);
|
std::shared_ptr<Route> r = std::dynamic_pointer_cast<Route> (_current_stripable);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -182,9 +191,9 @@ Console1::spill_plugins (uint32_t plugin_index)
|
||||||
e.second->set_value (0);
|
e.second->set_value (0);
|
||||||
}
|
}
|
||||||
for (auto& c : buttons) {
|
for (auto& c : buttons) {
|
||||||
if( c.first == ControllerID::TRACK_GROUP )
|
if (c.first == ControllerID::TRACK_GROUP)
|
||||||
continue;
|
continue;
|
||||||
if( c.first >= ControllerID::FOCUS1 && c.first <= ControllerID::FOCUS20 )
|
if (c.first >= ControllerID::FOCUS1 && c.first <= ControllerID::FOCUS20)
|
||||||
continue;
|
continue;
|
||||||
c.second->set_plugin_action (0);
|
c.second->set_plugin_action (0);
|
||||||
c.second->set_led_state (false);
|
c.second->set_led_state (false);
|
||||||
|
@ -218,9 +227,7 @@ Console1::spill_plugins (uint32_t plugin_index)
|
||||||
DEBUG_TRACE (DEBUG::Console1, string_compose ("Found plugin id %1\n", plugin->unique_id ()));
|
DEBUG_TRACE (DEBUG::Console1, string_compose ("Found plugin id %1\n", plugin->unique_id ()));
|
||||||
|
|
||||||
PluginMappingMap::iterator pmmit = pluginMappingMap.find (plugin->unique_id ());
|
PluginMappingMap::iterator pmmit = pluginMappingMap.find (plugin->unique_id ());
|
||||||
if (pmmit == pluginMappingMap.end ()) {
|
mapping_found = (pmmit != pluginMappingMap.end ());
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PluginMapping pluginMapping = pmmit->second;
|
PluginMapping pluginMapping = pmmit->second;
|
||||||
DEBUG_TRACE (DEBUG::Console1,
|
DEBUG_TRACE (DEBUG::Console1,
|
||||||
|
@ -228,24 +235,24 @@ Console1::spill_plugins (uint32_t plugin_index)
|
||||||
|
|
||||||
set<Evoral::Parameter> p = proc->what_can_be_automated ();
|
set<Evoral::Parameter> p = proc->what_can_be_automated ();
|
||||||
|
|
||||||
PluginParameterMapping enableMapping = pluginMapping.parameters[-1];
|
try {
|
||||||
if (enableMapping.controllerId != 0) {
|
ControllerButton* cb = get_button (ControllerID::MUTE);
|
||||||
try {
|
boost::function<void ()> plugin_mapping = [=] () -> void { cb->set_led_state (plugin_insert->enabled ()); };
|
||||||
ControllerButton* cb = get_button (enableMapping.controllerId);
|
cb->set_plugin_action ([=] (uint32_t val) {
|
||||||
boost::function<void ()> plugin_mapping = [=] () -> void { cb->set_led_state (plugin_insert->enabled ()); };
|
plugin_insert->enable (val == 127);
|
||||||
cb->set_plugin_action ([=] (uint32_t val) {
|
DEBUG_TRACE (DEBUG::Console1,
|
||||||
plugin_insert->enable (val == 127);
|
string_compose ("ControllerButton Plugin parameter %1: %2 \n", n_controls, val));
|
||||||
DEBUG_TRACE (DEBUG::Console1,
|
});
|
||||||
string_compose ("ControllerButton Plugin parameter %1: %2 \n", n_controls, val));
|
|
||||||
});
|
|
||||||
|
|
||||||
plugin_insert->ActiveChanged.connect (
|
plugin_insert->ActiveChanged.connect (
|
||||||
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping), this);
|
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping), this);
|
||||||
plugin_insert->ActiveChanged ();
|
plugin_insert->ActiveChanged ();
|
||||||
} catch (ControlNotFoundException&) {
|
} catch (ControlNotFoundException&) {
|
||||||
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
|
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
if( !mapping_found )
|
||||||
|
return true;
|
||||||
|
|
||||||
for (set<Evoral::Parameter>::iterator j = p.begin (); j != p.end (); ++j) {
|
for (set<Evoral::Parameter>::iterator j = p.begin (); j != p.end (); ++j) {
|
||||||
++n_controls;
|
++n_controls;
|
||||||
|
@ -274,50 +281,51 @@ Console1::spill_plugins (uint32_t plugin_index)
|
||||||
swtch = true;
|
swtch = true;
|
||||||
}
|
}
|
||||||
PluginParameterMapping ppm = pluginMapping.parameters[n_controls];
|
PluginParameterMapping ppm = pluginMapping.parameters[n_controls];
|
||||||
try {
|
if (!swtch) {
|
||||||
Encoder* e = get_encoder (ppm.controllerId);
|
try {
|
||||||
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
|
Encoder* e = get_encoder (ppm.controllerId);
|
||||||
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
|
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
|
||||||
double v = parameterDescriptor.to_interface (c->get_value (), true);
|
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
|
||||||
e->set_value (v * 127);
|
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;
|
e->set_plugin_action ([=] (uint32_t val) {
|
||||||
c->set_value (parameterDescriptor.from_interface (v, true),
|
double v = val / 127.f;
|
||||||
PBD::Controllable::GroupControlDisposition::UseGroup);
|
c->set_value (parameterDescriptor.from_interface (v, true),
|
||||||
DEBUG_TRACE (DEBUG::Console1,
|
PBD::Controllable::GroupControlDisposition::UseGroup);
|
||||||
string_compose ("Encoder Plugin parameter %1: %2 - %3\n", n_controls, val, v));
|
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.connect (
|
||||||
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
|
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
|
||||||
continue;
|
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
|
||||||
} catch (ControlNotFoundException&) {
|
continue;
|
||||||
DEBUG_TRACE (DEBUG::Console1, string_compose ("No Encoder found %1\n", n_controls));
|
} catch (ControlNotFoundException&) {
|
||||||
}
|
DEBUG_TRACE (DEBUG::Console1, string_compose ("No Encoder found %1\n", n_controls));
|
||||||
try {
|
}
|
||||||
ControllerButton* cb = get_button (ppm.controllerId);
|
} else {
|
||||||
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
|
try {
|
||||||
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
|
ControllerButton* cb = get_button (ppm.controllerId);
|
||||||
// double v = parameterDescriptor.to_interface (c->get_value (), true);
|
boost::function<void (bool b, PBD::Controllable::GroupControlDisposition d)> plugin_mapping =
|
||||||
// e->set_value (v * 127);
|
[=] (bool b, PBD::Controllable::GroupControlDisposition d) -> void {
|
||||||
cb->set_led_state (c->get_value ());
|
cb->set_led_state (c->get_value ());
|
||||||
};
|
};
|
||||||
cb->set_plugin_action ([=] (uint32_t val) {
|
cb->set_plugin_action ([=] (uint32_t val) {
|
||||||
double v = val / 127.f;
|
double v = val / 127.f;
|
||||||
c->set_value (parameterDescriptor.from_interface (v, true),
|
c->set_value (parameterDescriptor.from_interface (v, true),
|
||||||
PBD::Controllable::GroupControlDisposition::UseGroup);
|
PBD::Controllable::GroupControlDisposition::UseGroup);
|
||||||
DEBUG_TRACE (
|
DEBUG_TRACE (
|
||||||
DEBUG::Console1,
|
DEBUG::Console1,
|
||||||
string_compose ("ControllerButton Plugin parameter %1: %2 - %3\n", n_controls, val, v));
|
string_compose ("ControllerButton Plugin parameter %1: %2 - %3\n", n_controls, val, v));
|
||||||
});
|
});
|
||||||
|
|
||||||
c->Changed.connect (
|
c->Changed.connect (
|
||||||
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
|
plugin_connections, MISSING_INVALIDATOR, boost::bind (plugin_mapping, _1, _2), this);
|
||||||
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
|
c->Changed (true, PBD::Controllable::GroupControlDisposition::UseGroup);
|
||||||
continue;
|
continue;
|
||||||
} catch (ControlNotFoundException&) {
|
} catch (ControlNotFoundException&) {
|
||||||
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
|
DEBUG_TRACE (DEBUG::Console1, string_compose ("No ControllerButton found %1\n", n_controls));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,16 +63,16 @@ Console1::~Console1 ()
|
||||||
|
|
||||||
tear_down_gui ();
|
tear_down_gui ();
|
||||||
|
|
||||||
for( const auto &[a, b] : buttons ){
|
for( const auto &[_, b] : buttons ){
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
for( const auto &[a, b] : encoders ){
|
for( const auto &[_, b] : encoders ){
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
for( const auto &[a, b] : meters ){
|
for( const auto &[_, b] : meters ){
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
for( const auto &[a, b] : multi_buttons ){
|
for( const auto &[_, b] : multi_buttons ){
|
||||||
delete b;
|
delete b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,8 +107,6 @@ Console1::set_active (bool yn)
|
||||||
|
|
||||||
BaseUI::run ();
|
BaseUI::run ();
|
||||||
|
|
||||||
// connect_session_signals ();
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* Control Protocol Manager never calls us with false, but
|
/* Control Protocol Manager never calls us with false, but
|
||||||
* insteads destroys us.
|
* insteads destroys us.
|
||||||
|
|
|
@ -93,8 +93,7 @@ class Console1 : public MIDISurface
|
||||||
public:
|
public:
|
||||||
Console1 (ARDOUR::Session&);
|
Console1 (ARDOUR::Session&);
|
||||||
virtual ~Console1 ();
|
virtual ~Console1 ();
|
||||||
void map_p();
|
void map_p ();
|
||||||
|
|
||||||
|
|
||||||
int set_active (bool yn);
|
int set_active (bool yn);
|
||||||
|
|
||||||
|
@ -572,12 +571,12 @@ class Console1 : public MIDISurface
|
||||||
};
|
};
|
||||||
|
|
||||||
/* plugin handling */
|
/* plugin handling */
|
||||||
bool spill_plugins (uint32_t plugin_index);
|
bool spill_plugins (const uint32_t plugin_index);
|
||||||
|
|
||||||
/* plugin operations */
|
/* plugin operations */
|
||||||
void select_plugin (const uint32_t i);
|
bool select_plugin (const uint32_t plugin_index);
|
||||||
|
|
||||||
void map_select_plugin ();
|
bool map_select_plugin (const uint32_t plugin_index);
|
||||||
|
|
||||||
using PluginMappingMap = std::map<std::string, PluginMapping>;
|
using PluginMappingMap = std::map<std::string, PluginMapping>;
|
||||||
PluginMappingMap pluginMappingMap;
|
PluginMappingMap pluginMappingMap;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user