+boost::shared_ptr<Route>
+Session::get_midi_nth_route_by_id (PresentationInfo::order_t n) const
+{
+ PresentationInfo::Flag f;
+
+ if (n == 318) {
+ f = PresentationInfo::MasterOut;
+ } else if (n == 319) {
+ f = PresentationInfo::MonitorOut;
+ } else {
+ f = PresentationInfo::Route;
+ }
+
+ boost::shared_ptr<RouteList> r = routes.reader ();
+ PresentationInfo::order_t match_cnt = 0;
+
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->presentation_info().flag_match (f)) {
+ if (match_cnt++ == n) {
+ return *i;
+ }
+ }
+ }
+
+ return boost::shared_ptr<Route>();
+}
+