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 (""));
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 ();
}
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 {
_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);
_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 ()
{
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);
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
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 ();
}
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 {
{
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;
}
{
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;
}
}
-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 ();
}
/* 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;
}
++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;
/** 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)
{
}
/* 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
/** 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 ();
/* 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);
}
}
}
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());
}
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) {
}
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) {
}
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()) {
}
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]);
}
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 ();
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;
}
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 ();
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();
}
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;
_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);
PortMatrix::set_type (DataType t)
{
_type = t;
- _ports[0].set_type (_type);
- _ports[1].set_type (_type);
setup_all_ports ();
}
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),
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
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))
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);
+ }
}
}
}
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);
+ }
}
}
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);
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));
+ }
}
}
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()) {
_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,
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;
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();
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;
);
}
- 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 */
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));
}
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());
}
}
if (_matrix->show_only_bundles()) {
p += 1;
} else {
- p += (*i)->bundle->nchannels ();
+ p += (*i)->bundle->nchannels().get (_matrix->type());
}
}
} 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 {
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);
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);
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);
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();
}
}
}
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().n_total(); ++j) {
- for (uint32_t j = 0; j < node.column.bundle->nchannels (); ++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);
{
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);
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) {
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();
{
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);
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 */
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 ()));
}
_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);
}
}
#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.
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);
/** @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; }
void emit_changed (Change);
std::string _name;
- DataType _type;
bool _ports_are_inputs;
bool _signals_suspended;
* @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))
{
*/
Bundle::Bundle (std::string const & n, bool i)
: _name (n),
- _type (DataType::AUDIO),
- _ports_are_inputs (i),
- _signals_suspended (false),
- _pending_change (Change (0))
-{
-
-}
-
-
-/** 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)
}
-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;
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);
{
void
Bundle::remove_port_from_channel (uint32_t ch, string portname)
{
- assert (ch < nchannels());
+ assert (ch < nchannels().n_total());
bool changed = false;
void
Bundle::set_port (uint32_t ch, string portname)
{
- assert (ch < nchannels());
+ assert (ch < nchannels().n_total());
assert (portname.find_first_of (':') != string::npos);
{
/** @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);
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 ());
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);
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;
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);
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) {
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);
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);
void
Bundle::remove_ports_from_channel (uint32_t ch)
{
- assert (ch < nchannels ());
+ assert (ch < nchannels().n_total());
{
Glib::Mutex::Lock lm (_channel_mutex);
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);
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 ()
{
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;
}
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;
+}
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)
{
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;
}
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;
}
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;
_bundle->suspend_signals ();
- _bundle->set_type (default_type ());
-
_bundle->remove_channels ();
if (_direction == Input) {
_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()));
}
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);
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);
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);
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);
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 ();
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");