Skip to content

Move BnkExtract onto ritoshark, drop the Wwise toolchain - #7

Open
DexalGT wants to merge 4 commits into
mainfrom
feat/audio-ritoshark
Open

Move BnkExtract onto ritoshark, drop the Wwise toolchain#7
DexalGT wants to merge 4 commits into
mainfrom
feat/audio-ritoshark

Conversation

@DexalGT

@DexalGT DexalGT commented Aug 3, 2026

Copy link
Copy Markdown
Member

Replaces the downloaded Wwise/vgmstream toolchain with in-process Rust, fixes the container corruption in bnk_save_bank, and fills the bank paths in from a picked BIN.

Dropping the toolchain

wwise_install pulled WwiseConsole.exe and vgmstream-cli.exe from tarngaina/LtMAO into %APPDATA%/RitoShark/AudioTools and shelled out to them. ritoshark f646d96 encodes Wwise Vorbis in-process, which was the only job that genuinely needed an external toolchain, so the install flow, the progress modal and the "needs tools" gating are gone. Anything an older version left behind is deleted on startup.

Worth knowing: the prompt only appeared on Replace, Adjust gain, Open in splitter and importing non-.wem reference files. Loading, playing and extracting never touched it, so plenty of users will never have seen it.

Two things replaced it:

  • Encodingencode_vorbis / encode_vorbis_like from rs_audio.
  • User mp3/flac/ogg/m4asymphonia. rs_audio deliberately stops at PCM samples, so decoding user files is the app's side of that boundary.

Decoding was already native but unreachable

audio_decode_to_wav tried the Rust decoder and then only accepted the result if decoded.format == "wav". Every League WEM is Wwise Vorbis, so that check never passed and every decode spawned vgmstream anyway.

Container corruption

bnk_save_bank rebuilt the bank from scratch on every save: a fresh 20-byte BKHD at version 134 with bank id 0, HIRC and every unmodelled section dropped, and entries sorted by id so order was lost too. It now applies the edited entry set to the container the tree was loaded from, so the header, the bank id and the hierarchy survive. The root node already carried its source path, so no new frontend plumbing was needed.

One deliberate behaviour change: saving without a recorded source is now an error rather than silently writing a rebuilt bank.

BIN → banks

Picking a skin BIN now fills in the audio and events fields. bnk_locate_banks_for_bin walks up to the directory holding data/ or assets/, then reuses the mod-folder matching so the picker and the folder drop cannot disagree. Only empty fields are filled, and nothing convincing nearby leaves them alone rather than guessing.

Also

  • Gain decodes to PCM, scales and re-encodes into the codec the sound already used, instead of round-tripping through two processes.
  • Removed the orphaned 74 KB codebook and the vestigial loadCodebook / _codebook plumbing, which every decoder already ignored.
  • The scanner body moved into scan_folder_sets so both callers share one copy of the matching rules.

Verification

291 Rust tests pass (16 new, covering header/hierarchy survival on save, entry removal, verbatim .wem passthrough, amplify staying Vorbis, WAV round-trip, symphonia decode, and the skin/root path helpers). npm run typecheck and clippy are clean for everything touched.

Pre-existing and untouched: quartz-lib/examples/fbx_top2 and fbx_ref don't compile — they use fbxcel, which isn't declared in any Cargo.toml. --lib --bins is green. mp3Bitrate still flows from the UI and still does nothing, since there is no MP3 encoder; the field is kept and documented rather than silently changing the wire contract.

Not verified in a running game client — that's the one check that can't be done from here.

DexalGT added 4 commits August 4, 2026 00:42
Quartz downloaded WwiseConsole.exe and vgmstream-cli.exe from tarngaina/LtMAO into %APPDATA%/RitoShark/AudioTools and shelled out to them. ritoshark f646d96 encodes Wwise Vorbis in-process, which was the only thing that genuinely needed an external toolchain, so both are gone along with the install flow, the progress modal and the needs-tools gating. Any copy an older version left behind is deleted on startup. Decoding was already native but unreachable: audio_decode_to_wav only accepted the result if it came back as wav, and every League wem is Vorbis, so the check never passed and each decode spawned vgmstream anyway. User mp3/flac/ogg/m4a now goes through symphonia, which is the app's side of the boundary rs_audio deliberately draws at PCM samples. Containers moved to rs_audio too: bnk_save_bank rebuilt the bank from scratch on every save, writing a 20-byte BKHD at version 134 with bank id 0 and dropping HIRC and every unmodelled section, and it sorted entries by id so order was lost as well. It now applies the edited entry set to the container the tree was loaded from, so the header and hierarchy survive. Gain no longer round-trips through two processes; it decodes to pcm, scales, and re-encodes into the codec the sound already used.
Picking a skin BIN already tells you which banks belong to it: they share a skin number and a mod root. bnk_locate_banks_for_bin walks up from the BIN to the directory holding data/ or assets/, then reuses the mod-folder matching to pair an audio bank with its events bank, so the folder drop and the file picker cannot disagree. Only empty fields are filled, so an explicit choice is never overwritten, and nothing convincing nearby leaves the fields alone rather than guessing. The scanner body moved into scan_folder_sets so both callers share one copy of the rules.
load_banks returned audio_files alongside the tree, and both carried the full bytes of every embedded wem. The frontend declared audioFiles and hydrated it, but nothing ever read it — the tree leaves are what the UI works from. Tauri serializes Vec<u8> as a JSON number array, so each byte costs roughly three and a half characters and the duplicate doubled that again. Measured on aatrox_base_sfx_audio.bnk: a 3.02 MB bank with 170 entries produced 21.54 MB of IPC JSON, now 10.79 MB. The remaining 3.6x is the number-array encoding itself, which needs the tree to stop carrying audio at all to fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant