summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/port_group.cc50
-rw-r--r--libs/ardour/ardour/bundle.h4
-rw-r--r--libs/ardour/ardour/io.h1
-rw-r--r--libs/ardour/bundle.cc32
-rw-r--r--libs/ardour/io.cc24
5 files changed, 86 insertions, 25 deletions
diff --git a/gtk2_ardour/port_group.cc b/gtk2_ardour/port_group.cc
index 2544268586..af2fd24bc5 100644
--- a/gtk2_ardour/port_group.cc
+++ b/gtk2_ardour/port_group.cc
@@ -139,15 +139,40 @@ PortGroupList::gather (ARDOUR::Session& session)
{
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)) {
@@ -167,24 +192,7 @@ PortGroupList::gather (ARDOUR::Session& session)
}
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);
}
}
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h
index f9971ddf15..ac5928fc34 100644
--- a/libs/ardour/ardour/bundle.h
+++ b/libs/ardour/ardour/bundle.h
@@ -24,6 +24,7 @@
#include <vector>
#include <glibmm/thread.h>
#include <sigc++/signal.h>
+#include <boost/shared_ptr.hpp>
#include "ardour/data_type.h"
namespace ARDOUR {
@@ -72,6 +73,8 @@ class Bundle : public sigc::trackable
*/
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 */
@@ -93,6 +96,7 @@ class Bundle : public sigc::trackable
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.
diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h
index 1918a9a41a..2d5b55c502 100644
--- a/libs/ardour/ardour/io.h
+++ b/libs/ardour/ardour/io.h
@@ -380,6 +380,7 @@ class IO : public SessionObject, public AutomatableControls, public Latent
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
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index 53fc2f1930..48c0ead6e6 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -29,6 +29,15 @@
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
{
@@ -211,3 +220,26 @@ Bundle::set_channel_name (uint32_t ch, std::string const & n)
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]);
+ }
+ }
+}
diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc
index b86462472a..a5a330cc36 100644
--- a/libs/ardour/io.cc
+++ b/libs/ardour/io.cc
@@ -2601,8 +2601,7 @@ IO::setup_bundles_for_inputs_and_outputs ()
_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()));
}
@@ -2610,8 +2609,7 @@ IO::setup_bundles_for_inputs_and_outputs ()
_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()));
}
}
@@ -2725,3 +2723,21 @@ IO::flush_outputs (nframes_t nframes, nframes_t offset)
}
}
+
+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 "";
+}