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
This commit is contained in:
Paul Davis 2012-04-19 00:30:55 +00:00
parent 66398a7e16
commit 0eee85f43b
2 changed files with 21 additions and 0 deletions

View File

@ -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 ();

View File

@ -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>();
}