diff options
author | Carl Hetherington <carl@carlh.net> | 2009-01-20 14:46:00 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-01-20 14:46:00 +0000 |
commit | 61db2175eb8b8fffd0c1796ace78ac33c9e1adf0 (patch) | |
tree | 6fdc23e7e0161ce54642b0bd44dc8e0a33f05efe /libs/ardour | |
parent | ef038c1a84ecd541a540d5a5baa677d7663e535c (diff) |
New matrix-based editor for connections and bundles, based on thorwil's design.
Add Bundle Manager dialog.
git-svn-id: svn://localhost/ardour2/branches/3.0@4415 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour')
-rw-r--r-- | libs/ardour/ardour/bundle.h | 39 | ||||
-rw-r--r-- | libs/ardour/bundle.cc | 103 | ||||
-rw-r--r-- | libs/ardour/io.cc | 11 | ||||
-rw-r--r-- | libs/ardour/session.cc | 17 | ||||
-rw-r--r-- | libs/ardour/user_bundle.cc | 10 |
5 files changed, 117 insertions, 63 deletions
diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 1b029dc2b4..8b1af39e75 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -21,17 +21,21 @@ #define __ardour_bundle_h__ #include <string> +#include <vector> +#include <glibmm/thread.h> #include <sigc++/signal.h> #include "ardour/data_type.h" namespace ARDOUR { /** A set of `channels', each of which is associated with 0 or more ports. + * Each channel has a name which can be anything useful. * Intended for grouping things like, for example, a buss' outputs. * `Channel' is a rather overloaded term but I can't think of a better * one right now. */ -class Bundle : public sigc::trackable { +class Bundle : public sigc::trackable +{ public: /// List of ports associated with a channel. We can't use a @@ -39,6 +43,17 @@ class Bundle : public sigc::trackable { /// (ie those without a Port object) typedef std::vector<std::string> PortList; + struct Channel { + Channel (std::string n) : name (n) {} + + bool operator== (Channel const &o) const { + return name == o.name && ports == o.ports; + } + + std::string name; + PortList ports; + }; + /** Construct an audio bundle. * @param i true if ports are inputs, otherwise false. */ @@ -50,6 +65,13 @@ class Bundle : public sigc::trackable { */ Bundle (std::string const & n, bool i = true) : _name (n), _type (DataType::AUDIO), _ports_are_inputs (i) {} + /** Construct a bundle. + * @param n Name. + * @param t Type. + * @param i true if ports are inputs, otherwise false. + */ + Bundle (std::string const & n, DataType t, bool i = true) : _name (n), _type (t), _ports_are_inputs (i) {} + virtual ~Bundle() {} /** @return Number of channels that this Bundle has */ @@ -60,13 +82,16 @@ class Bundle : public sigc::trackable { */ PortList const & channel_ports (uint32_t) const; - void add_channel (); + void add_channel (std::string const &); + std::string channel_name (uint32_t) const; + void set_channel_name (uint32_t, std::string const &); void add_port_to_channel (uint32_t, std::string); void set_port (uint32_t, std::string); void remove_port_from_channel (uint32_t, std::string); - void set_nchannels (uint32_t); bool port_attached_to_channel (uint32_t, std::string); + bool uses_port (std::string) const; void remove_channel (uint32_t); + void remove_channels (); /** Set the name. * @param n New name. @@ -94,7 +119,7 @@ class Bundle : public sigc::trackable { bool operator== (Bundle const &) const; - /** Emitted when the name changes */ + /** Emitted when the bundle name or a channel name has changed */ sigc::signal<void> NameChanged; /** The number of channels has changed */ sigc::signal<void> ConfigurationChanged; @@ -103,10 +128,10 @@ class Bundle : public sigc::trackable { protected: - /// mutex for _ports; + /// mutex for _channel_ports and _channel_names /// XXX: is this necessary? - mutable Glib::Mutex _ports_mutex; - std::vector<PortList> _ports; + mutable Glib::Mutex _channel_mutex; + std::vector<Channel> _channel; private: int set_channels (std::string const &); diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index bdad9d364d..379a3d4c2b 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -32,8 +32,8 @@ using namespace PBD; uint32_t Bundle::nchannels () const { - Glib::Mutex::Lock lm (_ports_mutex); - return _ports.size (); + Glib::Mutex::Lock lm (_channel_mutex); + return _channel.size (); } Bundle::PortList const & @@ -41,8 +41,8 @@ Bundle::channel_ports (uint32_t c) const { assert (c < nchannels()); - Glib::Mutex::Lock lm (_ports_mutex); - return _ports[c]; + Glib::Mutex::Lock lm (_channel_mutex); + return _channel[c].ports; } /** Add an association between one of our channels and a port. @@ -55,8 +55,8 @@ Bundle::add_port_to_channel (uint32_t ch, string portname) assert (ch < nchannels()); { - Glib::Mutex::Lock lm (_ports_mutex); - _ports[ch].push_back (portname); + Glib::Mutex::Lock lm (_channel_mutex); + _channel[ch].ports.push_back (portname); } PortsChanged (ch); /* EMIT SIGNAL */ @@ -74,8 +74,8 @@ Bundle::remove_port_from_channel (uint32_t ch, string portname) bool changed = false; { - Glib::Mutex::Lock lm (_ports_mutex); - PortList& pl = _ports[ch]; + Glib::Mutex::Lock lm (_channel_mutex); + PortList& pl = _channel[ch].ports; PortList::iterator i = find (pl.begin(), pl.end(), portname); if (i != pl.end()) { @@ -95,48 +95,31 @@ Bundle::remove_port_from_channel (uint32_t ch, string portname) bool Bundle::operator== (const Bundle& other) const { - return other._ports == _ports; + return other._channel == _channel; } -/** Set the number of channels. - * @param n New number of channels. - */ - -void -Bundle::set_nchannels (uint32_t n) -{ - { - Glib::Mutex::Lock lm (_ports_mutex); - _ports.clear (); - for (uint32_t i = 0; i < n; ++i) { - _ports.push_back (PortList()); - } - } - - ConfigurationChanged (); /* EMIT SIGNAL */ -} - void Bundle::set_port (uint32_t ch, string portname) { assert (ch < nchannels()); { - Glib::Mutex::Lock lm (_ports_mutex); - _ports[ch].clear (); - _ports[ch].push_back (portname); + Glib::Mutex::Lock lm (_channel_mutex); + _channel[ch].ports.clear (); + _channel[ch].ports.push_back (portname); } PortsChanged (ch); /* EMIT SIGNAL */ } +/** @param n Channel name */ void -Bundle::add_channel () +Bundle::add_channel (std::string const & n) { { - Glib::Mutex::Lock lm (_ports_mutex); - _ports.push_back (PortList ()); + Glib::Mutex::Lock lm (_channel_mutex); + _channel.push_back (Channel (n)); } ConfigurationChanged (); /* EMIT SIGNAL */ @@ -147,8 +130,8 @@ Bundle::port_attached_to_channel (uint32_t ch, std::string portname) { assert (ch < nchannels()); - Glib::Mutex::Lock lm (_ports_mutex); - return (std::find (_ports[ch].begin (), _ports[ch].end (), portname) != _ports[ch].end ()); + Glib::Mutex::Lock lm (_channel_mutex); + return (std::find (_channel[ch].ports.begin (), _channel[ch].ports.end (), portname) != _channel[ch].ports.end ()); } void @@ -156,6 +139,52 @@ Bundle::remove_channel (uint32_t ch) { assert (ch < nchannels ()); - Glib::Mutex::Lock lm (_ports_mutex); - _ports.erase (_ports.begin () + ch); + Glib::Mutex::Lock lm (_channel_mutex); + _channel.erase (_channel.begin () + ch); +} + +void +Bundle::remove_channels () +{ + Glib::Mutex::Lock lm (_channel_mutex); + + _channel.clear (); +} + +bool +Bundle::uses_port (std::string p) const +{ + Glib::Mutex::Lock lm (_channel_mutex); + + for (std::vector<Channel>::const_iterator i = _channel.begin(); i != _channel.end(); ++i) { + for (PortList::const_iterator j = i->ports.begin(); j != i->ports.end(); ++j) { + if (*j == p) { + return true; + } + } + } + + return false; +} + +std::string +Bundle::channel_name (uint32_t ch) const +{ + assert (ch < nchannels()); + + Glib::Mutex::Lock lm (_channel_mutex); + return _channel[ch].name; +} + +void +Bundle::set_channel_name (uint32_t ch, std::string const & n) +{ + assert (ch < nchannels()); + + { + Glib::Mutex::Lock lm (_channel_mutex); + _channel[ch].name = n; + } + + NameChanged (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/io.cc b/libs/ardour/io.cc index ed1064f0e8..2b8f12680f 100644 --- a/libs/ardour/io.cc +++ b/libs/ardour/io.cc @@ -593,7 +593,7 @@ IO::remove_output_port (Port* port, void* src) PortCountChanged (n_outputs()); /* EMIT SIGNAL */ } - if (change == ConnectionsChanged) { + if (change == ConfigurationChanged) { setup_bundles_for_inputs_and_outputs (); } @@ -2592,19 +2592,24 @@ IO::setup_bundles_for_inputs_and_outputs () { char buf[32]; + _bundle_for_inputs->remove_channels (); + _bundle_for_outputs->remove_channels (); + snprintf(buf, sizeof (buf), _("%s in"), _name.c_str()); _bundle_for_inputs->set_name (buf); uint32_t const ni = inputs().num_ports(); - _bundle_for_inputs->set_nchannels (ni); 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->set_port (i, inputs().port(i)->name()); } snprintf(buf, sizeof (buf), _("%s out"), _name.c_str()); _bundle_for_outputs->set_name (buf); uint32_t const no = outputs().num_ports(); - _bundle_for_outputs->set_nchannels (no); 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->set_port (i, outputs().port(i)->name()); } } diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index c020509924..2b4d264bbb 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -598,7 +598,7 @@ Session::when_engine_running () snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1); shared_ptr<Bundle> c (new Bundle (buf, true)); - c->set_nchannels (1); + c->add_channel (_("mono")); c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np)); add_bundle (c); @@ -609,7 +609,7 @@ Session::when_engine_running () snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1); shared_ptr<Bundle> c (new Bundle (buf, false)); - c->set_nchannels (1); + c->add_channel (_("mono")); c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np)); add_bundle (c); @@ -622,8 +622,9 @@ Session::when_engine_running () snprintf (buf, sizeof (buf), _("out %" PRIu32 "+%" PRIu32), np+1, np+2); shared_ptr<Bundle> c (new Bundle (buf, true)); - c->set_nchannels (2); + c->add_channel (_("left")); c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np)); + c->add_channel (_("right")); c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1)); add_bundle (c); @@ -634,8 +635,9 @@ Session::when_engine_running () snprintf (buf, sizeof (buf), _("in %" PRIu32 "+%" PRIu32), np+1, np+2); shared_ptr<Bundle> c (new Bundle (buf, false)); - c->set_nchannels (2); + c->add_channel (_("left")); c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np)); + c->add_channel (_("right")); c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1)); add_bundle (c); @@ -2003,13 +2005,6 @@ Session::add_routes (RouteList& new_routes, bool save) if ((*x)->is_control()) { _control_out = (*x); } - - /* only busses get automatic bundles formed */ - - if (!boost::dynamic_pointer_cast<Track> (*x)) { - add_bundle ((*x)->bundle_for_inputs()); - add_bundle ((*x)->bundle_for_outputs()); - } } if (_control_out && IO::connecting_legal) { diff --git a/libs/ardour/user_bundle.cc b/libs/ardour/user_bundle.cc index d53bf8b155..2dee0af01e 100644 --- a/libs/ardour/user_bundle.cc +++ b/libs/ardour/user_bundle.cc @@ -45,7 +45,7 @@ ARDOUR::UserBundle::set_state (XMLNode const & node) return -1; } - add_channel (); + add_channel ("XXX"); XMLNodeList const ports = (*i)->children (); @@ -83,13 +83,13 @@ ARDOUR::UserBundle::get_state () node->add_property ("name", name ()); { - Glib::Mutex::Lock lm (_ports_mutex); + Glib::Mutex::Lock lm (_channel_mutex); - for (std::vector<PortList>::iterator i = _ports.begin(); i != _ports.end(); ++i) { - + for (std::vector<Channel>::iterator i = _channel.begin(); i != _channel.end(); ++i) { XMLNode* c = new XMLNode ("Channel"); + c->add_property ("name", i->name); - for (PortList::iterator j = i->begin(); j != i->end(); ++j) { + for (PortList::iterator j = i->ports.begin(); j != i->ports.end(); ++j) { XMLNode* p = new XMLNode ("Port"); p->add_property ("name", *j); c->add_child_nocopy (*p); |