+boost::shared_ptr<Controllable>
+Session::controllable_by_descriptor (const ControllableDescriptor& desc)
+{
+ boost::shared_ptr<Controllable> c;
+ boost::shared_ptr<Route> r;
+
+ switch (desc.top_level_type()) {
+ case ControllableDescriptor::NamedRoute:
+ {
+ std::string str = desc.top_level_name();
+ if (str == "master") {
+ r = _master_out;
+ } else if (str == "control" || str == "listen") {
+ r = _monitor_out;
+ } else {
+ r = route_by_name (desc.top_level_name());
+ }
+ break;
+ }
+
+ case ControllableDescriptor::RemoteControlID:
+ r = route_by_remote_id (desc.rid());
+ break;
+ }
+
+ if (!r) {
+ return c;
+ }
+
+ switch (desc.subtype()) {
+ case ControllableDescriptor::Gain:
+ c = r->gain_control ();
+ break;
+
+ case ControllableDescriptor::Solo:
+ c = r->solo_control();
+ break;
+
+ case ControllableDescriptor::Mute:
+ c = r->mute_control();
+ break;
+
+ case ControllableDescriptor::Recenable:
+ {
+ boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track>(r);
+
+ if (t) {
+ c = t->rec_enable_control ();
+ }
+ break;
+ }
+
+ case ControllableDescriptor::Pan:
+ /* XXX pan control */
+ break;
+
+ case ControllableDescriptor::Balance:
+ /* XXX simple pan control */
+ break;
+
+ case ControllableDescriptor::PluginParameter:
+ {
+ uint32_t plugin = desc.target (0);
+ uint32_t parameter_index = desc.target (1);
+
+ /* revert to zero based counting */
+
+ if (plugin > 0) {
+ --plugin;
+ }
+
+ if (parameter_index > 0) {
+ --parameter_index;
+ }
+
+ boost::shared_ptr<Processor> p = r->nth_plugin (plugin);
+
+ if (p) {
+ c = boost::dynamic_pointer_cast<ARDOUR::AutomationControl>(
+ p->control(Evoral::Parameter(PluginAutomation, 0, parameter_index)));
+ }
+ break;
+ }
+
+ case ControllableDescriptor::SendGain:
+ {
+ uint32_t send = desc.target (0);
+
+ /* revert to zero-based counting */
+
+ if (send > 0) {
+ --send;
+ }
+
+ boost::shared_ptr<Processor> p = r->nth_send (send);
+
+ if (p) {
+ boost::shared_ptr<Send> s = boost::dynamic_pointer_cast<Send>(p);
+ boost::shared_ptr<Amp> a = s->amp();
+
+ if (a) {
+ c = s->amp()->gain_control();
+ }
+ }
+ break;
+ }
+
+ default:
+ /* relax and return a null pointer */
+ break;
+ }
+
+ return c;
+}
+
+void