Audio modding; changing loop points / adding longer tracks
Feb 19, 2019 11:36:30 GMT 10
FluffyQuack, ReiKaz, and 10 more like this
Post by archerpz on Feb 19, 2019 11:36:30 GMT 10
what this guide is for
specifically for the DLC Soundtrack (it's what I use)
using .wem files that are larger/smaller than the track you want to replace
changing loop points, and how they work (or how I think they work)
files that we'll be changing
natives\x64\sectionroot\sound\wwise\music_dlc_classic.bnk.2.x64 (loop points)
natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64 (longer/shorter replacement tracks)
natives\x64\streaming\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64 (where the tracks go)
what you should already know for this guide
how to extract .pak files
how to create .wem files (or have your replacement .wem file)
which audio file you want to replace, and it's name/id (numbers)
things you need
a hex editor (I'm using 010 Editor but any hex editor should do, but preferably it has bookmark functionality)
wwiseutil-gui
audacity or whatever audio editor you prefer that works for you
...
in this guide I'll be replacing Mr X's theme with American Football - Never Meant
the track that plays for Mr X in the Original Soundtrack DLC is '669052692'
using larger/smaller .wem files
finding the loop points
changing the loop points
example for Remake Soundtrack (Mr X Theme)
additional findings/stuff
specifically for the DLC Soundtrack (it's what I use)
using .wem files that are larger/smaller than the track you want to replace
changing loop points, and how they work (or how I think they work)
files that we'll be changing
natives\x64\sectionroot\sound\wwise\music_dlc_classic.bnk.2.x64 (loop points)
natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64 (longer/shorter replacement tracks)
natives\x64\streaming\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64 (where the tracks go)
what you should already know for this guide
how to extract .pak files
how to create .wem files (or have your replacement .wem file)
which audio file you want to replace, and it's name/id (numbers)
things you need
a hex editor (I'm using 010 Editor but any hex editor should do, but preferably it has bookmark functionality)
wwiseutil-gui
audacity or whatever audio editor you prefer that works for you
...
in this guide I'll be replacing Mr X's theme with American Football - Never Meant
the track that plays for Mr X in the Original Soundtrack DLC is '669052692'
using larger/smaller .wem files
{expand}for this we need wwiseutil and a hex editor
and have your replacement track ready (give it the same name as the track you'll be replacing, in the case of this guide that's '669052692.wem' -note; I'm not sure if you have to give it the same name)
let's start by making some backups and changing the file extension so we can open it with wwiseutil
in this directory 'natives\x64\streaming\sectionroot\sound\wwise\'
now we can open the .pck file with wwiseutil, locate '669052692' and select it
then click on 'Replace', and browse for your replacement file
the column 'Replacing with' should have '669052692.wem' next to the original track, '30.wem'
then save as 'File Package (*.pck)'
give it a different name (don't save over the one that's open), I gave it the name music_dlc_classic_modded
note how the offsets have changed for the files following the track we replaced, and ofcourse the file size of the track we replaced the original with has changed too
now we can close wwiseutil, open the directory 'natives\x64\sectionroot\sound\wwise'
and make some more backups
using a hex editor, open up both the .pck file you just saved and the music_dlc_classic.pck.3.x64 file
natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64
natives\x64\streaming\sectionroot\sound\wwise\music_dlc_classic_modded.pck
compare both files, it should look something like this
up until the point music_dlc_classic.pck.3.x64 ends, the file is mostly the same, the differences are the offsets of the new differently sized .pck file
now we need to copy the stuff our new 'music_dlc_classic_modded.pck' onto the 'music_dlc_classic.pck.3.x64' we have open
I just manually select from the start of the file up to the point where you can see 'RIFFL..' but you could also select the range starting from "0" and ending at "3D4h"
copy, then select all in the 'music_dlc_classic.pck.3.x64', paste over it
now compare the files again, if you did everything correct both files are the same until the smaller file ends
save the 'natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64' file
rename 'music_dlc_classic_modded.pck' in 'natives\x64\streaming\sectionroot\sound\wwise\' to 'music_dlc_classic.pck.3.x64'
and have your replacement track ready (give it the same name as the track you'll be replacing, in the case of this guide that's '669052692.wem' -note; I'm not sure if you have to give it the same name)
let's start by making some backups and changing the file extension so we can open it with wwiseutil
in this directory 'natives\x64\streaming\sectionroot\sound\wwise\'
now we can open the .pck file with wwiseutil, locate '669052692' and select it
then click on 'Replace', and browse for your replacement file
the column 'Replacing with' should have '669052692.wem' next to the original track, '30.wem'
then save as 'File Package (*.pck)'
give it a different name (don't save over the one that's open), I gave it the name music_dlc_classic_modded
note how the offsets have changed for the files following the track we replaced, and ofcourse the file size of the track we replaced the original with has changed too
now we can close wwiseutil, open the directory 'natives\x64\sectionroot\sound\wwise'
and make some more backups
using a hex editor, open up both the .pck file you just saved and the music_dlc_classic.pck.3.x64 file
natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64
natives\x64\streaming\sectionroot\sound\wwise\music_dlc_classic_modded.pck
compare both files, it should look something like this
up until the point music_dlc_classic.pck.3.x64 ends, the file is mostly the same, the differences are the offsets of the new differently sized .pck file
now we need to copy the stuff our new 'music_dlc_classic_modded.pck' onto the 'music_dlc_classic.pck.3.x64' we have open
I just manually select from the start of the file up to the point where you can see 'RIFFL..' but you could also select the range starting from "0" and ending at "3D4h"
copy, then select all in the 'music_dlc_classic.pck.3.x64', paste over it
now compare the files again, if you did everything correct both files are the same until the smaller file ends
save the 'natives\x64\sectionroot\sound\wwise\music_dlc_classic.pck.3.x64' file
rename 'music_dlc_classic_modded.pck' in 'natives\x64\streaming\sectionroot\sound\wwise\' to 'music_dlc_classic.pck.3.x64'
finding the loop points
{expand}I already have the .wem file converted, but I forgot to cut off a part of the song at the start, and the end (we can fix this in the music_dlc_classic.bnk.2.x64 file)
using audacity I tried to find a point in the song that could be looped
zooming in, and a bit of using the timeshift tool later, we can see it's a pretty good fit (I flipped left and right channel in the second track to be able to align it better)
this is the track and the timecodes/duration we need (in milliseconds)
- 9405 is the part of the song I want to cut off (if you edit the track before so it starts at 0:00:00.000 you can put 0 here and in music_dlc_classic.bnk.2.x64
- 29996 is the 'A part', this part plays once and then the 'B part' loops over and over
- 39401 is the part of the song I cut off + the 'A part' (again, if the track you want to replace starts at 0:00:00.000, this value and the 'A part' will be the same value)
- 173554 is the 'B part' of the song
- 55427 is the part of the song that's cut off, just like the 9405 ms at the start of the song
- 228981 is the part that's cut off + the 'B part'
- 268382 is the total duration of the song
using audacity I tried to find a point in the song that could be looped
zooming in, and a bit of using the timeshift tool later, we can see it's a pretty good fit (I flipped left and right channel in the second track to be able to align it better)
this is the track and the timecodes/duration we need (in milliseconds)
- 9405 is the part of the song I want to cut off (if you edit the track before so it starts at 0:00:00.000 you can put 0 here and in music_dlc_classic.bnk.2.x64
- 29996 is the 'A part', this part plays once and then the 'B part' loops over and over
- 39401 is the part of the song I cut off + the 'A part' (again, if the track you want to replace starts at 0:00:00.000, this value and the 'A part' will be the same value)
- 173554 is the 'B part' of the song
- 55427 is the part of the song that's cut off, just like the 9405 ms at the start of the song
- 228981 is the part that's cut off + the 'B part'
- 268382 is the total duration of the song
changing the loop points
{expand}starting in the directory 'natives\x64\sectionroot\sound\wwise'
create some backups of the original files (something like this)
now open 'music_dlc_classic.bnk.2.x64' with a hex editor (I'll be using 010 editor)
search for a 'Signed Int (i32)', and enter the track id (in this case 66905269, Mr X)
you should get 4 results. incase you get 0 results, change the Endian to Little Endian
then select all groups of 4 bytes, and bookmark them with a color (the colors i'll be using allign with the ones used in the previous screenshot of the track in audacity)
screenshot on the left;
bookmark these 4 clusters of 8 bytes
the values seem to be something like "-ms to cut off from start of song" | "ms to cut off from start of song" | "-ms (total duration of song minus A part)" | "ms total duration of the song"
screenshot on the right;
this bit of text 'HÖ»[' seems to be followed by a loop section, or 'parts'
directly above, seperated by one line, is the same value (or close to the same value), both need to be replaced
screenshot on the left;
bookmark the first 'loop' / the 'A part' (this is the value minus the part that's cut off from the song in milliseconds)
screenshot on the right;
bookmark another 4 sets of 8 bytes
the values seem to be something like "-ms starting point of the 'B part'" | "ms starting point of the 'B part'" | "-ms end point of the 'B part'" | "ms total duration of the song"
the next part is the part that gave me headaches, finding these 4 bytes, and figuring out what they do, these 4 ****ing bytes...
as you can see in the Inspector, these 4 bytes have a float value of -0.9999847
this seems to be a volume modifier of some sort, without changing this the song will cut off at the point the original 'B part' ended
so if you want to edit another track, and it cuts off for seemingly no reason whatsoever, try looking for a a float value of close to "-1.0" in a similar location
anyway, select these 4 bytes, then in the inspector click on 'Float' then double click on it, and enter 0
screenshot on the right;
mark these 2 sets of 8 bytes. this is the 'B part' (note the 'HÖ»[' text again)
now it's just a matter of plugging in the values we marked, go through each section (either by selecting all the bytes or clicking infront of the first byte that starts the section)
every value we change now, and basically every value that's in milliseconds, is going to be a 'Double'
I'm only going to show one screenshot for this, this thread is already way too long
and lastly, here is an overview of the changed values (and to which value the clusters of 8 bytes were changed)
now all that's left is saving the file and testing to see if it works ingame
(obligatory video below)
example of what having a track that's 2 minutes long (or 120000 ms) and that loops over and over from start to finish would look like;
create some backups of the original files (something like this)
now open 'music_dlc_classic.bnk.2.x64' with a hex editor (I'll be using 010 editor)
search for a 'Signed Int (i32)', and enter the track id (in this case 66905269, Mr X)
you should get 4 results. incase you get 0 results, change the Endian to Little Endian
then select all groups of 4 bytes, and bookmark them with a color (the colors i'll be using allign with the ones used in the previous screenshot of the track in audacity)
screenshot on the left;
bookmark these 4 clusters of 8 bytes
the values seem to be something like "-ms to cut off from start of song" | "ms to cut off from start of song" | "-ms (total duration of song minus A part)" | "ms total duration of the song"
screenshot on the right;
this bit of text 'HÖ»[' seems to be followed by a loop section, or 'parts'
directly above, seperated by one line, is the same value (or close to the same value), both need to be replaced
screenshot on the left;
bookmark the first 'loop' / the 'A part' (this is the value minus the part that's cut off from the song in milliseconds)
screenshot on the right;
bookmark another 4 sets of 8 bytes
the values seem to be something like "-ms starting point of the 'B part'" | "ms starting point of the 'B part'" | "-ms end point of the 'B part'" | "ms total duration of the song"
the next part is the part that gave me headaches, finding these 4 bytes, and figuring out what they do, these 4 ****ing bytes...
as you can see in the Inspector, these 4 bytes have a float value of -0.9999847
this seems to be a volume modifier of some sort, without changing this the song will cut off at the point the original 'B part' ended
so if you want to edit another track, and it cuts off for seemingly no reason whatsoever, try looking for a a float value of close to "-1.0" in a similar location
anyway, select these 4 bytes, then in the inspector click on 'Float' then double click on it, and enter 0
screenshot on the right;
mark these 2 sets of 8 bytes. this is the 'B part' (note the 'HÖ»[' text again)
now it's just a matter of plugging in the values we marked, go through each section (either by selecting all the bytes or clicking infront of the first byte that starts the section)
every value we change now, and basically every value that's in milliseconds, is going to be a 'Double'
I'm only going to show one screenshot for this, this thread is already way too long
and lastly, here is an overview of the changed values (and to which value the clusters of 8 bytes were changed)
now all that's left is saving the file and testing to see if it works ingame
(obligatory video below)
example of what having a track that's 2 minutes long (or 120000 ms) and that loops over and over from start to finish would look like;
example for Remake Soundtrack (Mr X Theme)
{expand}some documentation for the Remake Soundtrack's 'music_resident.bnk.2.x64' file
the easiest way to replace the theme is to only replace track '881034229'
and edit the bnk file so track '41740675' doesn't play
so, once you have replaced '881034229' with your song in natives\x64\streaming\sectionroot\sound\wwise\music_resident.pck.3.x64
and fixed natives\x64\sectionroot\sound\wwise\music_resident.pck.3.x64 with the new offsets,
open natives\x64\sectionroot\sound\wwise\music_resident.bnk.2.x64
just like for the Original Soundtrack, search for the track id as a Signed Int (i32)
but this time, we need to change the intro track, '41740675', first
like this;
change those 4 sets of 8 bytes, every value that we change is a Double, no Floats this time
0
0
-8586.97916666667
8586.97916666667 (unchanged)
that should take care of that song not playing anymore ingame, leaving only track '881034229' to play for Mr X
search for '881034229', again, Signed Int (i32)
below is a bit of explanation of the structure, seems to be the opposite of the order in the Original Soundtrack
(by order I mean the entire sections, the bottom section plays first ONCE, then the top section LOOPS)
(the values in this screenshot are the ones used in the 'LEON!' mod)
all that's left now is to plug in the values, all as Doubles
the values below are for an example song that's 2 minutes long, and loops from start to finish
the easiest way to replace the theme is to only replace track '881034229'
and edit the bnk file so track '41740675' doesn't play
so, once you have replaced '881034229' with your song in natives\x64\streaming\sectionroot\sound\wwise\music_resident.pck.3.x64
and fixed natives\x64\sectionroot\sound\wwise\music_resident.pck.3.x64 with the new offsets,
open natives\x64\sectionroot\sound\wwise\music_resident.bnk.2.x64
just like for the Original Soundtrack, search for the track id as a Signed Int (i32)
but this time, we need to change the intro track, '41740675', first
like this;
change those 4 sets of 8 bytes, every value that we change is a Double, no Floats this time
0
0
-8586.97916666667
8586.97916666667 (unchanged)
that should take care of that song not playing anymore ingame, leaving only track '881034229' to play for Mr X
search for '881034229', again, Signed Int (i32)
below is a bit of explanation of the structure, seems to be the opposite of the order in the Original Soundtrack
(by order I mean the entire sections, the bottom section plays first ONCE, then the top section LOOPS)
(the values in this screenshot are the ones used in the 'LEON!' mod)
all that's left now is to plug in the values, all as Doubles
the values below are for an example song that's 2 minutes long, and loops from start to finish
additional findings/stuff
{expand}screenshots are from 'music_dlc_classic.bnk.2.x64' but they apply to the Remake Soundtrack too
this is pretty handy to have, as I've used it in the "Mr. X Theme (North American Version)" mod
this is how you can have a segment keep playing while restarting the segment (or starting the next loop if you're editing the part that only plays once)
the 8 bytes after 'HÖ»[' define when the loop/segment ends, and it either goes to the next track (if an A part), or restarts the loop (if a B part or simple single segment looping track)
the 8 bytes right above it define how long the track will actually play for
this is pretty useful for crossfading tracks, or if you have a track/segment that can overlap
(advised not to go overkill, like having a track play for 50000 ms and restarting the loop after 10000 ms)
some tracks have the A and B parts flipped, so the bottom section plays before the top section
a lot of tracks in the Original Soundtrack have volume modifiers (fading points after x duration in seconds) which is most likely used to crossfade loops
the drawback is that no matter what values you plug in for the loop points, the song will "cut-off" after the original duration
the only way I know to find those values is to look for them manually (move over byte per byte in the section of the track, starting after the total duration, and look for a float value that is the original duration of the segment in seconds)
most of the time the volume modifier is "FF FE 7F BF", so you can look for that hex value and see if there's any occurences in the track you're editing
but some times there's more than one multiplier, as you can see in the next example
the following image is an example of the S.T.A.R.S. Office song from the Original Soundtrack
this track is also a good example of the loop/segment sections not being lined up each other (with one line in between, but same column starting position) (the 8 bytes after 'HÖ»[')
those values are marked in red
the values marked in green seem to be points in the song (in seconds, float) after which a volume change happens (a negative multiplier? float value) marked in white
changing the white sections to '0' (zero out the 4 bytes or enter 0 as a float value) should do the trick
below is an example of Mr X's theme in the Original Soundtrack
this section doesn't exist in the Remake Soundtrack for Mr X's theme
this is pretty handy to have, as I've used it in the "Mr. X Theme (North American Version)" mod
this is how you can have a segment keep playing while restarting the segment (or starting the next loop if you're editing the part that only plays once)
the 8 bytes after 'HÖ»[' define when the loop/segment ends, and it either goes to the next track (if an A part), or restarts the loop (if a B part or simple single segment looping track)
the 8 bytes right above it define how long the track will actually play for
this is pretty useful for crossfading tracks, or if you have a track/segment that can overlap
(advised not to go overkill, like having a track play for 50000 ms and restarting the loop after 10000 ms)
some tracks have the A and B parts flipped, so the bottom section plays before the top section
a lot of tracks in the Original Soundtrack have volume modifiers (fading points after x duration in seconds) which is most likely used to crossfade loops
the drawback is that no matter what values you plug in for the loop points, the song will "cut-off" after the original duration
the only way I know to find those values is to look for them manually (move over byte per byte in the section of the track, starting after the total duration, and look for a float value that is the original duration of the segment in seconds)
most of the time the volume modifier is "FF FE 7F BF", so you can look for that hex value and see if there's any occurences in the track you're editing
but some times there's more than one multiplier, as you can see in the next example
the following image is an example of the S.T.A.R.S. Office song from the Original Soundtrack
this track is also a good example of the loop/segment sections not being lined up each other (with one line in between, but same column starting position) (the 8 bytes after 'HÖ»[')
those values are marked in red
the values marked in green seem to be points in the song (in seconds, float) after which a volume change happens (a negative multiplier? float value) marked in white
changing the white sections to '0' (zero out the 4 bytes or enter 0 as a float value) should do the trick
below is an example of Mr X's theme in the Original Soundtrack
this section doesn't exist in the Remake Soundtrack for Mr X's theme