{
clear_list ();
- /* Find the bundles for routes */
+ /* Find the bundles for routes. We take their bundles, copy them,
+ and add ports from the route's processors */
boost::shared_ptr<ARDOUR::Session::RouteList> routes = session.get_routes ();
for (ARDOUR::Session::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
+ /* Copy the appropriate bundle from the route */
+ boost::shared_ptr<ARDOUR::Bundle> bundle (
+ new ARDOUR::Bundle (
+ _offer_inputs ? (*i)->bundle_for_inputs() : (*i)->bundle_for_outputs ()
+ )
+ );
- /* Route IO */
- PortGroup* g = 0;
+ /* Add ports from the route's processors */
+ uint32_t n = 0;
+ while (1) {
+ boost::shared_ptr<ARDOUR::Processor> p = (*i)->nth_processor (n);
+ if (p == 0) {
+ break;
+ }
+ boost::shared_ptr<ARDOUR::IOProcessor> iop = boost::dynamic_pointer_cast<ARDOUR::IOProcessor> (p);
+
+ if (iop) {
+ boost::shared_ptr<ARDOUR::Bundle> pb = _offer_inputs ?
+ iop->io()->bundle_for_inputs() : iop->io()->bundle_for_outputs();
+ bundle->add_channels_from_bundle (pb);
+ }
+
+ ++n;
+ }
+
+ /* Work out which group to put this bundle in */
+ PortGroup* g = 0;
if (_type == ARDOUR::DataType::AUDIO) {
if (boost::dynamic_pointer_cast<ARDOUR::AudioTrack> (*i)) {
}
if (g) {
- g->add_bundle (_offer_inputs ? (*i)->bundle_for_inputs() : (*i)->bundle_for_outputs ());
- }
-
- /* Ports from this route's processors */
-
- uint32_t n = 0;
- while (1) {
- boost::shared_ptr<ARDOUR::Processor> p = (*i)->nth_processor (n);
- if (p == 0) {
- break;
- }
-
- boost::shared_ptr<ARDOUR::IOProcessor> iop = boost::dynamic_pointer_cast<ARDOUR::IOProcessor> (p);
- if (iop) {
- g->add_bundle (_offer_inputs ? iop->io()->bundle_for_inputs() : iop->io()->bundle_for_outputs());
- }
-
- ++n;
+ g->add_bundle (bundle);
}
}
#include <vector>
#include <glibmm/thread.h>
#include <sigc++/signal.h>
+#include <boost/shared_ptr.hpp>
#include "ardour/data_type.h"
namespace ARDOUR {
*/
Bundle (std::string const & n, DataType t, bool i = true) : _name (n), _type (t), _ports_are_inputs (i) {}
+ Bundle (boost::shared_ptr<Bundle>);
+
virtual ~Bundle() {}
/** @return Number of channels that this Bundle has */
bool offers_port_alone (std::string) const;
void remove_channel (uint32_t);
void remove_channels ();
+ void add_channels_from_bundle (boost::shared_ptr<ARDOUR::Bundle>);
/** Set the name.
* @param n New name.
void create_bundles_for_inputs_and_outputs ();
void setup_bundles_for_inputs_and_outputs ();
+ std::string bundle_channel_name (uint32_t, uint32_t) const;
};
} // namespace ARDOUR
using namespace ARDOUR;
using namespace PBD;
+Bundle::Bundle (boost::shared_ptr<Bundle> other)
+ : _channel (other->_channel),
+ _name (other->_name),
+ _type (other->_type),
+ _ports_are_inputs (other->_ports_are_inputs)
+{
+
+}
+
uint32_t
Bundle::nchannels () const
{
NameChanged (); /* EMIT SIGNAL */
}
+
+/** Take the channels from another bundle and add them to this bundle,
+ * so that channels from other are added to this (with their ports)
+ * and are named "<other_bundle_name> <other_channel_name>".
+ */
+void
+Bundle::add_channels_from_bundle (boost::shared_ptr<Bundle> other)
+{
+ uint32_t const ch = nchannels ();
+
+ for (uint32_t i = 0; i < other->nchannels(); ++i) {
+
+ std::stringstream s;
+ s << other->name() << " " << other->channel_name(i);
+
+ add_channel (s.str());
+
+ PortList const& pl = other->channel_ports (i);
+ for (uint32_t j = 0; j < pl.size(); ++j) {
+ add_port_to_channel (ch + i, pl[j]);
+ }
+ }
+}
_bundle_for_inputs->set_name (buf);
uint32_t const ni = inputs().num_ports();
for (uint32_t i = 0; i < ni; ++i) {
- snprintf (buf, sizeof(buf), _("in %d"), (i + 1));
- _bundle_for_inputs->add_channel (buf);
+ _bundle_for_inputs->add_channel (bundle_channel_name (i, ni));
_bundle_for_inputs->set_port (i, _session.engine().make_port_name_non_relative (inputs().port(i)->name()));
}
_bundle_for_outputs->set_name (buf);
uint32_t const no = outputs().num_ports();
for (uint32_t i = 0; i < no; ++i) {
- snprintf (buf, sizeof(buf), _("out %d"), (i + 1));
- _bundle_for_outputs->add_channel (buf);
+ _bundle_for_outputs->add_channel (bundle_channel_name (i, no));
_bundle_for_outputs->set_port (i, _session.engine().make_port_name_non_relative (outputs().port(i)->name()));
}
}
}
}
+
+std::string
+IO::bundle_channel_name (uint32_t c, uint32_t n) const
+{
+ char buf[32];
+
+ switch (n) {
+ case 1:
+ return _("mono");
+ case 2:
+ return c == 0 ? _("L") : _("R");
+ default:
+ snprintf (buf, sizeof(buf), _("%d"), (c + 1));
+ return buf;
+ }
+
+ return "";
+}