diff options
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/bundle.h | 1 | ||||
-rw-r--r-- | libs/ardour/bundle.cc | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 6b8586a46a..821dd57896 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -100,6 +100,7 @@ class Bundle : public PBD::ScopedConnectionList void disconnect (boost::shared_ptr<Bundle>, AudioEngine &); bool connected_to (boost::shared_ptr<Bundle>, AudioEngine &); bool has_same_ports (boost::shared_ptr<Bundle>) const; + uint32_t type_channel_to_overall (DataType, uint32_t) const; void set_name (std::string const &); diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index d8666c5bbb..d9fc86e2ad 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -517,3 +517,44 @@ Bundle::operator== (Bundle const & other) { return _channel == other._channel; } + +/** Given an index of a channel as the nth channel of a particular type, + * return an index of that channel when considering channels of all types. + * + * e.g. given a bundle with channels: + * fred [audio] + * jim [audio] + * sheila [midi] + * + * If t == MIDI and c == 0, then we would return 2, as 2 is the index of the + * 0th MIDI channel. + */ + +uint32_t +Bundle::type_channel_to_overall (DataType t, uint32_t c) const +{ + Glib::Mutex::Lock lm (_channel_mutex); + + vector<Channel>::const_iterator i = _channel.begin (); + + uint32_t o = 0; + + while (1) { + + assert (i != _channel.end ()); + + if (i->type != t) { + ++i; + } else { + if (c == 0) { + return o; + } + --c; + } + + ++o; + } + + /* NOTREACHED */ + return -1; +} |