Basic tweaks to make the bundles and the port matrix accept that MIDI tracks may have audio IO, and vice versa. Allows connection of instrument tracks using the global port matrix.

git-svn-id: svn://localhost/ardour2/branches/3.0@7335 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Carl Hetherington 2010-06-30 02:59:13 +00:00
parent 8efaca01ef
commit 5f67a72c34
19 changed files with 217 additions and 238 deletions

View File

@ -37,7 +37,7 @@ using namespace std;
using namespace ARDOUR;
BundleEditorMatrix::BundleEditorMatrix (Gtk::Window* parent, Session* session, boost::shared_ptr<Bundle> bundle)
: PortMatrix (parent, session, bundle->type())
: PortMatrix (parent, session, DataType::NIL)
, _bundle (bundle)
{
_port_group = boost::shared_ptr<PortGroup> (new PortGroup (""));
@ -60,7 +60,7 @@ BundleEditorMatrix::setup_ports (int dim)
otherwise in some cases the basic system IO ports may be hidden, making
the bundle editor useless */
_ports[OTHER].gather (_session, _bundle->ports_are_inputs(), true);
_ports[OTHER].gather (_session, DataType::NIL, _bundle->ports_are_inputs(), true);
_ports[OTHER].remove_bundle (_bundle);
_ports[OTHER].resume_signals ();
}
@ -118,7 +118,8 @@ BundleEditorMatrix::add_channel (boost::shared_ptr<Bundle> b)
return;
}
_bundle->add_channel (d.get_name());
/* XXX: allow user to specify type */
_bundle->add_channel (d.get_name(), DataType::AUDIO);
setup_ports (OURS);
} else {
@ -212,28 +213,6 @@ BundleEditor::BundleEditor (Session* session, boost::shared_ptr<UserBundle> bund
_input_or_output.signal_changed().connect (sigc::mem_fun (*this, &BundleEditor::input_or_output_changed));
/* Type (audio or MIDI) */
a = new Gtk::Alignment (1, 0.5, 0, 1);
a->add (*Gtk::manage (new Gtk::Label (_("Type:"))));
t->attach (*Gtk::manage (a), 0, 1, 2, 3, Gtk::FILL, Gtk::FILL);
a = new Gtk::Alignment (0, 0.5, 0, 1);
a->add (_type);
t->attach (*Gtk::manage (a), 1, 2, 2, 3);
_type.append_text (_("Audio"));
_type.append_text (_("MIDI"));
switch (bundle->type ()) {
case DataType::AUDIO:
_type.set_active_text (_("Audio"));
break;
case DataType::MIDI:
_type.set_active_text (_("MIDI"));
break;
}
_type.signal_changed().connect (sigc::mem_fun (*this, &BundleEditor::type_changed));
get_vbox()->pack_start (*Gtk::manage (t), false, false);
get_vbox()->pack_start (_matrix);
get_vbox()->set_spacing (4);
@ -270,18 +249,6 @@ BundleEditor::input_or_output_changed ()
_matrix.setup_all_ports ();
}
void
BundleEditor::type_changed ()
{
_bundle->remove_ports_from_channels ();
DataType const t = _type.get_active_text() == _("Audio") ?
DataType::AUDIO : DataType::MIDI;
_bundle->set_type (t);
_matrix.set_type (t);
}
void
BundleEditor::on_map ()
{
@ -360,7 +327,8 @@ BundleManager::new_clicked ()
boost::shared_ptr<UserBundle> b (new UserBundle (_("Bundle")));
/* Start off with a single channel */
b->add_channel ("1");
/* XXX: allow user to specify type */
b->add_channel ("1", DataType::AUDIO);
_session->add_bundle (b);
add_bundle (b);

View File

@ -72,14 +72,12 @@ class BundleEditor : public ArdourDialog
private:
void name_changed ();
void input_or_output_changed ();
void type_changed ();
void on_show ();
BundleEditorMatrix _matrix;
boost::shared_ptr<ARDOUR::UserBundle> _bundle;
Gtk::Entry _name;
Gtk::ComboBoxText _input_or_output;
Gtk::ComboBoxText _type;
};
class BundleManager : public ArdourDialog

View File

@ -42,7 +42,7 @@ void
GlobalPortMatrix::setup_ports (int dim)
{
_ports[dim].suspend_signals ();
_ports[dim].gather (_session, dim == IN, false);
_ports[dim].gather (_session, type(), dim == IN, false);
_ports[dim].resume_signals ();
}

View File

@ -76,7 +76,7 @@ IOSelector::setup_ports (int dim)
if (dim == _other) {
_ports[_other].gather (_session, _find_inputs_for_io_outputs, false);
_ports[_other].gather (_session, type(), _find_inputs_for_io_outputs, false);
} else {

View File

@ -868,10 +868,7 @@ MixerStrip::maybe_add_bundle_to_input_menu (boost::shared_ptr<Bundle> b, ARDOUR:
{
using namespace Menu_Helpers;
if (b->ports_are_outputs() == false ||
route()->input()->default_type() != b->type() ||
b->nchannels() != _route->n_inputs().get (b->type ())) {
if (b->ports_are_outputs() == false || b->nchannels() != _route->n_inputs()) {
return;
}
@ -905,10 +902,7 @@ MixerStrip::maybe_add_bundle_to_output_menu (boost::shared_ptr<Bundle> b, ARDOUR
{
using namespace Menu_Helpers;
if (b->ports_are_inputs() == false ||
route()->output()->default_type() != b->type() ||
b->nchannels() != _route->n_outputs().get (b->type ())) {
if (b->ports_are_inputs() == false || b->nchannels() != _route->n_outputs()) {
return;
}

View File

@ -181,10 +181,10 @@ PortGroup::only_bundle ()
}
uint32_t
ChanCount
PortGroup::total_channels () const
{
uint32_t n = 0;
ChanCount n;
for (BundleList::const_iterator i = _bundles.begin(); i != _bundles.end(); ++i) {
n += (*i)->bundle->nchannels ();
}
@ -225,14 +225,14 @@ PortGroup::remove_duplicates ()
/* this bundle is larger */
uint32_t k = 0;
while (k < (*i)->bundle->nchannels()) {
while (k < (*i)->bundle->nchannels().n_total()) {
/* see if this channel on *i has an equivalent on *j */
uint32_t l = 0;
while (l < (*j)->bundle->nchannels() && (*i)->bundle->channel_ports (k) != (*j)->bundle->channel_ports (l)) {
while (l < (*j)->bundle->nchannels().n_total() && (*i)->bundle->channel_ports (k) != (*j)->bundle->channel_ports (l)) {
++l;
}
if (l == (*j)->bundle->nchannels()) {
if (l == (*j)->bundle->nchannels().n_total()) {
/* it does not */
break;
}
@ -240,7 +240,7 @@ PortGroup::remove_duplicates ()
++k;
}
if (k == (*i)->bundle->nchannels ()) {
if (k == (*i)->bundle->nchannels().n_total()) {
/* all channels on *i are represented by the larger bundle *j, so remove *i */
remove = true;
break;
@ -260,7 +260,7 @@ PortGroup::remove_duplicates ()
/** PortGroupList constructor.
*/
PortGroupList::PortGroupList ()
: _type (DataType::AUDIO), _signals_suspended (false), _pending_change (false), _pending_bundle_change ((Bundle::Change) 0)
: _signals_suspended (false), _pending_change (false), _pending_bundle_change ((Bundle::Change) 0)
{
}
@ -270,13 +270,6 @@ PortGroupList::~PortGroupList()
/* XXX need to clean up bundles, but ownership shared with PortGroups */
}
void
PortGroupList::set_type (DataType t)
{
_type = t;
clear ();
}
void
PortGroupList::maybe_add_processor_to_list (
boost::weak_ptr<Processor> wp, list<boost::shared_ptr<Bundle> >* route_bundles, bool inputs, set<boost::shared_ptr<IO> >& used_io
@ -304,7 +297,7 @@ PortGroupList::maybe_add_processor_to_list (
/** Gather bundles from around the system and put them in this PortGroupList */
void
PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
PortGroupList::gather (ARDOUR::Session* session, ARDOUR::DataType type, bool inputs, bool allow_dups)
{
clear ();
@ -342,33 +335,18 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
/* Work out which group to put these bundles in */
boost::shared_ptr<PortGroup> g;
if (_type == DataType::AUDIO) {
if (boost::dynamic_pointer_cast<AudioTrack> (*i)) {
g = track;
} else if (!boost::dynamic_pointer_cast<MidiTrack>(*i)) {
g = bus;
}
} else if (_type == DataType::MIDI) {
if (boost::dynamic_pointer_cast<MidiTrack> (*i)) {
g = track;
}
/* No MIDI busses yet */
if (boost::dynamic_pointer_cast<Track> (*i)) {
g = track;
} else {
g = bus;
}
if (g) {
TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (*i);
for (list<boost::shared_ptr<Bundle> >::iterator i = route_bundles.begin(); i != route_bundles.end(); ++i) {
if (tv) {
g->add_bundle (*i, io, tv->color ());
} else {
g->add_bundle (*i, io);
}
TimeAxisView* tv = PublicEditor::instance().axis_view_from_route (*i);
for (list<boost::shared_ptr<Bundle> >::iterator i = route_bundles.begin(); i != route_bundles.end(); ++i) {
if (tv) {
g->add_bundle (*i, io, tv->color ());
} else {
g->add_bundle (*i, io);
}
}
}
@ -380,20 +358,20 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
boost::shared_ptr<BundleList> b = session->bundles ();
for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) && (*i)->ports_are_inputs() == inputs) {
system->add_bundle (*i, allow_dups);
}
}
for (BundleList::iterator i = b->begin(); i != b->end(); ++i) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs && (*i)->type() == _type) {
if (boost::dynamic_pointer_cast<UserBundle> (*i) == 0 && (*i)->ports_are_inputs() == inputs) {
system->add_bundle (*i, allow_dups);
}
}
/* Ardour stuff */
if (!inputs && _type == DataType::AUDIO) {
if (!inputs && type == DataType::AUDIO) {
ardour->add_bundle (session->the_auditioner()->output()->bundle());
ardour->add_bundle (session->click_io()->bundle());
}
@ -403,7 +381,7 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
std::vector<std::string> extra_system;
std::vector<std::string> extra_other;
const char **ports = session->engine().get_ports ("", _type.to_jack_type(), inputs ?
const char **ports = session->engine().get_ports ("", type.to_jack_type(), inputs ?
JackPortIsInput : JackPortIsOutput);
if (ports) {
@ -449,12 +427,12 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
}
if (!extra_system.empty()) {
boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_system, inputs);
boost::shared_ptr<Bundle> b = make_bundle_from_ports (extra_system, type, inputs);
system->add_bundle (b);
}
if (!extra_other.empty()) {
other->add_bundle (make_bundle_from_ports (extra_other, inputs));
other->add_bundle (make_bundle_from_ports (extra_other, type, inputs));
}
if (!allow_dups) {
@ -471,9 +449,9 @@ PortGroupList::gather (ARDOUR::Session* session, bool inputs, bool allow_dups)
}
boost::shared_ptr<Bundle>
PortGroupList::make_bundle_from_ports (std::vector<std::string> const & p, bool inputs) const
PortGroupList::make_bundle_from_ports (std::vector<std::string> const & p, ARDOUR::DataType type, bool inputs) const
{
boost::shared_ptr<Bundle> b (new Bundle ("", _type, inputs));
boost::shared_ptr<Bundle> b (new Bundle ("", inputs));
std::string const pre = common_prefix (p);
if (!pre.empty()) {
@ -481,7 +459,7 @@ PortGroupList::make_bundle_from_ports (std::vector<std::string> const & p, bool
}
for (uint32_t j = 0; j < p.size(); ++j) {
b->add_channel (p[j].substr (pre.length()));
b->add_channel (p[j].substr (pre.length()), type);
b->set_port (j, p[j]);
}
@ -560,10 +538,10 @@ PortGroupList::bundles () const
return _bundles;
}
uint32_t
ChanCount
PortGroupList::total_channels () const
{
uint32_t n = 0;
ChanCount n;
for (PortGroupList::List::const_iterator i = begin(); i != end(); ++i) {
n += (*i)->total_channels ();
@ -661,7 +639,7 @@ bool
PortGroupList::empty () const
{
List::const_iterator i = _groups.begin ();
while (i != _groups.end() && (*i)->total_channels() == 0) {
while (i != _groups.end() && (*i)->total_channels() == ChanCount::ZERO) {
++i;
}

View File

@ -58,7 +58,7 @@ public:
void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
boost::shared_ptr<ARDOUR::Bundle> only_bundle ();
void clear ();
uint32_t total_channels () const;
ARDOUR::ChanCount total_channels () const;
boost::shared_ptr<ARDOUR::IO> io_from_bundle (boost::shared_ptr<ARDOUR::Bundle>) const;
void remove_duplicates ();
@ -108,12 +108,11 @@ class PortGroupList : public sigc::trackable
void add_group (boost::shared_ptr<PortGroup>);
void add_group_if_not_empty (boost::shared_ptr<PortGroup>);
void set_type (ARDOUR::DataType);
void gather (ARDOUR::Session *, bool, bool);
void gather (ARDOUR::Session *, ARDOUR::DataType, bool, bool);
PortGroup::BundleList const & bundles () const;
void clear ();
void remove_bundle (boost::shared_ptr<ARDOUR::Bundle>);
uint32_t total_channels () const;
ARDOUR::ChanCount total_channels () const;
uint32_t size () const {
return _groups.size();
}
@ -144,12 +143,11 @@ class PortGroupList : public sigc::trackable
std::string common_prefix_before (std::vector<std::string> const &, std::string const &) const;
void emit_changed ();
void emit_bundle_changed (ARDOUR::Bundle::Change);
boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, bool) const;
boost::shared_ptr<ARDOUR::Bundle> make_bundle_from_ports (std::vector<std::string> const &, ARDOUR::DataType, bool) const;
void maybe_add_processor_to_list (
boost::weak_ptr<ARDOUR::Processor>, std::list<boost::shared_ptr<ARDOUR::Bundle> > *, bool, std::set<boost::shared_ptr<ARDOUR::IO> > &
);
ARDOUR::DataType _type;
mutable PortGroup::BundleList _bundles;
List _groups;
PBD::ScopedConnectionList _bundle_changed_connections;

View File

@ -77,10 +77,6 @@ PortMatrix::PortMatrix (Window* parent, Session* session, DataType type)
_hnotebook.property_tab_border() = 4;
_hnotebook.set_name (X_("PortMatrixLabel"));
for (int i = 0; i < 2; ++i) {
_ports[i].set_type (type);
}
_vlabel.set_use_markup ();
_vlabel.set_alignment (1, 1);
_vlabel.set_padding (4, 16);
@ -217,8 +213,6 @@ void
PortMatrix::set_type (DataType t)
{
_type = t;
_ports[0].set_type (_type);
_ports[1].set_type (_type);
setup_all_ports ();
}
@ -261,9 +255,13 @@ PortMatrix::disassociate_all ()
PortGroup::BundleList b = _ports[1].bundles ();
for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) {
for (uint32_t l = 0; l < (*k)->bundle->nchannels(); ++l) {
for (uint32_t l = 0; l < (*k)->bundle->nchannels().n_total(); ++l) {
if ((*i)->bundle->channel_type(j) != _type || (*k)->bundle->channel_type(l) != _type) {
continue;
}
BundleChannel c[2] = {
BundleChannel ((*i)->bundle, j),
@ -287,8 +285,8 @@ void
PortMatrix::select_arrangement ()
{
uint32_t const N[2] = {
_ports[0].total_channels (),
_ports[1].total_channels ()
_ports[0].total_channels().get(_type),
_ports[1].total_channels().get(_type)
};
/* The list with the most channels goes on left or right, so that the most channel
@ -426,13 +424,15 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_all_channels), w))
);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
add_remove_option (sub, w, i);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
if (bc[dim].bundle->channel_type(i) == _type) {
add_remove_option (sub, w, i);
}
}
}
}
if (_show_only_bundles || bc[dim].bundle->nchannels() <= 1) {
if (_show_only_bundles || bc[dim].bundle->nchannels().get(_type) <= 1) {
snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
sub.push_back (
MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim))
@ -448,8 +448,10 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_bundle), w, dim))
);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels(); ++i) {
add_disassociate_option (sub, w, dim, i);
for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
if (bc[dim].bundle->channel_type(i) == _type) {
add_disassociate_option (sub, w, dim, i);
}
}
}
}
@ -505,8 +507,10 @@ PortMatrix::disassociate_all_on_bundle (boost::weak_ptr<Bundle> bundle, int dim)
return;
}
for (uint32_t i = 0; i < sb->nchannels(); ++i) {
disassociate_all_on_channel (bundle, i, dim);
for (uint32_t i = 0; i < sb->nchannels().n_total(); ++i) {
if (sb->channel_type(i) == _type) {
disassociate_all_on_channel (bundle, i, dim);
}
}
}
@ -521,7 +525,11 @@ PortMatrix::disassociate_all_on_channel (boost::weak_ptr<Bundle> bundle, uint32_
PortGroup::BundleList a = _ports[1-dim].bundles ();
for (PortGroup::BundleList::iterator i = a.begin(); i != a.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
if ((*i)->bundle->channel_type(j) != _type) {
continue;
}
BundleChannel c[2];
c[dim] = BundleChannel (sb, channel);
@ -662,8 +670,10 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
return;
}
for (uint32_t i = 0; i < b->nchannels(); ++i) {
remove_channel (ARDOUR::BundleChannel (b, i));
for (uint32_t i = 0; i < b->nchannels().n_total(); ++i) {
if (b->channel_type(i) == _type) {
remove_channel (ARDOUR::BundleChannel (b, i));
}
}
}

View File

@ -467,7 +467,12 @@ PortMatrixBody::highlight_associated_channels (int dim, ARDOUR::BundleChannel h)
PortGroup::BundleList const b = _matrix->visible_ports(1 - dim)->bundles ();
for (PortGroup::BundleList::const_iterator i = b.begin(); i != b.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
if ((*i)->bundle->channel_type(j) != _matrix->type()) {
continue;
}
bc[1 - dim] = ARDOUR::BundleChannel ((*i)->bundle, j);
if (_matrix->get_state (bc) == PortMatrixNode::ASSOCIATED) {
if (dim == _matrix->column_index()) {

View File

@ -62,7 +62,11 @@ PortMatrixColumnLabels::compute_dimensions ()
_longest_bundle_name = ext.width;
}
for (uint32_t k = 0; k < (*j)->bundle->nchannels (); ++k) {
for (uint32_t k = 0; k < (*j)->bundle->nchannels().n_total(); ++k) {
if ((*j)->bundle->channel_type(k) != _matrix->type()) {
continue;
}
cairo_text_extents (
cr,
@ -135,7 +139,7 @@ PortMatrixColumnLabels::render (cairo_t* cr)
if (_matrix->show_only_bundles()) {
x += grid_spacing();
} else {
x += (*i)->bundle->nchannels () * grid_spacing();
x += (*i)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
}
++N;
@ -149,7 +153,12 @@ PortMatrixColumnLabels::render (cairo_t* cr)
for (PortGroup::BundleList::const_iterator i = bundles.begin (); i != bundles.end(); ++i) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
if ((*i)->bundle->channel_type(j) != _matrix->type()) {
continue;
}
Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N);
render_channel_name (cr, background_colour (), c, x, 0, ARDOUR::BundleChannel ((*i)->bundle, j));
x += grid_spacing();
@ -254,7 +263,7 @@ PortMatrixColumnLabels::render_bundle_name (
if (_matrix->show_only_bundles()) {
w = grid_spacing ();
} else {
w = b->nchannels() * grid_spacing();
w = b->nchannels().get(_matrix->type()) * grid_spacing();
}
double x_ = xoff;
@ -352,7 +361,7 @@ PortMatrixColumnLabels::render_channel_name (
);
}
if (bc.bundle->nchannels() > 1) {
if (bc.bundle->nchannels().get(_matrix->type()) > 1) {
/* only plot the name if the bundle has more than one channel;
the name of a single channel is assumed to be redundant */
@ -478,7 +487,12 @@ PortMatrixColumnLabels::motion (double x, double y)
list<PortMatrixNode> n;
for (uint32_t i = 0; i < w.bundle->nchannels(); ++i) {
for (uint32_t i = 0; i < w.bundle->nchannels().n_total(); ++i) {
if (w.bundle->channel_type(i) != _matrix->type()) {
continue;
}
ARDOUR::BundleChannel const bc (w.bundle, i);
n.push_back (PortMatrixNode (ARDOUR::BundleChannel (), bc));
}

View File

@ -132,7 +132,7 @@ PortMatrixComponent::group_size (boost::shared_ptr<const PortGroup> g) const
s = bundles.size();
} else {
for (PortGroup::BundleList::const_iterator i = bundles.begin(); i != bundles.end(); ++i) {
s += (*i)->bundle->nchannels();
s += (*i)->bundle->nchannels().get (_matrix->type());
}
}
@ -169,7 +169,7 @@ PortMatrixComponent::channel_to_position (ARDOUR::BundleChannel bc, boost::share
if (_matrix->show_only_bundles()) {
p += 1;
} else {
p += (*i)->bundle->nchannels ();
p += (*i)->bundle->nchannels().get (_matrix->type());
}
}
@ -195,7 +195,7 @@ PortMatrixComponent::position_to_channel (double p, double, boost::shared_ptr<co
} else {
uint32_t const s = (*j)->bundle->nchannels ();
uint32_t const s = (*j)->bundle->nchannels().get (_matrix->type());
if (p < s) {
return ARDOUR::BundleChannel ((*j)->bundle, p);
} else {

View File

@ -81,7 +81,7 @@ PortMatrixGrid::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().get(_matrix->type()); ++j) {
x += grid_spacing ();
cairo_move_to (cr, x, 0);
cairo_line_to (cr, x, _height);
@ -111,7 +111,7 @@ PortMatrixGrid::render (cairo_t* cr)
if (!_matrix->show_only_bundles()) {
cairo_set_line_width (cr, thin_grid_line_width());
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().get(_matrix->type()); ++j) {
y += grid_spacing ();
cairo_move_to (cr, 0, y);
cairo_line_to (cr, _width, y);
@ -169,10 +169,14 @@ PortMatrixGrid::render (cairo_t* cr)
for (PortGroup::BundleList::const_iterator j = row_bundles.begin(); j != row_bundles.end(); ++j) {
x = bx;
for (uint32_t k = 0; k < (*i)->bundle->nchannels (); ++k) {
for (uint32_t k = 0; k < (*i)->bundle->nchannels().n_total(); ++k) {
y = by;
for (uint32_t l = 0; l < (*j)->bundle->nchannels (); ++l) {
for (uint32_t l = 0; l < (*j)->bundle->nchannels().n_total(); ++l) {
if ((*i)->bundle->channel_type(k) != _matrix->type() || (*j)->bundle->channel_type(l) != _matrix->type()) {
continue;
}
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel ((*i)->bundle, k);
@ -198,10 +202,10 @@ PortMatrixGrid::render (cairo_t* cr)
x += grid_spacing();
}
by += (*j)->bundle->nchannels () * grid_spacing();
by += (*j)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
}
bx += (*i)->bundle->nchannels () * grid_spacing();
bx += (*i)->bundle->nchannels().get(_matrix->type()) * grid_spacing();
}
}
}
@ -277,9 +281,13 @@ PortMatrixGrid::get_association (PortMatrixNode node) const
bool have_diagonal_association = false;
bool have_diagonal_not_association = false;
for (uint32_t i = 0; i < node.row.bundle->nchannels (); ++i) {
for (uint32_t i = 0; i < node.row.bundle->nchannels().n_total(); ++i) {
for (uint32_t j = 0; j < node.column.bundle->nchannels (); ++j) {
for (uint32_t j = 0; j < node.column.bundle->nchannels().n_total(); ++j) {
if (node.row.bundle->channel_type(i) != _matrix->type() || node.column.bundle->channel_type(j) != _matrix->type()) {
continue;
}
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.row.bundle, i);
@ -334,9 +342,13 @@ PortMatrixGrid::set_association (PortMatrixNode node, bool s)
{
if (_matrix->show_only_bundles()) {
for (uint32_t i = 0; i < node.column.bundle->nchannels(); ++i) {
for (uint32_t j = 0; j < node.row.bundle->nchannels(); ++j) {
for (uint32_t i = 0; i < node.column.bundle->nchannels().n_total(); ++i) {
for (uint32_t j = 0; j < node.row.bundle->nchannels().n_total(); ++j) {
if (node.column.bundle->channel_type(i) != _matrix->type() || node.row.bundle->channel_type(j) != _matrix->type()) {
continue;
}
ARDOUR::BundleChannel c[2];
c[_matrix->column_index()] = ARDOUR::BundleChannel (node.column.bundle, i);
c[_matrix->row_index()] = ARDOUR::BundleChannel (node.row.bundle, j);

View File

@ -54,7 +54,12 @@ PortMatrixRowLabels::compute_dimensions ()
PortGroup::BundleList const r = (*i)->bundles ();
for (PortGroup::BundleList::const_iterator j = r.begin(); j != r.end(); ++j) {
for (uint32_t k = 0; k < (*j)->bundle->nchannels(); ++k) {
for (uint32_t k = 0; k < (*j)->bundle->nchannels().n_total(); ++k) {
if ((*j)->bundle->channel_type(k) != _matrix->type()) {
continue;
}
cairo_text_extents_t ext;
cairo_text_extents (cr, (*j)->bundle->channel_name(k).c_str(), &ext);
if (ext.width > _longest_port_name) {
@ -110,7 +115,12 @@ PortMatrixRowLabels::render (cairo_t* cr)
render_bundle_name (cr, background_colour (), (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (N), 0, y, (*i)->bundle);
if (!_matrix->show_only_bundles()) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels(); ++j) {
for (uint32_t j = 0; j < (*i)->bundle->nchannels().n_total(); ++j) {
if ((*i)->bundle->channel_type(j) != _matrix->type()) {
continue;
}
Gdk::Color c = (*i)->has_colour ? (*i)->colour : get_a_bundle_colour (M);
render_channel_name (cr, background_colour (), c, 0, y, ARDOUR::BundleChannel ((*i)->bundle, j));
y += grid_spacing();
@ -205,7 +215,7 @@ PortMatrixRowLabels::render_bundle_name (
{
double const x = bundle_name_x ();
int const n = _matrix->show_only_bundles() ? 1 : b->nchannels();
int const n = _matrix->show_only_bundles() ? 1 : b->nchannels().get(_matrix->type());
set_source_rgb (cr, bg_colour);
cairo_rectangle (cr, xoff + x, yoff, _longest_bundle_name + name_pad() * 2, grid_spacing() * n);
cairo_fill_preserve (cr);
@ -238,7 +248,7 @@ PortMatrixRowLabels::render_channel_name (
cairo_text_extents (cr, bc.bundle->channel_name(bc.channel).c_str(), &ext);
double const off = (grid_spacing() - ext.height) / 2;
if (bc.bundle->nchannels() > 1) {
if (bc.bundle->nchannels().get(_matrix->type()) > 1) {
/* only plot the name if the bundle has more than one channel;
the name of a single channel is assumed to be redundant */
@ -323,7 +333,12 @@ PortMatrixRowLabels::motion (double x, double y)
list<PortMatrixNode> n;
for (uint32_t i = 0; i < w.bundle->nchannels(); ++i) {
for (uint32_t i = 0; i < w.bundle->nchannels().n_total(); ++i) {
if (w.bundle->channel_type(i) != _matrix->type()) {
continue;
}
ARDOUR::BundleChannel const bc (w.bundle, i);
n.push_back (PortMatrixNode (bc, ARDOUR::BundleChannel ()));
}

View File

@ -32,7 +32,7 @@ public:
_port_group->add_bundle (_session->click_io()->bundle());
_port_group->add_bundle (_session->the_auditioner()->output()->bundle());
} else {
_ports[OTHER].gather (_session, true, false);
_ports[OTHER].gather (_session, DataType::AUDIO, true, false);
}
}

View File

@ -28,13 +28,14 @@
#include "pbd/signals.h"
#include "ardour/data_type.h"
#include "ardour/chan_count.h"
namespace ARDOUR {
class AudioEngine;
/** A set of `channels', each of which is associated with 0 or more ports.
* Each channel has a name which can be anything useful.
* Each channel has a name which can be anything useful, and a data type.
* 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.
@ -49,33 +50,34 @@ class Bundle : public PBD::ScopedConnectionList
typedef std::vector<std::string> PortList;
struct Channel {
Channel (std::string n) : name (n) {}
Channel (std::string n, DataType t) : name (n), type (t) {}
bool operator== (Channel const &o) const {
return name == o.name && ports == o.ports;
return name == o.name && type == o.type && ports == o.ports;
}
std::string name;
DataType type;
PortList ports;
};
Bundle (bool i = true);
Bundle (std::string const &, bool i = true);
Bundle (std::string const &, DataType, bool i = true);
Bundle (boost::shared_ptr<Bundle>);
virtual ~Bundle() {}
/** @return Number of channels that this Bundle has */
uint32_t nchannels () const;
ChanCount nchannels () const;
/** @param Channel index.
* @return Ports associated with this channel.
*/
PortList const & channel_ports (uint32_t) const;
void add_channel (std::string const &);
void add_channel (std::string const &, DataType);
std::string channel_name (uint32_t) const;
DataType channel_type (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);
@ -98,11 +100,6 @@ class Bundle : public PBD::ScopedConnectionList
/** @return Bundle name */
std::string name () const { return _name; }
void set_type (DataType);
/** @return Type of the ports in this Bundle. */
DataType type () const { return _type; }
void set_ports_are_inputs ();
void set_ports_are_outputs ();
bool ports_are_inputs () const { return _ports_are_inputs; }
@ -135,7 +132,6 @@ class Bundle : public PBD::ScopedConnectionList
void emit_changed (Change);
std::string _name;
DataType _type;
bool _ports_are_inputs;
bool _signals_suspended;

View File

@ -36,8 +36,7 @@ using namespace PBD;
* @param i true if ports are inputs, otherwise false.
*/
Bundle::Bundle (bool i)
: _type (DataType::AUDIO),
_ports_are_inputs (i),
: _ports_are_inputs (i),
_signals_suspended (false),
_pending_change (Change (0))
{
@ -51,7 +50,6 @@ Bundle::Bundle (bool i)
*/
Bundle::Bundle (std::string const & n, bool i)
: _name (n),
_type (DataType::AUDIO),
_ports_are_inputs (i),
_signals_suspended (false),
_pending_change (Change (0))
@ -59,27 +57,9 @@ Bundle::Bundle (std::string const & n, bool i)
}
/** Construct a bundle.
* @param n Name.
* @param t Type.
* @param i true if ports are inputs, otherwise false.
*/
Bundle::Bundle (std::string const & n, DataType t, bool i)
: _name (n),
_type (t),
_ports_are_inputs (i),
_signals_suspended (false),
_pending_change (Change (0))
{
}
Bundle::Bundle (boost::shared_ptr<Bundle> other)
: _channel (other->_channel),
_name (other->_name),
_type (other->_type),
_ports_are_inputs (other->_ports_are_inputs),
_signals_suspended (other->_signals_suspended),
_pending_change (other->_pending_change)
@ -87,17 +67,23 @@ Bundle::Bundle (boost::shared_ptr<Bundle> other)
}
uint32_t
ChanCount
Bundle::nchannels () const
{
Glib::Mutex::Lock lm (_channel_mutex);
return _channel.size ();
ChanCount c;
for (vector<Channel>::const_iterator i = _channel.begin(); i != _channel.end(); ++i) {
c.set (i->type, c.get (i->type) + 1);
}
return c;
}
Bundle::PortList const &
Bundle::channel_ports (uint32_t c) const
{
assert (c < nchannels());
assert (c < nchannels().n_total());
Glib::Mutex::Lock lm (_channel_mutex);
return _channel[c].ports;
@ -110,7 +96,7 @@ Bundle::channel_ports (uint32_t c) const
void
Bundle::add_port_to_channel (uint32_t ch, string portname)
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
assert (portname.find_first_of (':') != string::npos);
{
@ -128,7 +114,7 @@ Bundle::add_port_to_channel (uint32_t ch, string portname)
void
Bundle::remove_port_from_channel (uint32_t ch, string portname)
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
bool changed = false;
@ -155,7 +141,7 @@ Bundle::remove_port_from_channel (uint32_t ch, string portname)
void
Bundle::set_port (uint32_t ch, string portname)
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
assert (portname.find_first_of (':') != string::npos);
{
@ -169,11 +155,11 @@ Bundle::set_port (uint32_t ch, string portname)
/** @param n Channel name */
void
Bundle::add_channel (std::string const & n)
Bundle::add_channel (std::string const & n, DataType t)
{
{
Glib::Mutex::Lock lm (_channel_mutex);
_channel.push_back (Channel (n));
_channel.push_back (Channel (n, t));
}
emit_changed (ConfigurationChanged);
@ -182,7 +168,7 @@ Bundle::add_channel (std::string const & n)
bool
Bundle::port_attached_to_channel (uint32_t ch, std::string portname)
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
Glib::Mutex::Lock lm (_channel_mutex);
return (std::find (_channel[ch].ports.begin (), _channel[ch].ports.end (), portname) != _channel[ch].ports.end ());
@ -194,7 +180,7 @@ Bundle::port_attached_to_channel (uint32_t ch, std::string portname)
void
Bundle::remove_channel (uint32_t ch)
{
assert (ch < nchannels ());
assert (ch < nchannels().n_total());
Glib::Mutex::Lock lm (_channel_mutex);
_channel.erase (_channel.begin () + ch);
@ -252,7 +238,7 @@ Bundle::offers_port_alone (std::string p) const
std::string
Bundle::channel_name (uint32_t ch) const
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
Glib::Mutex::Lock lm (_channel_mutex);
return _channel[ch].name;
@ -265,7 +251,7 @@ Bundle::channel_name (uint32_t ch) const
void
Bundle::set_channel_name (uint32_t ch, std::string const & n)
{
assert (ch < nchannels());
assert (ch < nchannels().n_total());
{
Glib::Mutex::Lock lm (_channel_mutex);
@ -282,14 +268,14 @@ Bundle::set_channel_name (uint32_t ch, std::string const & n)
void
Bundle::add_channels_from_bundle (boost::shared_ptr<Bundle> other)
{
uint32_t const ch = nchannels ();
uint32_t const ch = nchannels().n_total();
for (uint32_t i = 0; i < other->nchannels(); ++i) {
for (uint32_t i = 0; i < other->nchannels().n_total(); ++i) {
std::stringstream s;
s << other->name() << " " << other->channel_name(i);
add_channel (s.str());
add_channel (s.str(), other->channel_type(i));
PortList const& pl = other->channel_ports (i);
for (uint32_t j = 0; j < pl.size(); ++j) {
@ -306,8 +292,8 @@ Bundle::add_channels_from_bundle (boost::shared_ptr<Bundle> other)
void
Bundle::connect (boost::shared_ptr<Bundle> other, AudioEngine & engine)
{
uint32_t const N = nchannels ();
assert (N == other->nchannels ());
uint32_t const N = nchannels().n_total();
assert (N == other->nchannels().n_total());
for (uint32_t i = 0; i < N; ++i) {
Bundle::PortList const & our_ports = channel_ports (i);
@ -324,8 +310,8 @@ Bundle::connect (boost::shared_ptr<Bundle> other, AudioEngine & engine)
void
Bundle::disconnect (boost::shared_ptr<Bundle> other, AudioEngine & engine)
{
uint32_t const N = nchannels ();
assert (N == other->nchannels ());
uint32_t const N = nchannels().n_total();
assert (N == other->nchannels().n_total());
for (uint32_t i = 0; i < N; ++i) {
Bundle::PortList const & our_ports = channel_ports (i);
@ -360,7 +346,7 @@ Bundle::remove_ports_from_channels ()
void
Bundle::remove_ports_from_channel (uint32_t ch)
{
assert (ch < nchannels ());
assert (ch < nchannels().n_total());
{
Glib::Mutex::Lock lm (_channel_mutex);
@ -400,14 +386,11 @@ Bundle::emit_changed (Change c)
bool
Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
{
if (_ports_are_inputs == other->_ports_are_inputs ||
_type != other->_type ||
nchannels() != other->nchannels ()) {
if (_ports_are_inputs == other->_ports_are_inputs || nchannels() != other->nchannels()) {
return false;
}
for (uint32_t i = 0; i < nchannels(); ++i) {
for (uint32_t i = 0; i < nchannels().n_total(); ++i) {
Bundle::PortList const & A = channel_ports (i);
Bundle::PortList const & B = other->channel_ports (i);
@ -433,16 +416,6 @@ Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
return true;
}
/** Set the type of the ports in this Bundle.
* @param t New type.
*/
void
Bundle::set_type (DataType t)
{
_type = t;
emit_changed (TypeChanged);
}
void
Bundle::set_ports_are_inputs ()
{
@ -473,9 +446,9 @@ Bundle::set_name (string const & n)
bool
Bundle::has_same_ports (boost::shared_ptr<Bundle> b) const
{
uint32_t const N = nchannels ();
uint32_t const N = nchannels().n_total();
if (b->nchannels() != N) {
if (b->nchannels().n_total() != N) {
return false;
}
@ -489,3 +462,12 @@ Bundle::has_same_ports (boost::shared_ptr<Bundle> b) const
return true;
}
DataType
Bundle::channel_type (uint32_t c) const
{
assert (c < nchannels().n_total());
Glib::Mutex::Lock lm (_channel_mutex);
return _channel[c].type;
}

View File

@ -111,6 +111,10 @@ IO::check_bundles_connected ()
check_bundles (_bundles_connected, ports());
}
/** Check the bundles in list to see which are connected to a given PortSet,
* and update list with those that are connected such that every port on every
* bundle channel x is connected to port x in ports.
*/
void
IO::check_bundles (std::vector<UserBundleInfo*>& list, const PortSet& ports)
{
@ -118,9 +122,9 @@ IO::check_bundles (std::vector<UserBundleInfo*>& list, const PortSet& ports)
for (std::vector<UserBundleInfo*>::iterator i = list.begin(); i != list.end(); ++i) {
uint32_t const N = (*i)->bundle->nchannels ();
uint32_t const N = (*i)->bundle->nchannels().n_total();
if (_ports.num_ports (default_type()) < N) {
if (_ports.num_ports() < N) {
continue;
}
@ -771,7 +775,7 @@ IO::get_port_counts (const XMLNode& node, int version, ChanCount& n, boost::shar
if ((prop = node.property ("connection")) != 0) {
if ((c = find_possible_bundle (prop->value())) != 0) {
n = ChanCount::max (n, ChanCount(c->type(), c->nchannels()));
n = ChanCount::max (n, c->nchannels());
}
return 0;
}
@ -780,7 +784,7 @@ IO::get_port_counts (const XMLNode& node, int version, ChanCount& n, boost::shar
if ((*iter)->name() == X_("Bundle")) {
if ((c = find_possible_bundle (prop->value())) != 0) {
n = ChanCount::max (n, ChanCount(c->type(), c->nchannels()));
n = ChanCount::max (n, c->nchannels());
return 0;
} else {
return -1;
@ -1328,8 +1332,6 @@ IO::setup_bundle ()
_bundle->suspend_signals ();
_bundle->set_type (default_type ());
_bundle->remove_channels ();
if (_direction == Input) {
@ -1340,7 +1342,7 @@ IO::setup_bundle ()
_bundle->set_name (buf);
uint32_t const ni = _ports.num_ports();
for (uint32_t i = 0; i < ni; ++i) {
_bundle->add_channel (bundle_channel_name (i, ni));
_bundle->add_channel (bundle_channel_name (i, ni), _ports.port(i)->type());
_bundle->set_port (i, _session.engine().make_port_name_non_relative (_ports.port(i)->name()));
}

View File

@ -441,7 +441,7 @@ Session::when_engine_running ()
snprintf (buf, sizeof (buf), _("out %" PRIu32), np+1);
shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("mono"));
c->add_channel (_("mono"), DataType::AUDIO);
c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
add_bundle (c);
@ -454,9 +454,9 @@ Session::when_engine_running ()
char buf[32];
snprintf (buf, sizeof(buf), _("out %" PRIu32 "+%" PRIu32), np + 1, np + 2);
shared_ptr<Bundle> c (new Bundle (buf, true));
c->add_channel (_("L"));
c->add_channel (_("L"), DataType::AUDIO);
c->set_port (0, _engine.get_nth_physical_output (DataType::AUDIO, np));
c->add_channel (_("R"));
c->add_channel (_("R"), DataType::AUDIO);
c->set_port (1, _engine.get_nth_physical_output (DataType::AUDIO, np + 1));
add_bundle (c);
@ -470,7 +470,7 @@ Session::when_engine_running ()
snprintf (buf, sizeof (buf), _("in %" PRIu32), np+1);
shared_ptr<Bundle> c (new Bundle (buf, false));
c->add_channel (_("mono"));
c->add_channel (_("mono"), DataType::AUDIO);
c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
add_bundle (c);
@ -484,9 +484,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->add_channel (_("L"));
c->add_channel (_("L"), DataType::AUDIO);
c->set_port (0, _engine.get_nth_physical_input (DataType::AUDIO, np));
c->add_channel (_("R"));
c->add_channel (_("R"), DataType::AUDIO);
c->set_port (1, _engine.get_nth_physical_input (DataType::AUDIO, np + 1));
add_bundle (c);

View File

@ -50,7 +50,13 @@ ARDOUR::UserBundle::set_state (XMLNode const & node, int /*version*/)
return -1;
}
add_channel (name->value ());
XMLProperty const * type;
if ((type = (*i)->property ("type")) == 0) {
PBD::error << _("Node for Channel has no \"type\" property") << endmsg;
return -1;
}
add_channel (name->value (), DataType (type->value()));
XMLNodeList const ports = (*i)->children ();
@ -93,6 +99,7 @@ ARDOUR::UserBundle::get_state ()
for (std::vector<Channel>::iterator i = _channel.begin(); i != _channel.end(); ++i) {
XMLNode* c = new XMLNode ("Channel");
c->add_property ("name", i->name);
c->add_property ("type", i->type.to_string());
for (PortList::iterator j = i->ports.begin(); j != i->ports.end(); ++j) {
XMLNode* p = new XMLNode ("Port");