make compressor generic & add decompressor

This commit is contained in:
Alex Janka 2021-09-24 13:38:26 +10:00
parent 8d8e160bd0
commit 3e6ecd6248
5 changed files with 40 additions and 13 deletions

View file

@ -5,6 +5,8 @@ this makes racks look like they were made with ableton live 10.0.3. most racks w
windows: just drag and drop the .adg onto the converter exe windows: just drag and drop the .adg onto the converter exe
macos: drag and drop doesn't work, just use the terminal (ie: `./ableton-rack-converter ../racks/incompatible-rack.adg`) macos: drag and drop doesn't work, just use the terminal (ie: `./ableton-rack-converter ../racks/incompatible-rack.adg`)
compressor/decompressor are used in the same way for if u want to manually edit/inspect the xml
not working: not working:
* vsts * vsts
* you tell me (😉) * you tell me (😉)

View file

@ -1,4 +1,5 @@
cargo build --target-dir=./build/macos --release cargo build --target-dir=./build/macos --release
mkdir -p build/release/macos mkdir -p build/release/macos
cp build/macos/release/converter build/release/macos/ableton-rack-converter cp build/macos/release/converter build/release/macos/ableton-rack-converter
cp build/macos/release/compressor build/release/macos/xml-to-compressed-rack cp build/macos/release/compressor build/release/macos/xml-to-rack
cp build/macos/release/decompressor build/release/macos/rack-to-xml

View file

@ -1,4 +1,5 @@
cargo build --target=x86_64-pc-windows-gnu --target-dir=./build/windows --release cargo build --target=x86_64-pc-windows-gnu --target-dir=./build/windows --release
mkdir -p build/release/windows mkdir -p build/release/windows
cp build/windows/x86_64-pc-windows-gnu/release/converter.exe build/release/windows/ableton-rack-converter.exe cp build/windows/x86_64-pc-windows-gnu/release/converter.exe build/release/windows/ableton-rack-converter.exe
cp build/windows/x86_64-pc-windows-gnu/release/compressor.exe build/release/windows/xml-to-compressed-rack.exe cp build/windows/x86_64-pc-windows-gnu/release/compressor.exe build/release/windows/xml-to-rack.exe
cp build/windows/x86_64-pc-windows-gnu/release/decompressor.exe build/release/windows/rack-to-xml.exe

View file

@ -1,18 +1,20 @@
#![windows_subsystem = "windows"] #![windows_subsystem = "windows"]
use ableton_rack_converter; use ableton_rack_converter;
use std::{fs, path::PathBuf}; use std::{env, path::PathBuf};
fn main() { fn main() {
let paths = fs::read_dir(".\\test_conversion\\").unwrap(); let args: Vec<String> = env::args().collect();
for path in paths { if args.len() == 1 {
let loadpath = path.unwrap().path(); return;
if loadpath.extension().expect("couldn't get extension") == "xml" {
let mut path_str = String::from(".\\exported_files\\");
path_str.push_str(loadpath.file_stem().unwrap().to_str().unwrap());
path_str.push_str("-compressed.adg");
let savepath = PathBuf::from(path_str);
ableton_rack_converter::compress_file(loadpath, savepath);
}
} }
let file_load = PathBuf::from(args[1].as_str());
if file_load.extension().expect("wrong/no extension") != "xml" {
return;
}
let mut path_str = String::from("");
path_str.push_str(file_load.file_stem().unwrap().to_str().unwrap());
path_str.push_str("-compressed.adg");
let file_save = PathBuf::from(path_str);
ableton_rack_converter::compress_file(file_load, file_save);
} }

21
src/bin/decompressor.rs Normal file
View file

@ -0,0 +1,21 @@
#![windows_subsystem = "windows"]
use ableton_rack_converter;
use std::{env, path::PathBuf};
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
return;
}
let file_load = PathBuf::from(args[1].as_str());
if file_load.extension().expect("wrong/no extension") != "adg" {
return;
}
let mut path_str = String::from("");
path_str.push_str(file_load.file_stem().unwrap().to_str().unwrap());
path_str.push_str("-decompressed.xml");
let file_save = PathBuf::from(path_str);
let dom = ableton_rack_converter::load_adg(file_load);
ableton_rack_converter::save_uncompressed(&dom, file_save);
}