• Announcements

    • Detrux

      Site Relaunched   10/13/2016

      Welcome back to BFEditor.org! We've upgraded the forum software, removed the spammers, and improved security. Apologies for the downtime! Det
Xevin

Extracting Sound And Music Files From Bfbc2

53 posts in this topic

After a ton of research, I have completely figured out how to extract the audio files from Battlefield: Bad Company 2(BFBC2). I'm just going to post what I've figured out so far by reading the forums here and over at a few other places (xentax.com, aluigi.freeforums.org). This is my first post here, so please don't hurt me. Also apparently you can only extract one type of sound: WaveDataSns.

DISCLAIMER: I DID NOT create any of these tools, or discover anything new! I'm just posting this here for other people looking to do the same thing I did!

Programs You Will Need:

1.Xbox 360 ISO Extract (mirror) (created by somski)

2.ea_multi_xma (created by HCS) (http://hcs64.com/vgm_ripping.html)

3.xma_parse (created by HCS) (http://hcs64.com/vgm_ripping.html)

4.quickbms (created by Luigi Auriemma) (http://aluigi.org/papers.htm#quickbms)

5.ToWAV (created by Xplorer) (http://www.ctpax-x.ru/index.php?goto=files&show=24)

Prerequisites:

Average Computer Skills

Battlefield Bad Company 2 XBOX360 ISO

15-20GB free HD space

Step 1: Extract ISO

Run XBOX360ISOExtract.exe

Click "choose ISO-Folder"

Find folder with your BFBC2 ISO file

Click "choose destination"

Make New Folder "ExtractedISO"

Choose destination folder "ExtractedISO"

Click "Scan"

Click "Go"

Wait

Step 2: Program Prep

Extract all the remaining programs.

Put the following files into a new folder called "ExtractOmatic":

ea_multi_xma.exe

quickbms.exe

towav.exe

xma_test.exe

Step 3: Make .bms Files

Make a new text file named "fbrb.txt" in your "ExtractOmatic" folder

Paste the following text into it:

# Battlefield: Bad Company (script 0.1.3)
# script for QuickBMS http://aluigi.org/papers.htm#quickbms

endian big
comtype deflate
idstring "FbRB"
get SIZE long
savepos OFFSET
set MEM_FILE long 1
callfunction gzip_fbrb_sux

math OFFSET += SIZE
get SIZE asize
math SIZE -= OFFSET
goto OFFSET
set MEM_FILE long 2
callfunction gzip_fbrb_sux

get VER long MEMORY_FILE
get INFO_OFF long MEMORY_FILE
savepos NAME_BASE MEMORY_FILE
math INFO_OFF += NAME_BASE
goto INFO_OFF MEMORY_FILE
get FILES long MEMORY_FILE
for i = 0 < FILES
   get NAMEOFF long MEMORY_FILE
   get DUMMY long MEMORY_FILE
   get OFFSET long MEMORY_FILE
   get SIZE long MEMORY_FILE
   get XSIZE long MEMORY_FILE
   get NAMESZ long MEMORY_FILE

   savepos TMP MEMORY_FILE
   math NAMEOFF += NAME_BASE
   goto NAMEOFF MEMORY_FILE
   #getdstring NAME NAMESZ MEMORY_FILE
   get NAME string MEMORY_FILE
   goto TMP MEMORY_FILE

   log NAME OFFSET SIZE MEMORY_FILE2
next i

# fbrb sux, it specifies a wrong size for the gzip file in some archives (like ondemand_awards-00.fbrb)
# so when QuickBMS goes at its end to find the uncompressed size field it finds a zero... bad
startfunction gzip_fbrb_sux
   savepos TMP_OFF
   endian little
   get GZIP_SIGN short
   if GZIP_SIGN == 0x8b1f
       get CM byte
       get FLAGS byte
       get MTIME long
       get XFL byte
       get OS byte
       if FLAGS & 4
           get TMP short
           getdstring TMP TMP
       endif
       if FLAGS & 8
           get TMP string
       endif
       if FLAGS & 16
           get TMP string
       endif
       if FLAGS & 2
           get TMP short
       endif
       savepos TMP
       math SIZE += OFFSET
       math SIZE -= 4  # uncompressed size
       goto SIZE
       get XSIZE long
       math SIZE -= TMP
       if XSIZE < SIZE # so also if it's 0
           math XSIZE = SIZE
           math XSIZE *= 12    # enough?
       endif
       if MEM_FILE == 1
           clog MEMORY_FILE TMP SIZE XSIZE
       else
           clog MEMORY_FILE2 TMP SIZE XSIZE
       endif
   else
       if MEM_FILE == 1
           log MEMORY_FILE OFFSET SIZE
       else
           log MEMORY_FILE2 OFFSET SIZE
       endif
   endif
   goto TMP_OFF
   endian big
endfunction

Save it

Close it

Rename to "fbrb.bms"

(fbrb.bms created by Luigi Auriemma)

Make a new text file named "addheader_stereo.txt" in your "ExtractOmatic" folder

Paste the following text into it:

set MEMORY_FILE binary "\x52\x49\x46\x46\xb8\x59\xa7\x00\x57\x41\x56\x45\x66\x6d\x74\x20\x20\x00\x00\x00\x65\x01\x10\x00\xd6\x10\x00\x00\x01\x00\x00\x03\xe3\x9a\x00\x00\x80\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x00\x64\x61\x74\x61\xff\xff\xff\x70"

get NAME basename
get SIZE asize
string NAME += ".xma"

append
log MEMORY_FILE 0 SIZE
append
math SIZE += 60
log NAME 0 SIZE MEMORY_FILE

Save it

Close it

Rename to "addheader_stereo.bms"

(created by AlphaTwentyThree)

Make a new text file named "addheader_mono.txt" in your "ExtractOmatic" folder

Paste the following text into it:

set MEMORY_FILE binary "\x52\x49\x46\x46\xb8\x59\xa7\x00\x57\x41\x56\x45\x66\x6d\x74\x20\x20\x00\x00\x00\x65\x01\x10\x00\xd6\x10\x00\x00\x01\x00\x00\x03\xe3\x9a\x00\x00\x80\xbb\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x02\x00\x64\x61\x74\x61\xff\xff\xff\x70"

get NAME basename
get SIZE asize
string NAME += ".xma"

append
log MEMORY_FILE 0 SIZE
append
math SIZE += 60
log NAME 0 SIZE MEMORY_FILE

Save it

Close it

Rename to "addheader_mono.bms"

(created by AlphaTwentyThree)

Step 4: Extract FBRB Files

Run quickbms.exe

Browse to your "ExtractOmatic" folder and load "fbrb.bms"

Browse to "ExtractedISO\dist\xenon\streaming_sounds-00.fbrb"

Make new folder "ExtractedFBRB"

Select folder "ExtractedFBRB"

Let it Rip!

NOTE: Rinse and Repeat for other .fbrb files as needed.

NOTE: Not all .fbrb files contain sound files.

NOTE: Extracting all .fbrb into the "ExtractedFBRB" folder will result in a nice and tidy folder tree.

Step 5: Make Duplicates

Copy (CTRL-C) the "ExtractedFBRB\Sound" folder.

Make a new folder called "ExtractedSound"

Open the "ExtractedSound" folder

Paste (CTRL-V)

Paste again (CTRL-V) (Trust me damnit!)

Rename one of the "Sound" folders "Sound-stereo"

Rename the other "Sound" folder "Sound-mono"

NOTE: The reason for the duplicate "Sound" folders is that there is no way to determine if a .res file is stereo or mono. If a stereo file is extracted as mono it will 1) emit static, or 2) play nothing at all. This also applies to the inverse. To solve this we are going to processes the whole "Sound" file twice; once as Stereo and then again as Mono. Then we can delete the static files on the Mono folder and overwrite the static files in the Stereo folder using the Mono files.

Step 6: Make Batch Files

Make a new text file named "RUN - Stereo.txt" in your "ExtractOmatic" folder

Paste the following text into it:

for /r %%i in (*.res) do "%CD%\ea_multi_xma.exe" "%%i" -o 0x00
for /r %%i in (*.res_stream1) do ren "%%i" *.str
for /r %%i in (*.str) do "%CD%\xma_test.exe" "%%i" -2 -r "%%i.xm"
del /s *.str
for /r %%i in (*.xm) DO "%CD%\quickbms.exe" -o "%CD%\addheader_stereo.bms" "%%i" "%%~dpi\"
del /s *.xm
for /r %%i in (*.xma) do (
"%CD%\towav.exe" "%%i" 
move *.wav "%%~dpi/"
)
del /s *.xma
del /s *.res

Save it

Close it

Rename to "RUN - Stereo.bat"

(created by AlphaTwentyThree, modified by Xevin)

Make a new text file named "RUN - Mono.txt" in your "ExtractOmatic" folder

Paste the following text into it:

for /r %%i in (*.res) do "%CD%\ea_multi_xma.exe" "%%i" -o 0x00
for /r %%i in (*.res_stream1) do ren "%%i" *.str
for /r %%i in (*.str) do "%CD%\xma_test.exe" "%%i" -2 -r "%%i.xm"
del /s *.str
for /r %%i in (*.xm) DO "%CD%\quickbms.exe" -o "%CD%\addheader_mono.bms" "%%i" "%%~dpi\"
del /s *.xm
for /r %%i in (*.xma) do (
"%CD%\towav.exe" "%%i" 
move *.wav "%%~dpi/"
)
del /s *.xma
del /s *.res

Save it

Close it

Rename to "RUN - Mono.bat"

(created by AlphaTwentyThree, modified by Xevin)

Step 7: The Final Fontier

Cut (CTRL-X) your "Sound-stereo" folder

Paste (CTRL-V) into your "ExtractOmatic" folder

Run "RUN - Stereo.bat"

Wait...

Cut (CTRL-X) your "Sound-stereo" folder

Paste (CTRL-V) back to where it was

Cut (CTRL-X) your "Sound-mono" folder

Paste (CTRL-V) into your "ExtractOmatic" folder

Run "RUN - Mono.bat"

Wait...

Cut (CTRL-X) your "Sound-mono" folder

Paste (CTRL-V) back to where it was

Begin deleting the static files out of the "Sounds-mono" folder

NOTE: There are many more Mono files then Stereo files. Thus less things to delete in the Mono Folder.

Cut (CTRL-X) the folders INSIDE "Sounds-mono"

Paste (CTRL-V) the folders INTO "Sounds-stereo"

Click Overwrite ALL

Rename the "Sounds-stereo" folder to "Sounds - Extracted"

Enjoy!

If you have any questions I probably can't answer them, but I'll try.

Credits:

Luigi Auriemma

HCS

AlphaTwentyThree

Xplorer

somski

Edited by Xevin

Share this post


Link to post
Share on other sites

Hmm. OK so I only found out how to convert the "WaveDataSns" files with the above technique. So I started trying to figure out how to do the "Wave" files too.

I appears you have to cut off the first 32bytes in each file when processing with ea_multi_xma.exe by using 0x20 in the batch file. I'm testing this now to make sure it works for all the "Wave" files...

[edit]I found some that need the first 30 cut off. (0x1C)[/edit]

[edit]Ok. It's random. From what I can tell there are actually multiple audio files inside each "Wave.res" file. For instance in \Sound\Vehicles\Land\T90\T90_Start_Idle_Stop_Wave.res it contains 3 sound files. Obviously it's the engine start, idle and stop sound. The first offset cut is at 0x1C, the second at 0x4934 and the third is at 0xB414. I don't think the ea_multi_xma.exe program can search for hex strings so, ripping the "Wave.res" files remains a manual thing unless someone knows something I don't (pleasepleasepleaseplease...). AFAIK the hex string that denotes the start of a new audio file is:

48 00 00 0C 13 00 bb 80 40 01

Anyone know a command line program that can search a file for a string then output the location of the start of the string to a variable that I can use in the batch file?[/edit]

Edited by Xevin

Share this post


Link to post
Share on other sites

For some odd reason, when i start ea_multi_xma.exe. It just sits there doing nothing. This happens when i have the correct offset. I know it is the correct offset because any other offset produces errors. Does it take a long time for ea_multi_xma.exe to work on the file?

Share this post


Link to post
Share on other sites

Hmm. I've had ea_multi_xma refuse to load a file, but it would normally error out. It would only lock for me if I chose an offset that contained "00". OR I tried to extract a .res that was not an audio file. There are a few of those in the "Sound" folder. They are mostly less then 3kb. The only standard offsets I found for .res sound files were 0x00 0x20 0x1C and 0x60 (in order of most common to least common). If the offset is 0x1C it a multi-stream file. To extract the other streams from a 0x1C offset file you have to use a Hex editor and search for this string:

48 00 00 0C

Every time you find this string use the offset for "48" (H). There are typically 3 streams in a multi-stream file.

Also any .res can have either stereo or mono audio files. So I ended up using 8 different .bat files and 1 random .bat that I would edit on the fly with offsets and stereo/mono headers for the multi-stream (0x1C) files.

There are a few .res audio files that CANNOT be extracted. They are in a different format or something. I could find the "48 00 00 0C" string (mostly at 0x20) but they would just extract to a garbled mess. At first I thought it was because they were stereo and I was extracting mono, but after changing that, they still would extract garbled, or not at all.

After all was said and done, I extracted about 94% of the sound files. I got the sound files I needed. And I learned a lot along the way. I hope my experiences help other people.

[edit]Oh and for those who want it: BFBC2 - End Credits Music[/edit]

Edited by Xevin

Share this post


Link to post
Share on other sites

Oh well.

Ooh hey, I wonder if this could help clarify whether that WW2 Sarge says "Okay, you watch ahead Wyatt" as DICE's subtitler thinks, or "Okay, you watch ya head Wyatt" as I think he says (which makes sense because a guard tower nearly flattens the car immediately after he says this).

Edited by UberWazuSoldier

Share this post


Link to post
Share on other sites

Oh well.

Ooh hey, I wonder if this could help clarify whether that WW2 Sarge says "Okay, you watch ahead Wyatt" as DICE's subtitler thinks, or "Okay, you watch your head Wyatt" as I think he says (which makes sense because a guard tower nearly flattens the car immediately after he says this).

Here ya go man.

Edited by Xevin

Share this post


Link to post
Share on other sites

to Xevin

What do I do not so? I have made archive under your scheme and I try to recode remarks from game. But at me a problem. Sounds turn out accelerated why I do not know. I think that in all my system is guilty, but is not assured.

ExtractOmatic.exe

Sounds

Edited by Sfinks

Share this post


Link to post
Share on other sites

to Xevin

What do I do not so? I have made archive under your scheme and I try to recode remarks from game. But at me a problem. Sounds turn out accelerated why I do not know. I think that in all my system is guilty, but is not assured.

ExtractOmatic.exe

Sounds

Yeah... I'm not going to download an .exe from someone I don't know. Especially if he does not speak proper English. Also the extractOmatic is a folder containing the programs not an .exe, so that really makes me think you have a nice little virus and you want to give it away.

Share this post


Link to post
Share on other sites

Yeah... I'm not going to download an .exe from someone I don't know. Especially if he does not speak proper English. Also the extractOmatic is a folder containing the programs not an .exe, so that really makes me think you have a nice little virus and you want to give it away.

This is only one SFX packages from the WinRar to unpack deletes everything you do not need and there is only sound

Folder. dude, if I need help I'm so not a shit.

Here, then normal

Share this post


Link to post
Share on other sites

This is only one SFX packages from the WinRar to unpack deletes everything you do not need and there is only sound

Folder. dude, if I need help I'm so not a shit.

Here, then normal

These .res files are NOT from the XBOX 360 VERSION.

Share this post


Link to post
Share on other sites

These .res files are NOT from the XBOX 360 VERSION.

Clearly, the das. I have of Allstars. Then laid his times think that this is not correct.

If possible then to wav. Thx

Edited by Sfinks

Share this post


Link to post
Share on other sites

Only the Xbox 360 sounds can be converted to .wav - PC and PS3 use a different format, so it will not work to use those.

Share this post


Link to post
Share on other sites

Only the Xbox 360 sounds can be converted to .wav - PC and PS3 use a different format, so it will not work to use those.

I know it myself. What I have here is Battlefield.Bad.Company.2.PAL.X360-Allstars. and do not tell me did it wrong. Why this now somehow not right, I do not know, I beg to correct WAVs and if it works.

Edited by Sfinks

Share this post


Link to post
Share on other sites

I know it myself. What I have here is Battlefield.Bad.Company.2.PAL.X360-Allstars. and do not tell me did it wrong. Why this now somehow not right, I do not know, I beg to correct WAVs and if it works.

Maybe the PAL version has a different audio format? All I know is the .res files you uploaded do not have the "48 00 00 0C" string in the hex. It's a miracle they extract to the super speed audio files at all. I used an NTSC copy of the game to extract from and it works. As far as I can tell you did everything right. The only thing you are doing wrong is the .res files you are using.

If you don't mind my asking, what is your native language?

Share this post


Link to post
Share on other sites

I have all figured out. happened thanks. Now began studying MOH Beta. Surprisingly there is also a system that in BFBC. Unpack happened, but encode with ea_multi_xma no

Share this post


Link to post
Share on other sites

Any Idea where I can get the:

-Gun firing sounds

-Sounds for Impacts, Ear Buzzing/High Pitched Noise,

-Environmental Sounds like Trees, Birds etc

Thanks

Edited by loosebruce

Share this post


Link to post
Share on other sites

Any Idea where I can get the:

-Gun firing sounds

-Sounds for Impacts, Ear Buzzing/High Pitched Noise,

-Environmental Sounds like Trees, Birds etc

Thanks

Look in \Sound\Ambients

As for gun fire/explosion I believe these are dynamically rendered to account for echos etc. I haven'nt seen any files relating to them so far. I would be interested to know more.

Share this post


Link to post
Share on other sites

Hi guys!

Nice find, I hope! :)

I've got some errors pretty early in the process. (Call me stupid or anything) But the "fbrb.txt" paste I did doesnt look the same as in the topic at all. It's all mixed in notepad. Any ideas on how to get it correctly as it's supposed to be?

I tried to manually stack the code up as shown in the topic, but that didnt help either... After pressing "Save" in QuickBMS in my "\dist\xenon\ExtractedFBRB" -directory I get this error message: "Error: Invalid datatype at line 7"

Need help! This is the same with the other codes you're supposed to paste into Notepad and then rename to *.BMS. Dont u use notepad for pasting?

/Anders

Share this post


Link to post
Share on other sites

loosebruce,

Impact sounds - Sound\MAOISM\

Ear ring - not sure (might be rendered in game)

Guns firing - Sounds\Weapons\

-=ander=-,

Not sure what the problem is. Make sure you are using NOTEpad and not WORDpad. Still having issues? Try Notepad++.

Share this post


Link to post
Share on other sites

loosebruce,

Impact sounds - Sound\MAOISM\

Ear ring - not sure (might be rendered in game)

Guns firing - Sounds\Weapons\

-=ander=-,

Not sure what the problem is. Make sure you are using NOTEpad and not WORDpad. Still having issues? Try Notepad++.

Hey, it worked now!!! yey! Tried firefox instead, then it worked to paste correctly.

Ok, so now I've extracted all sounds-res files (I think), but there're no firing sounds except some in the weapons folder. Only 3p reload sounds.... How come??? Where're the firing sounds?

[EDIT]

So, now i've completed the whole procedure! But, almost ALL files are static... Any ways to fix them??? And the weapon fire sounds again.. Where the heck are they?

Edited by -=anders=-

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now