diff options
author | Harald Eilertsen <haraldei@anduin.net> | 2020-12-07 12:50:00 +0100 |
---|---|---|
committer | Harald Eilertsen <haraldei@anduin.net> | 2020-12-07 12:50:00 +0100 |
commit | af057f48f833744b9d20eb536e220b6df247f7e7 (patch) | |
tree | 3311fcc286cb989f5aa17eaaa1460b1e8f9e790e /src | |
parent | 181dd4972efc1c40e6a965438a65c27474a43107 (diff) | |
download | cbconv-af057f48f833744b9d20eb536e220b6df247f7e7.tar.gz cbconv-af057f48f833744b9d20eb536e220b6df247f7e7.tar.bz2 cbconv-af057f48f833744b9d20eb536e220b6df247f7e7.zip |
Begin parsing of Arrangement1 chunk.
This is the meat of the file, and the majority of the data. Don't expect
this to be trivial, or how much of it I really need to understand. Let's
take it slowly and see where it takes us.
Diffstat (limited to 'src')
-rw-r--r-- | src/cubase_project.rs | 3 | ||||
-rw-r--r-- | src/main.rs | 41 |
2 files changed, 43 insertions, 1 deletions
diff --git a/src/cubase_project.rs b/src/cubase_project.rs index 49c73a7..498936d 100644 --- a/src/cubase_project.rs +++ b/src/cubase_project.rs @@ -38,3 +38,6 @@ pub struct PAppVersion { pub applocale: String, } +#[derive(Debug, Default)] +pub struct PArrangement { +} diff --git a/src/main.rs b/src/main.rs index 58b6a86..6eb105b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,7 @@ use cubase_project::*; use nom::{ bytes::complete::*, - multi::length_data, + multi::{length_data, many1}, number::complete::*, sequence::tuple, Finish, @@ -90,6 +90,12 @@ fn p_app_version<'a>(data: &'a [u8]) -> IResult<&'a [u8], PAppVersion> { Ok((r, v)) } +fn p_arrangement<'a>(data: &'a [u8]) -> IResult<&'a [u8], PArrangement> { + let mut v = PArrangement::default(); + + Ok((data, v)) +} + fn fourcc<'a>(data: &'a [u8]) -> IResult<&'a [u8], &'a str> { let (rest, tag) = take(4usize)(data)?; Ok((rest, std::str::from_utf8(tag).unwrap())) @@ -161,6 +167,11 @@ fn cpr_file<'a>(data: &'a [u8]) -> IResult<&'a [u8], CubaseProject> { proj.app_version = v; payload = r2; }, + "Arrangement1" => { + let (r2, a) = arrangement_chunk(r)?; + println!("[*] {:?}", a); + payload = r2; + }, _ => { let (r2, _) = riff_chunk(r)?; payload = r2; @@ -223,6 +234,34 @@ fn version_chunk<'a>(data: &'a [u8]) -> IResult<&'a [u8], PAppVersion> { Ok((r, v)) } + +fn arrangement_chunk<'a>(data: &'a [u8]) -> IResult<&'a [u8], PArrangement> { + let (r, chunk) = riff_chunk(data)?; + assert_eq!(chunk.fourcc, "ARCH"); + + // It varies a bit how many levels deep the actual PArrangement object is. + // + // File created with Cubase 4.5.x (file version 310?) seems to have this + // structure: + // + // GDocument -> GModel -> CmObject + // + // While Cubase version 5.x (file version 400?) seems to have the CmObject + // directly under the GDocument container. + let (odata, c) = many1(container_node)(chunk.payload)?; + println!("[*] {:?}", c); + + // This is the actual PArrangeent object + let (r2, o) = object_node(odata)?; + println!("[*] {:?}: {} ({} bytes)", o.node_type, o.name, o.payload.unwrap().len()); + assert_eq!(r2.len(), 0); + + let (r2, v) = p_arrangement(o.payload.unwrap())?; + // assert_eq!(r2.len(), 0); + + Ok((r, PArrangement::default())) +} + pub fn parse_cubase_project<P>(filename: P) -> Result<CubaseProject, Box<dyn Error>> where P: AsRef<Path> |