diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 89a0cac214..bdda941a97 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -397,6 +397,15 @@ class Route : public SessionObject, public Automatable, public RouteGroupMember, boost::shared_ptr gain_control() const; boost::shared_ptr pannable() const; + /** + Return the first processor that accepts has at least one MIDI input + and at least one audio output. In the vast majority of cases, this + will be "the instrument". This does not preclude other MIDI->audio + processors later in the processing chain, but that would be a + special case not covered by this utility function. + */ + boost::shared_ptr the_instrument() const; + void automation_snapshot (framepos_t now, bool force=false); void protect_automation (); diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 6e36a133e9..3f68e266eb 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -4054,3 +4054,15 @@ Route::has_external_redirects () const return false; } +boost::shared_ptr +Route::the_instrument () const +{ + Glib::RWLock::WriterLock lm (_processor_lock); + for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) { + if ((*i)->input_streams().n_midi() > 0 && + (*i)->output_streams().n_audio() > 0) { + return (*i); + } + } + return boost::shared_ptr(); +}