2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <ardour/audio_track_importer.h>
23 #include <ardour/session.h>
26 #include <pbd/failed_constructor.h>
27 #include <pbd/convert.h>
32 using namespace ARDOUR;
34 /*** AudioTrackImportHandler ***/
36 AudioTrackImportHandler::AudioTrackImportHandler (XMLTree const & source, Session & session) :
37 ElementImportHandler (source, session)
39 XMLNode const * root = source.root();
40 XMLNode const * routes;
42 if (!(routes = root->child ("Routes"))) {
43 throw failed_constructor();
46 XMLNodeList const & route_list = routes->children();
47 for (XMLNodeList::const_iterator it = route_list.begin(); it != route_list.end(); ++it) {
48 const XMLProperty* type = (*it)->property("default-type");
49 if ( !type || type->value() == "audio" ) {
51 elements.push_back (ElementPtr ( new AudioTrackImporter (source, session, *this, **it)));
52 } catch (failed_constructor err) {
60 AudioTrackImportHandler::get_info () const
62 return _("Audio Tracks");
66 /*** AudioTrackImporter ***/
68 AudioTrackImporter::AudioTrackImporter (XMLTree const & source, Session & session, AudioTrackImportHandler & handler, XMLNode const & node) :
69 ElementImporter (source, session),
74 if (!parse_route_xml ()) {
75 throw failed_constructor();
79 throw failed_constructor();
82 XMLNodeList const & controllables = node.children ("controllable");
83 for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
84 parse_controllable (**it);
87 XMLNode * remote_control = xml_track.child ("remote_control");
88 if (remote_control && (prop = remote_control->property ("id"))) {
89 uint32_t control_id = session.ntracks() + session.nbusses() + 1;
90 prop->set_value (to_string (control_id, std::dec));
93 xml_track.remove_nodes_and_delete ("extra");
97 AudioTrackImporter::parse_route_xml ()
99 XMLPropertyList const & props = xml_track.properties();
101 for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
102 string prop = (*it)->name();
103 if (!prop.compare ("default-type") || !prop.compare ("flags") ||
104 !prop.compare ("active") || !prop.compare ("muted") ||
105 !prop.compare ("soloed") || !prop.compare ("phase-invert") ||
106 !prop.compare ("denormal-protection") || !prop.compare("mute-affects-pre-fader") ||
107 !prop.compare ("mute-affects-post-fader") || !prop.compare("mute-affects-control-outs") ||
108 !prop.compare ("mute-affects-main-outs") || !prop.compare("mode")) {
110 } else if (!prop.compare("order-keys")) {
112 } else if (!prop.compare("diskstream-id")) {
115 std::cerr << string_compose (X_("AudioTrackImporter: did not recognise XML-property \"%1\""), prop) << endmsg;
123 AudioTrackImporter::parse_io ()
126 bool name_ok = false;
129 if (!(io = xml_track.child ("IO"))) {
133 XMLPropertyList const & props = io->properties();
135 for (XMLPropertyList::const_iterator it = props.begin(); it != props.end(); ++it) {
136 string prop = (*it)->name();
137 if (!prop.compare ("gain") || !prop.compare ("iolimits")) {
139 } else if (!prop.compare("name")) {
142 } else if (!prop.compare("id")) {
144 (*it)->set_value (id.to_s());
147 } else if (!prop.compare("inputs")) {
149 } else if (!prop.compare("outputs")) {
152 std::cerr << string_compose (X_("AudioTrackImporter: did not recognise XML-property \"%1\""), prop) << endmsg;
157 error << X_("AudioTrackImporter: did not find necessary XML-property \"name\"") << endmsg;
162 error << X_("AudioTrackImporter: did not find necessary XML-property \"id\"") << endmsg;
166 XMLNodeList const & controllables = io->children ("controllable");
167 for (XMLNodeList::const_iterator it = controllables.begin(); it != controllables.end(); ++it) {
168 parse_controllable (**it);
171 XMLNodeList const & processors = io->children ("Processor");
172 for (XMLNodeList::const_iterator it = processors.begin(); it != processors.end(); ++it) {
173 parse_processor (**it);
176 XMLNodeList const & automations = io->children ("Automation");
177 for (XMLNodeList::const_iterator it = automations.begin(); it != automations.end(); ++it) {
178 parse_automation (**it);
185 AudioTrackImporter::get_info () const
192 AudioTrackImporter::prepare_move ()
199 AudioTrackImporter::cancel_move ()
205 AudioTrackImporter::move ()
211 AudioTrackImporter::parse_processor (XMLNode & node)
213 XMLNode * automation = node.child ("Automation");
215 parse_automation (*automation);
222 AudioTrackImporter::parse_controllable (XMLNode & node)
226 if ((prop = node.property ("id"))) {
228 prop->set_value (new_id.to_s());
237 AudioTrackImporter::parse_automation (XMLNode & node)
240 XMLNodeList const & lists = node.children ("AutomationList");
241 for (XMLNodeList::const_iterator it = lists.begin(); it != lists.end(); ++it) {
244 if ((prop = (*it)->property ("id"))) {
246 prop->set_value (id.to_s());
249 // TODO rate convert events