Tutorial
Updated
How to swap audio in Unreal Engine 4 games
Because of @Kirby567fan idea I've been working on figuring out how to swap audio from Yoshi's Crafted World. And probably all UE4 games on Switch uses the same format for audio.
It can be achieved by doing app, but this tutorial is barebone as possible.
Example of what can be achieved:
How to unpack game:
https://gbatemp.net/threads/how-to-easy-extract-game-files-from-nsp-xci.534724/#post-8572631
It can be achieved by doing app, but this tutorial is barebone as possible.
Example of what can be achieved:
How to unpack game:
https://gbatemp.net/threads/how-to-easy-extract-game-files-from-nsp-xci.534724/#post-8572631
What you needPreparing game files to be modifiedSwapping fileCorrecting infoPacking
- - Audio files converted to RIFF (.wav).
- Hex Editor (I'm using HxD)
- UEViewer (http://www.gildor.org/en/projects/umodel#files)
First run umodel.
Show path to game's romfs folder included.
And rest check as showed lower (for v5 pack use Unreal Engine 4.20, for v7 pack use Unreal Engine 4.21)
And OK.
After few seconds it should show files. Go to All packages->Game
Find folder with audio. For our game background music is in
Code:All packages\Game\Assets\Sounds\BGM\Wave
We are searching for our audio that we want to modify, right click on it and "Export". Again right click and "save packages".
Now in umodel folder they should be folders named UmodelExport and UModelSaved.
For our game wav file unpacked to
Code:UmodelExport\Game\Assets\Sounds\BGM\Wave
Code:UmodelSaved\Game\Assets\Sounds\BGM\Wave
Check properties of *.wav file.
You need to convert size in bytes of wav file to Hex Little Endian.
Find any hex calculator. For 99% it will be Big Endian. How to convert this to Little Endian? By reversing bytes.
Code:Big Endian -> Little Endian (always 4 bytes for this tutorial, if our big endian value is lacking it, we are adding it at the end of file) 07 01 -> 01 07 00 00 0A 04 76 -> 76 04 0A 00 01 78 65 2A -> 2A 65 78 01 1 35 87 9C -> 9C 87 35 01
For example our file has size 10 584 046
Now converted value will look like:
Code:ByteSize -> Hex Big Endian -> Hex Little Endian 10584046 -> A17FEE -> EE 7F A1 00
How to check if you correctly calculated this number?
Open with hexeditor your *.uexp file and try to find these hex values. It should be found 2 times at the beginning of file next to each other.
- Open your unpacked by umodel original *.wav file with hex editor. Open also *.uexp file with this audio.
Find in *.uexp file 4 bytes after string "data".
Try to find these hex value at the beginning of file and remember it's position.
Next you need to highlight the same data in *.uexp file that are in whole original *.wav file (images are from *.uexp file)
----------------
Open with hex editor your audio that you want to use, highlight it all, copy it and paste to *.uexp file in place of highlighted data.
Now you need to copy first 4 bytes after "data" string in modifiex *.uexp file to place that you needed to remember and rewrite it.
Next you need to check properties of your new wav file and convert it's size to hex little endian as earlier.
Code:30682066 -> 1D42BD2 -> D2 2B D4 01
Now you need to swap in *.uexp file each one of these 2 values next to each other found earlier with these converted size of your new wav file.
Aaaaaaand.... Save it. - Open *.uasset file for your modified *.uexp file with the same name.
Now bring back size of old *.uexp file, substract 4 from it. Convert this number to hex little endian.
Code:10584259-4 = 10584255 10584255 -> A180BF -> BF 80 A1 00
Now check size of your modified *.uexp file, substract 4 from it's value and convert it to hex little endian.
Code:30682279-4 = 30682275 30682275 -> 1D42CA3 -> A3 2C D4 01
Save. - Everything about packing to *.pak file you have here (don't move *.pak file from it's original place if you want to continue modifying audio files. Copy it to unpacked archive of UnrealPak):
https://gbatemp.net/threads/how-to-unpack-and-repack-unreal-engine-4-files.531784/
You don't need to unpack whole game. Just create lista.txt, clean it, delete all lines except audio and put modified files to correct folders, in our game it will be
Code:UnrealPakSwitch\PJ033\Content\Assets\Sounds\BGM\Wave
And use Patch tab.
If you will do something wrong, game will crash.
Last edited by masagrator,