Luigi Auriemma

aluigi.org (ARCHIVE-ONLY FORUM!)
It is currently 19 Jul 2012 16:30

All times are UTC [ DST ]





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 
Author Message
 Post subject: Battlefield: Bad Company - Extract audio from .res
PostPosted: 11 Jan 2010 22:08 

Joined: 11 Jan 2010 21:51
Posts: 2
Hi.

Following on from this thread discussing .fbrb archives in Battlefield Bad Company.

Is it known how to extract the audio from the .res files? (I have posted an example below).

http://www.megaupload.com/?d=EFMAC3J7

It would appear one file is an index/header and the other holds the data.

Any help appreciated.


Top
 Profile  
 
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 11 Jan 2010 22:22 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
I don't have idea, I recognize nothing familiar in those 2 files


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 11 Jan 2010 23:18 

Joined: 11 Jan 2010 21:51
Posts: 2
Hmm.

I loaded up ea_logo_hd.res in Hex edit.

Image

By removing the selected header I was able to play the video back in Bink's Video tools

This is probably nothing special. But I thought I'd post anyway.


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 11 Jan 2010 23:51 

Joined: 13 Aug 2007 21:44
Posts: 4068
Location: http://aluigi.org
maybe they are just raw resources, this last one you saw is a bink texture while the other previouses 2 were something else audio related (VOAI_MercSupport_Alert_Sniper_Fire_S_02_waveDataSns_1.res is not raw pcm because it's noisy so it's probably compressed with a codec)


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 12 Jan 2010 20:19 

Joined: 16 Aug 2009 19:24
Posts: 29
Location: Austin, TX
Ok, got it worked out, warning this is going to be a little tedious unless someone automates it. I've tried this out with RU_radio_channel_04_Classic_WaveDataSns_1.res. unpack1943 and xma_test are on http://hcs64.com/vgm_ripping.html
  1. Using unpack1943 0.1, unpack the .res to ordinary XMA1:
    Code:
    unpack1943 RU_radio_channel_04_Classic_WaveDataSns_1.res out
  2. Using xma_test 0.6 or so, sanitize the XMA stream (just needs to correct sequence numbers):
    Code:
    xma_test out -1 -x out2
  3. Build a complete XMA file for use with xmaencode, I described the process >here<. You'll start by joining xma.head, out2, and bd.seek into out.xma, then you need to do some editing to correct the total RIFF size and data chunk size.
  4. Decode with xmaencode:
    Code:
    xmaencode out.xma /X out.wav
It has to be xmaencode because there are apparently some frames in there that towav chokes on, I don't know if xmaencode handles these correctly or if it just skips them, but it seems to produce good audio.

Note that this process is only going to work with stereo files, mono files will require a different header.


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 11 Feb 2010 15:59 

Joined: 16 Aug 2009 19:24
Posts: 29
Location: Austin, TX
Just wanted to give an update here, yesterday on XeNTaX (http://forum.xentax.com/viewtopic.php?p=35446#p35446) I worked this out finally, you can now use ea_multi_xma 0.1 and xma_test 0.7 on these files, and then use the rebuilt files with toWav.


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 26 Mar 2010 13:58 

Joined: 27 Nov 2009 20:34
Posts: 17
This is too good to be true! THANKS A HUGE BUNCH HCS - YOU'RE OUR MAN!!! :) :) :)

And BTW, the tool-collection OrangeC provided on Xentax can be used rather nicely to transform these files step by step. To make it even easier, I've rewritten the batch files into one single file. Below are links to all programs and both the bms and batch script!

However, it's not working properly with the BF:BC radio files! The end is cut - looks like at least a whole minute is missing! Maybe you have another idea, HCS?
Here's one of the res files: http://www.filefront.com/15936297/US_ra ... taSns_1.7z

Programs
(extract all files into the folder you want to decode *.res files in):
01. ea_multi_xma: http://hcs64.com/files/ea_multi_xma02.zip (if version has changed: http://hcs64.com/vgm_ripping.html)
02. xma_parse: http://hcs64.com/files/xma_parse08.zip (if version has changed: http://hcs64.com/vgm_ripping.html)
03. quickbms: http://aluigi.altervista.org/papers.htm#quickbms
04. toWAV: http://www.ctpax-x.ru/index.php?goto=files&down=24

Scripts and batches
05. addXMARIFFheader.bms (save text file as "addXMARIFFheader.bms"):
Code:
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\x00\x58\xa7\x00"

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

06. the batch file to directly decode all *.res in one folder (save text file as .bat file):
Code:
for %%i in (*.res) do "%CD%\ea_multi_xma.exe" %%i -o 0x00
ren *.res_stream1 *.str
for %%i in (*.str) do "%CD%\xma_test.exe" %%i  -1 -r %%~ni.xm
del *.str
for %%i in (*.xm) DO "%CD%\quickbms.exe" -o "%CD%\addXMARIFFHeader.bms" %%i "%CD%"
del *.xm
@towav.exe *.xma
del *.xma
Of course if you want to keep the XMA files (for backup reasons for example), just delete the last batch line.

If nothing happens...
... you probably got the offset in the above batch file wrong (first line). Try decoding after successively adding 8 bytes (0x04, 0x08, 0x0C, 0x10, 0x14, 0x18...)

Changing the sample rate and channels in the xmaRIFF header
Sample rate: Change the bytes at 0x24 of the data that's written to the memory file. It's the code "\x80\xbb" above (23rd and 24th place from the end). These are the most common sample rates:
48.000 Hz: \x80\xbb
44.100 Hz: \x44\xac
32.000 Hz: \x00\x7d
22.050 Hz: \x22\x56
16.000 Hz: \x80\x3e
Channels: 11th place from the end "\x02" = stereo, "\x01" = mono.


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 09 Jun 2010 01:37 

Joined: 09 Jun 2010 01:23
Posts: 2
I'm having some weird trouble converting audio files from bad company 2. If I pick a file from the Sound/Cutscenes/ folder (like cs21_WaveDataSns_1.res I used for testing) then as long as I modify the batch file to use -2 in xma_test.exe, I get a nice wav file out of it. But if I pick a similar sized file - 154k to 165k - from the VO folder (I used voai_idle_generic_scene12_redford_waveDataSns_1.res) then I just get garbage in the .wav.

I put a pause at the end of the batch file and looked at the output - no errors (unless I leave that -1 in xma_test.exe) and the # samples looks OK. File sizes look normal up until the towav step, where the VO file produces a far too small .wav.

I've also twiddled with the wav headers, different sample rates or mono/stereo, but no luck. The resulting clip is < 1 second of noise, so I don't think it's that.

I don't have any ideas what's going wrong. it seems to happen on the example in the OP, and I have the latest versions of the program. Anyone have a clue?

EDIT: If it helps I can upload the intermediate files - I switched off the del lines to test what sizes they were.


Top
 Profile  
 
 Post subject: Re: Battlefield: Bad Company - Extract audio from .res
PostPosted: 09 Jun 2010 18:51 

Joined: 09 Jun 2010 01:23
Posts: 2
Ignore me, I'm an idiot. For anyone else who has the same problem - double check that you're not a retard and definitely try every sample rate and mono/stereo. Surprisingly if you use the wrong one, it won't work.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 9 posts ] 

All times are UTC [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for: