How to swap audio in Unreal Engine 4 games

Discussion in 'Switch - Tutorials' started by masagrator, Apr 8, 2019.

  1. masagrator
    OP

    masagrator Polish digger

    Member
    4
    Oct 14, 2018
    Poland
    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. :P

    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

    • - 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)
      upload_2019-4-8_23-33-35.
      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
      upload_2019-4-8_23-58-24.
      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.
      upload_2019-4-9_0-21-30.
      For our game wav file unpacked to
      Code:
      UmodelExport\Game\Assets\Sounds\BGM\Wave
      *.uexp file and *.uasset file are in
      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
      upload_2019-4-9_0-0-19.
      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.
      upload_2019-4-9_0-3-26.
    • 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".
      upload_2019-4-9_0-4-13.

      Try to find these hex value at the beginning of file and remember it's position.
      upload_2019-4-9_0-4-39.

      Next you need to highlight the same data in *.uexp file that are in whole original *.wav file (images are from *.uexp file)
      upload_2019-4-9_0-6-32.
      ----------------
      upload_2019-4-9_0-6-20.

      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.
      upload_2019-4-9_0-8-24.

      Next you need to check properties of your new wav file and convert it's size to hex little endian as earlier.
      upload_2019-4-9_0-10-4.

      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.
      upload_2019-4-9_0-11-40.

      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.
      upload_2019-4-9_0-12-55.

      Code:
      10584259-4 = 10584255
      10584255 -> A180BF -> BF 80 A1 00
      Find it in *.uasset file with hex editor.
      upload_2019-4-9_0-14-12.

      Now check size of your modified *.uexp file, substract 4 from it's value and convert it to hex little endian.
      upload_2019-4-9_0-15-3.

      Code:
      30682279-4 = 30682275
      30682275 -> 1D42CA3 -> A3 2C D4 01
      Paste it in place of highlighted value in *.uasset file.
      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. :P
     
    Last edited by masagrator, Apr 12, 2019
    Dartz150 and hippy dave like this.
  2. Kirby567fan

    Kirby567fan Advanced Member

    Newcomer
    3
    Jan 6, 2018
    Morocco
    Last edited by Kirby567fan, Apr 9, 2019
  3. xstationbr

    xstationbr Advanced Member

    Newcomer
    2
    Dec 30, 2015
    Brazil
    Hummm... maybe now can i play DOOM in Portuguese BR? Cause the game ROM have AUDIO PT BR, but Nintendo dont allow us change console to Brasil Country. Just Portuguese Portugal Country.
    Waiting to anyone found a way.
    Sad..
     
  4. masagrator
    OP

    masagrator Polish digger

    Member
    4
    Oct 14, 2018
    Poland
    If you want a language, write to me. I already implemented Polish Translation to this game.
    But not audio.
     
    Last edited by masagrator, Apr 12, 2019
    xstationbr likes this.
  5. xstationbr

    xstationbr Advanced Member

    Newcomer
    2
    Dec 30, 2015
    Brazil
    Thank you but is not POLISH, is Portuguese Audio, from Portuguese Brazil.
    If you know an way to access the Default .ini setings on this game to SWITCH and change from English to PT-BR ou PORTUGUESE i will be so greatfully to you.
    I dont know any way to explore files inside XCI to try by my self an way to test but if you know. thank you. show us how to do.
     
  6. masagrator
    OP

    masagrator Polish digger

    Member
    4
    Oct 14, 2018
    Poland
    There are two ways to do it: modify exefs or decrypt language files, swap it and encrypt again (every language has different key).
    I will try to check today.
     
Loading...