//! Dump `ADV`'s voice chunks as RIFF/XMA, so each can be decoded and identified. //! //! `intro-audio-decomposed.md` measured that the intro's output is the movie's own //! WMA Pro 5.1 track at 0.600 **plus** three streams occupying a front pair, a //! centre (with a silent partner) and a rear pair. What it could **not** say is //! *which* stream sits where — the assignment there is by position, not content. //! The port needs that to weight a positional downmix. //! //! This writes the chunks out so they can be decoded (ffmpeg has `xma2`) and //! correlated against the per-channel residuals. //! //! cargo run -p sylpheed-formats --example adv_voice_dump -- OUTDIR [MOVIE] use sylpheed_formats::media::{self, DirectorySource, DiscSource}; use sylpheed_formats::slb::{self, VoiceLang}; fn main() { let out = std::env::args().nth(1).expect("OUTDIR"); let movie = std::env::args().nth(2).unwrap_or_else(|| "ADV".into()); let disc = std::env::var("SYLPHEED_DISC").expect("SYLPHEED_DISC"); let src = DirectorySource::new(std::path::PathBuf::from(&disc)); std::fs::create_dir_all(&out).expect("outdir"); let (start, end) = media::resolve_movie_voice_region(&src, &movie, VoiceLang::English) .expect("voice region"); let bytes = src .read_segment_range("dat/sound", start, (end - start) as usize) .expect("region"); println!("{movie}: region {start}..{end} = {} B", end - start); let riffs = slb::to_xma_riffs(&bytes); println!("{} RIFF chunk(s)", riffs.len()); for (i, r) in riffs.iter().enumerate() { let p = format!("{out}/{movie}_{i}.xma"); std::fs::write(&p, r).expect("write"); // the probe reports `byte_size` = RIFF total - 60; print both so the // dump can be tied to a specific XMA context by its own number println!(" chunk {i}: {} B byte_size-equivalent {} -> {p}", r.len(), r.len() as i64 - 60); } }