EtiTheSpirit / WEMConverter

Converts WEM to WAV or converts any audio format into WEM.
MIT License
35 stars 4 forks source link

NMS: Converting WEM->WAV results in white noise (decompression not performed) #10

Open Sophira opened 2 years ago

Sophira commented 2 years ago

I am attempting to convert a WEM file from No Man's Sky (up-to-date as of today; I'd get you a precise version number but I don't know where that exists in the game, sorry!) into WAV format. I do not have Wwise installed, but as I understand it this should not be necessary for this project? (If I'm wrong, my apologies!)

To be precise:

  1. From the NMSARC.761ACED1.pak file which comes with the game[1], I have extracted the AUDIO/WINDOWS/NMS_AUDIO_PERSISTENT.BNK file[2].
  2. I have then used BNKcompilerWCmd.py (from the "Monkeyman's BNK Compiler" link on https://nmsmodding.fandom.com/wiki/Replacing_Audio) to extract the WEM files contained within the NMS_AUDIO_PERSISTENT.BNK file, resulting in (among many other files) a 61562048.wem file[3].
  3. I am then dragging the 61562048.wem file onto the WEMCompilerTool/bin/Release/WEMCompilerTool.exe file in this repo (commit 57742692, the latest at the time of writing; I have also tried using the actual latest release on the releases page (the one that has the included ffmpeg.exe executable), with exactly the same result, down to the SHA-256 hash below).
  4. A file named 61562048.wem.wav[4] is generated. It appears to be a 48000Hz, 16-bit, stereo WAV format file with a PCM datastream, but attempting to play it results in only white noise.

Relevant SHA-256 hashes: [1] NMSARC.761ACED1.pak: eeb0b78b850a671c34d2d7d9c1eddc1a5abe248b84edec1a9f4b3a05cd6332ab [2] NMS_AUDIO_PERSISTENT.BNK: 2ceef2c2dc594c8846793c530cf93f7eece21b4f8ebfa3cfda2ad7fb249a5e32 [3] 61562048.wem: 787ddb9bdd323a6ebda076428a826c8270e58388989f2166bd5babd9161525de [4] 61562048.wem.wav: dfd97520b3536974d7531678439b67c81f2654ea8011448eda3d5bbf989d1a07

It looks like there's a compressed datastream in the WAV file still, and indeed, comparing the WEM and the WAV shows that after an offset of 36 bytes in the WAV and 86 bytes in the WEM, the contents of each file are exactly the same to the end, showing that only the file header has changed and no decompression was actually performed.

Am I using this tool incorrectly?

EtiTheSpirit commented 2 years ago

No, that's just what the tool does when the WEM's format flag is set to use s16le encoding. I guess they started encoding audio. I just don't have the time to maintain this tool is the issue, so I can't deal with it any time soon. Sorry.

Sophira commented 2 years ago

No problem.

I've actually discovered in the meantime that there may be an issue with Monkeyman's BNK compiler as when I try to use it to repack the BNK files, it doesn't seem to do it correctly. As such, I can't be entirely certain that the WEM file was extracted correctly - so this might just be a corruption error before WEMConverter even gets involved.

Since all I'm currently looking to do is to replace audio anyway, I've started using your BNKRepacker tool instead.

Regardless, thank you for the tools! I'll leave it to you to decide whether you want to close this issue or not.