diff options
| author | NotRexed <therealnothingfn@gmail.com> | 2026-11-20 22:32:47 -0500 |
|---|---|---|
| committer | NotRexed <therealnothingfn@gmail.com> | 2026-11-20 22:32:47 -0500 |
| commit | 1da3c7d2aa55de7b6515a72e9ef6df6370476a12 (patch) | |
| tree | 44dd9d7bf16c8d92d138c7e3e1376ac5384f8a5d /tools/rpf9dump/Program.cs | |
| parent | bfba26fbbb4c283a6c19405210deff4e8fc64847 (diff) | |
Audio: XMA2 streams via rpf9dump xma + ffmpeg (all 1,818 decode)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tools/rpf9dump/Program.cs')
| -rw-r--r-- | tools/rpf9dump/Program.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/tools/rpf9dump/Program.cs b/tools/rpf9dump/Program.cs index 7b11eaf6c..5c672f098 100644 --- a/tools/rpf9dump/Program.cs +++ b/tools/rpf9dump/Program.cs | |||
| @@ -52,6 +52,27 @@ else if (mode == "audio") | |||
| 52 | return new { e.Path, e.Offset, e.Size, Streams = info?.Streams.Select(s => new { s.Index, Id = s.Id.ToString("X8"), s.Codec, s.Channels, s.SampleRate, s.DurationSeconds, s.IsStreamed }) }; }).ToList(); | 52 | return new { e.Path, e.Offset, e.Size, Streams = info?.Streams.Select(s => new { s.Index, Id = s.Id.ToString("X8"), s.Codec, s.Channels, s.SampleRate, s.DurationSeconds, s.IsStreamed }) }; }).ToList(); |
| 53 | File.WriteAllText(Path.Combine(outDir, "audio_manifest.json"), JsonSerializer.Serialize(new { src, Count = banks.Count, Banks = rows }, json)); | 53 | File.WriteAllText(Path.Combine(outDir, "audio_manifest.json"), JsonSerializer.Serialize(new { src, Count = banks.Count, Banks = rows }, json)); |
| 54 | } | 54 | } |
| 55 | else if (mode == "xma") | ||
| 56 | { | ||
| 57 | // XMA2 streams (AWC codec 5) as RIFF XMA2 .wav files that ffmpeg decodes (AwcRecovery.WriteXmaWave). | ||
| 58 | var doc = ArchiveReader.Open(src); | ||
| 59 | var banks = doc.Entries.Where(e => e.Extension == ".awc" && e.CanExtract).ToList(); | ||
| 60 | string sub = Path.Combine(outDir, "xma"); Directory.CreateDirectory(sub); | ||
| 61 | foreach (var e in banks) | ||
| 62 | { | ||
| 63 | var info = AwcInfo.Inspect(src, e.Offset, e.Size); | ||
| 64 | if (info == null) continue; | ||
| 65 | foreach (var st in info.Streams.Where(x => x.Codec == 5)) | ||
| 66 | { | ||
| 67 | string dir = Path.Combine(sub, Util.Safe(Path.GetFileNameWithoutExtension(e.Name))); | ||
| 68 | Directory.CreateDirectory(dir); | ||
| 69 | string path = Path.Combine(dir, $"{st.Id:X8}.xma.wav"); | ||
| 70 | if (File.Exists(path)) { ok++; continue; } | ||
| 71 | try { AwcRecovery.WriteXmaWave(src, e.Offset, e.Size, st.Index, path); ok++; } | ||
| 72 | catch (Exception ex) { fail++; if (fail <= 5) Console.WriteLine($" fail {e.Name}#{st.Index}: {ex.GetType().Name} {ex.Message}"); } | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 55 | else if (mode is "models" or "textures") | 76 | else if (mode is "models" or "textures") |
| 56 | { | 77 | { |
| 57 | byte[] header; using (var f = File.OpenRead(src)) { header = new byte[64]; f.ReadExactly(header); } | 78 | byte[] header; using (var f = File.OpenRead(src)) { header = new byte[64]; f.ReadExactly(header); } |