//! Is `BGM_103` the ONLY bank with those two wave sizes? //! //! `authored/audio.json` says *"Static code, disc census and runtime all agree"* //! — three legs. Reading the sentence beneath it, legs two and three are **one** //! comparison: the disc's declared wave sizes matched byte-for-byte against what //! the XMA probe saw at the menu. That is a disc-to-runtime match, not two //! independent confirmations. //! //! It is a third leg only if the census independently EXCLUDES alternatives — if //! some other bank carried the same two sizes, the byte match would not //! distinguish it. So the sizes are counted across every `BGM_*` bank on the //! disc. //! //! Prompted by the Decoder's point that a decorative second support is worse //! than none: **a conclusion with two supports reads as better evidenced than //! one with a single support, so apparent redundancy is itself the //! misinformation.** use sylpheed_formats::media; fn main() { let root = std::env::var("SYLPHEED_DISC").unwrap_or_else(|_| "/disc".into()); let src = media::DirectorySource::new(&root); const WANT: [usize; 2] = [3_876_864, 3_930_112]; let (mut found, mut matches) = (0usize, Vec::new()); for n in 0..=199u32 { let name = format!("BGM_{n:03}.slb"); let Ok(riffs) = media::sound_bank_riffs(&src, &name) else { continue }; if riffs.is_empty() { continue } found += 1; let sizes: Vec = riffs.iter().map(|r| r.len()).collect(); // Compare on the DATA payload the port sums, not on the RIFF wrapper: // a wrapper differs by header bytes and would hide a real collision. let near = sizes.iter().any(|s| WANT.iter().any(|w| s.abs_diff(*w) < 4096)); if near { matches.push((name.clone(), sizes.clone())); } } println!(" {found} BGM_* bank(s) readable on this disc"); for (n, s) in &matches { println!(" {n:<14} wave sizes {s:?}"); } println!("\n {} bank(s) carry a wave within 4 KiB of {WANT:?}", matches.len()); println!(" Exactly 1 means the census EXCLUDES alternatives and is a real third"); println!(" leg. More than 1 means the byte match does not distinguish BGM_103,"); println!(" and \"three legs\" is two. Zero means this reader cannot see the"); println!(" incumbent and its answer means nothing."); }