diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-19 00:30:55 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2012-04-19 00:30:55 +0000 |
commit | 0eee85f43b2435277c7cccda8e5145761bcb98a8 (patch) | |
tree | 6f1ddb53eb2c91511c4d60e9582d4631ea441dd2 /libs/ardour | |
parent | 66398a7e1633ed67bbbc25f9cf65e7ef5551aa4b (diff) |
add a simple method to return "the instrument" associated with a Route. see the comments about the semantics of this, which do not preclude 0..N "instruments" in a single route
git-svn-id: svn://localhost/ardour2/branches/3.0@12027 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/route.h | 9 | ||||
-rw-r--r-- | libs/ardour/route.cc | 12 |
2 files changed, 21 insertions, 0 deletions
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<AutomationControl> gain_control() const; boost::shared_ptr<Pannable> 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<Processor> 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<Processor> +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<Processor>(); +} |