summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2007-10-12 14:49:07 +0000
committerCarl Hetherington <carl@carlh.net>2007-10-12 14:49:07 +0000
commit7dcc66a7e5e68d69bda04fc6a7462d3f2140f6d5 (patch)
treea98cf9e1f0f26d3ffe9fe00eccfd513eebde99c4
parent50c68c6d0cd14525a48ea8f15e779fa92a1069c5 (diff)
Better support for MIDI tracks in the IO selector.
git-svn-id: svn://localhost/ardour2/trunk@2547 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/io_selector.cc51
-rw-r--r--gtk2_ardour/io_selector.h5
2 files changed, 40 insertions, 16 deletions
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc
index 6fb23e6e5a..dcaa2418e5 100644
--- a/gtk2_ardour/io_selector.cc
+++ b/gtk2_ardour/io_selector.cc
@@ -29,11 +29,24 @@
#include "ardour/io.h"
#include "ardour/audioengine.h"
#include "ardour/track.h"
+#include "ardour/audio_track.h"
+#include "ardour/midi_track.h"
+#include "ardour/data_type.h"
#include "io_selector.h"
#include "utils.h"
#include "gui_thread.h"
#include "i18n.h"
+void
+PortGroup::add (std::string const & p)
+{
+ if (prefix.empty() == false && p.substr (0, prefix.length()) == prefix) {
+ ports.push_back (p.substr (prefix.length()));
+ } else {
+ ports.push_back (p);
+ }
+}
+
RotatedLabelSet::RotatedLabelSet (GroupedPortList& g)
: Glib::ObjectBase ("RotatedLabelSet"), Gtk::Widget (), _port_list (g), _base_start (64), _base_width (128)
{
@@ -617,15 +630,26 @@ GroupedPortList::refresh ()
for (ARDOUR::Session::RouteList::const_iterator i = routes->begin(); i != routes->end(); ++i) {
- PortGroup& g = dynamic_cast<ARDOUR::Track*> ((*i).get()) == 0 ? buss : track;
-
- ARDOUR::PortSet const & p = _for_input ? ((*i)->outputs()) : ((*i)->inputs());
- for (uint32_t j = 0; j < p.num_ports(); ++j) {
- std::string const n = p.port(j)->name ();
- g.ports.push_back (n.substr(strlen ("ardour:")));
+ PortGroup* g = 0;
+ if (_io->default_type() == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::AudioTrack*> ((*i).get())) {
+ /* Audio track for an audio IO */
+ g = &track;
+ } else if (_io->default_type() == ARDOUR::DataType::MIDI && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get())) {
+ /* Midi track for a MIDI IO */
+ g = &track;
+ } else if (_io->default_type() == ARDOUR::DataType::AUDIO && dynamic_cast<ARDOUR::MidiTrack*> ((*i).get()) == 0) {
+ /* Non-MIDI track for an Audio IO; must be an audio buss */
+ g = &buss;
}
- std::sort (g.ports.begin(), g.ports.end());
+ if (g) {
+ ARDOUR::PortSet const & p = _for_input ? ((*i)->outputs()) : ((*i)->inputs());
+ for (uint32_t j = 0; j < p.num_ports(); ++j) {
+ g->add (p.port(j)->name ());
+ }
+
+ std::sort (g->ports.begin(), g->ports.end());
+ }
}
@@ -642,24 +666,21 @@ GroupedPortList::refresh ()
if (ports) {
- /* Count them */
int n = 0;
while (ports[n]) {
- ++n;
- }
-
- for (int i = 0; i < n; ++i) {
- std::string const p = ports[i];
+ std::string const p = ports[n];
if (p.substr(0, strlen ("system:")) == "system:") {
/* system: prefix */
- system.ports.push_back (p.substr (strlen ("system:")));
+ system.add (p);
} else {
if (p.substr(0, strlen("ardour:")) != "ardour:") {
/* other (non-ardour) prefix */
- other.ports.push_back (p);
+ other.add (p);
}
}
+
+ ++n;
}
}
diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h
index 4e40b356cd..3025f1d267 100644
--- a/gtk2_ardour/io_selector.h
+++ b/gtk2_ardour/io_selector.h
@@ -33,10 +33,13 @@ namespace ARDOUR {
class PortInsert;
}
-struct PortGroup
+class PortGroup
{
+ public:
PortGroup (std::string const & n, std::string const & p) : name (n), prefix (p) {}
+ void add (std::string const & p);
+
std::string name;
std::string prefix;
std::vector<std::string> ports;