works for live 11 sets!!

This commit is contained in:
Alex Janka 2022-03-20 13:52:57 +11:00
parent 68f895adf4
commit 8a748e4321
2 changed files with 43 additions and 11 deletions

View file

@ -25,6 +25,6 @@ fn main() {
); );
let file_save = PathBuf::from(path_str); let file_save = PathBuf::from(path_str);
let mut device = ableton_rack_converter::load_ableton_file(file_load); let mut device = ableton_rack_converter::load_ableton_file(file_load);
fixers::traverse_children(&mut device); fixers::traverse_children(&mut device, None);
ableton_rack_converter::save_ableton_file(&device, file_save); ableton_rack_converter::save_ableton_file(&device, file_save);
} }

View file

@ -1,27 +1,59 @@
use xml_dom::level2::{Attribute, Node, RefNode}; use xml_dom::level2::{Attribute, Document, Node, RefNode};
pub fn traverse_children(node: &mut RefNode) { pub fn traverse_children(node: &mut RefNode, parent: Option<&mut RefNode>) {
if node.node_name().to_string() == "Ableton" { let node_name = node.node_name().to_string();
if node_name == "Ableton" {
// -- LIVE 10.0.3 --
// let major = "5";
// let minor = "10.0_370";
// let revision = "5ae7d4938908194888f90ed5411dc3def59687f2";
// let creator = "Ableton Live 10.0.3";
// -- LIVE 10.1.14 --
let major = "5";
let minor = "10.0_377";
let revision = "2398148aa88b1dd45414868a29166dc901f88d67";
let creator = "Ableton Live 10.1.41";
println!("converting ableton version");
for (name, mut attribute) in node.attributes() { for (name, mut attribute) in node.attributes() {
match name.to_string().as_str() { match name.to_string().as_str() {
"MajorVersion" => attribute.set_value("5").unwrap(), "MajorVersion" => attribute.set_value(major).unwrap(),
"MinorVersion" => attribute.set_value("10.0_370").unwrap(), "MinorVersion" => attribute.set_value(minor).unwrap(),
"Revision" => attribute "Revision" => attribute.set_value(revision).unwrap(),
.set_value("5ae7d4938908194888f90ed5411dc3def59687f2") "Creator" => attribute.set_value(creator).unwrap(),
.unwrap(),
"Creator" => attribute.set_value("Ableton Live 10.0.3").unwrap(),
_ => (), _ => (),
} }
} }
} }
match node.node_name().to_string().as_str() { match node.node_name().to_string().as_str() {
"OverwriteProtectionNumber" => fix_overwrite_protection(node), "OverwriteProtectionNumber" => fix_overwrite_protection(node),
"Scenes" => match parent {
None => {}
Some(p) => {
fix_scenes(node, p);
}
},
_ => { _ => {
for mut e in node.child_nodes() { for mut e in node.child_nodes() {
traverse_children(&mut e); traverse_children(&mut e, Some(node));
} }
} }
} }
} }
fn fix_scenes(node: &mut RefNode, parent: &mut RefNode) {
let mut newnode = node
.owner_document()
.unwrap()
.create_element("SceneNames")
.unwrap();
for c in node.child_nodes() {
newnode.append_child(c).unwrap();
}
parent
.replace_child(newnode, node.to_owned())
.expect("Couldn't append new child node");
}
fn fix_overwrite_protection(node: &mut RefNode) {} fn fix_overwrite_protection(node: &mut RefNode) {}