summaryrefslogtreecommitdiff
path: root/libs/ardour/audio_track_importer.cc
diff options
context:
space:
mode:
authorSakari Bergen <sakari.bergen@beatwaves.net>2008-11-24 22:25:57 +0000
committerSakari Bergen <sakari.bergen@beatwaves.net>2008-11-24 22:25:57 +0000
commit23b1ff94b9b5058b98c0563bba04079c7cc88226 (patch)
tree8566f210a2c70d3222cec9f84ff3db9530637322 /libs/ardour/audio_track_importer.cc
parent94537a47a1c53fd97f3010c9cc17b49b441bb37a (diff)
A bit more of track import done...
git-svn-id: svn://localhost/ardour2/branches/3.0@4241 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audio_track_importer.cc')
-rw-r--r--libs/ardour/audio_track_importer.cc161
1 files changed, 131 insertions, 30 deletions
diff --git a/libs/ardour/audio_track_importer.cc b/libs/ardour/audio_track_importer.cc
index 752203f2cb..68827fb161 100644
--- a/libs/ardour/audio_track_importer.cc
+++ b/libs/ardour/audio_track_importer.cc
@@ -20,12 +20,16 @@
#include <ardour/audio_track_importer.h>
+#include <ardour/session.h>
+
#include <pbd/id.h>
#include <pbd/failed_constructor.h>
+#include <pbd/convert.h>
#include "i18n.h"
-namespace ARDOUR {
+using namespace PBD;
+using namespace ARDOUR;
/*** AudioTrackImportHandler ***/
@@ -63,21 +67,118 @@ AudioTrackImportHandler::get_info () const
AudioTrackImporter::AudioTrackImporter (XMLTree const & source, Session & session, AudioTrackImportHandler & handler, XMLNode const & node) :
ElementImporter (source, session),
- xml_track ("Route")
+ xml_track (node)
{
- // TODO Parse top-level XML
+ XMLProperty * prop;
+
+ if (!parse_route_xml ()) {
+ throw failed_constructor();
+ }
- if (!parse_io (node)) {
+ if (!parse_io ()) {
throw failed_constructor();
}
XMLNodeList const & controllables = node.children ("controllable");
for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
- parse_controllable (**it, xml_track);
+ parse_controllable (**it);
+ }
+
+ XMLNode * remote_control = xml_track.child ("remote_control");
+ if (remote_control && (prop = remote_control->property ("id"))) {
+ uint32_t control_id = session.ntracks() + session.nbusses() + 1;
+ prop->set_value (to_string (control_id, std::dec));
+ }
+
+ xml_track.remove_nodes_and_delete ("extra");
+}
+
+bool
+AudioTrackImporter::parse_route_xml ()
+{
+ XMLPropertyList const & props = xml_track.properties();
+
+ for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
+ string prop = (*it)->name();
+ if (!prop.compare ("default-type") || !prop.compare ("flags") ||
+ !prop.compare ("active") || !prop.compare ("muted") ||
+ !prop.compare ("soloed") || !prop.compare ("phase-invert") ||
+ !prop.compare ("denormal-protection") || !prop.compare("mute-affects-pre-fader") ||
+ !prop.compare ("mute-affects-post-fader") || !prop.compare("mute-affects-control-outs") ||
+ !prop.compare ("mute-affects-main-outs") || !prop.compare("mode")) {
+ // All ok
+ } else if (!prop.compare("order-keys")) {
+ // TODO
+ } else if (!prop.compare("diskstream-id")) {
+ // TODO
+ } else {
+ std::cerr << string_compose (X_("AudioTrackImporter: did not recognise XML-property \"%1\""), prop) << endmsg;
+ }
+ }
+
+ return true;
+}
+
+bool
+AudioTrackImporter::parse_io ()
+{
+ XMLNode * io;
+ bool name_ok = false;
+ bool id_ok = false;
+
+ if (!(io = xml_track.child ("IO"))) {
+ return false;
+ }
+
+ XMLPropertyList const & props = io->properties();
+
+ for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
+ string prop = (*it)->name();
+ if (!prop.compare ("gain") || !prop.compare ("iolimits")) {
+ // All ok
+ } else if (!prop.compare("name")) {
+ name = prop;
+ name_ok = true;
+ } else if (!prop.compare("id")) {
+ PBD::ID id;
+ (*it)->set_value (id.to_s());
+ id_ok = true;
+ // TODO
+ } else if (!prop.compare("inputs")) {
+ // TODO
+ } else if (!prop.compare("outputs")) {
+ // TODO
+ } else {
+ std::cerr << string_compose (X_("AudioTrackImporter: did not recognise XML-property \"%1\""), prop) << endmsg;
+ }
+ }
+
+ if (!name_ok) {
+ error << X_("AudioTrackImporter: did not find necessary XML-property \"name\"") << endmsg;
+ return false;
+ }
+
+ if (!id_ok) {
+ error << X_("AudioTrackImporter: did not find necessary XML-property \"id\"") << endmsg;
+ return false;
+ }
+
+ XMLNodeList const & controllables = io->children ("controllable");
+ for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
+ parse_controllable (**it);
+ }
+
+ XMLNodeList const & processors = io->children ("Processor");
+ for (XMLNodeList::const_iterator it = processors.begin(); it != processors.end(); ++it) {
+ parse_processor (**it);
}
- // TODO parse remote-control and extra?
+ XMLNodeList const & automations = io->children ("Automation");
+ for (XMLNodeList::const_iterator it = automations.begin(); it != automations.end(); ++it) {
+ parse_automation (**it);
+ }
+ return true;
}
string
@@ -107,46 +208,46 @@ AudioTrackImporter::move ()
}
bool
-AudioTrackImporter::parse_io (XMLNode const & node)
+AudioTrackImporter::parse_processor (XMLNode & node)
{
- XMLNode * io;
- XMLProperty * prop;
-
- if (!(io = node.child ("IO"))) {
- return false;
+ XMLNode * automation = node.child ("Automation");
+ if (automation) {
+ parse_automation (*automation);
}
- if ((prop = io->property ("name"))) {
- name = prop->value();
- } else {
- return false;
- }
-
- // TODO parse rest of the XML
-
return true;
}
bool
-AudioTrackImporter::parse_controllable (XMLNode const & node, XMLNode & dest_parent)
+AudioTrackImporter::parse_controllable (XMLNode & node)
{
XMLProperty * prop;
- XMLNode new_node (node);
- if ((prop = new_node.property ("id"))) {
- PBD::ID old_id (prop->value());
+ if ((prop = node.property ("id"))) {
PBD::ID new_id;
-
prop->set_value (new_id.to_s());
- // TODO do id mapping and everything else necessary...
-
} else {
return false;
}
-
- dest_parent.add_child_copy (new_node);
return true;
}
-} // namespace ARDOUR
+bool
+AudioTrackImporter::parse_automation (XMLNode & node)
+{
+
+ XMLNodeList const & lists = node.children ("AutomationList");
+ for (XMLNodeList::const_iterator it = lists.begin(); it != lists.end(); ++it) {
+ XMLProperty * prop;
+
+ if ((prop = (*it)->property ("id"))) {
+ PBD::ID id;
+ prop->set_value (id.to_s());
+ }
+
+ // TODO rate convert events
+ }
+
+ return true;
+}