A bit more of track import done...

git-svn-id: svn://localhost/ardour2/branches/3.0@4241 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Sakari Bergen 2008-11-24 22:25:57 +00:00
parent 94537a47a1
commit 23b1ff94b9
3 changed files with 138 additions and 35 deletions

View File

@ -50,10 +50,12 @@ class AudioTrackImporter : public ElementImporter
private:
bool parse_io (XMLNode const & node);
bool parse_processor (XMLNode const & node);
bool parse_route_xml ();
bool parse_io ();
bool parse_controllable (XMLNode const & node, XMLNode & dest_parent);
bool parse_processor (XMLNode & node);
bool parse_controllable (XMLNode & node);
bool parse_automation (XMLNode & node);
XMLNode xml_track;

View File

@ -180,7 +180,7 @@ AudioRegionImporter::move ()
bool
AudioRegionImporter::parse_xml_region ()
{
XMLPropertyList const & props = xml_region.properties();;
XMLPropertyList const & props = xml_region.properties();
bool id_ok = false;
bool name_ok = false;

View File

@ -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);
}
// TODO parse remote-control and extra?
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);
}
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();
return true;
}
bool
AudioTrackImporter::parse_controllable (XMLNode & node)
{
XMLProperty * prop;
if ((prop = node.property ("id"))) {
PBD::ID new_id;
prop->set_value (new_id.to_s());
} else {
return false;
}
// TODO parse rest of the XML
return true;
}
bool
AudioTrackImporter::parse_controllable (XMLNode const & node, XMLNode & dest_parent)
AudioTrackImporter::parse_automation (XMLNode & node)
{
XMLProperty * prop;
XMLNode new_node (node);
if ((prop = new_node.property ("id"))) {
PBD::ID old_id (prop->value());
PBD::ID new_id;
XMLNodeList const & lists = node.children ("AutomationList");
for (XMLNodeList::const_iterator it = lists.begin(); it != lists.end(); ++it) {
XMLProperty * prop;
prop->set_value (new_id.to_s());
// TODO do id mapping and everything else necessary...
if ((prop = (*it)->property ("id"))) {
PBD::ID id;
prop->set_value (id.to_s());
}
} else {
return false;
// TODO rate convert events
}
dest_parent.add_child_copy (new_node);
return true;
}
} // namespace ARDOUR