Jump to content

Extracting Wav Sound Files


Recommended Posts

It's quite possible to extract the wav sound files from the .bank files. I'm listening to the menu .wav music as we speak. ;)

Thanks to Nemon's great tool for extracting the bundle, if you look at the xml file

\data\sound\music\menu_music\menu_music_wave.xml

for example:

<?xml version="1.0" encoding="iso-8859-1" ?>

- <wavebank name="menu_music_wave" dir="data/sound/music/menu_music/" size_before="66276846" size="18639744" compression="28 %" xmlns:xi="x">

<wave name="menu_music01" file="menu_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="36286068" size="10205544" compression="28 %" bank="menu_music_wave.bank" offset="0" />

<wave name="outro_music01" file="outro_music01.wav" stream="true" file_priority="low" quality="44100 adpcm" size_before="29990778" size="8434200" compression="28 %" bank="menu_music_wave.bank" offset="10205544" />

</wavebank>

you can see the offset, this is in bytes. So I hacked together a little Java program that opens the .bank file as a stream, opens bytes 0 through 10205544, and saves this chunk as a .wav file. Here's the java code:

import java.io.*;


public class main

{

	public static void main(String args[]) throws IOException

	{

		try

		{

		FileInputStream fis = new FileInputStream ("menu_music_wave.bank");

		FileOutputStream fos = new FileOutputStream ("output.wav");


		byte[] buffer = new byte[10205544];

		fis.read(buffer, 0, 10205544);

		fos.write(buffer);

		fos.close();

		fis.close();

		}

		catch(IOException e)

		{

			System.err.println("Could not read file!");

		}

	}

}

It's REALLY simple. Anyway, I'm sure somebody else can make a nice GUI and so on. If nobody is up to it, I could certainly write something here this weekend maybe. Thanks again Nemon, you rock dude! :D

Link to comment
Share on other sites

  • Replies 52
  • Created
  • Last Reply

Top Posters In This Topic

Well, it's a pretty simple example. I'm going to see about maybe making a C++ executable version with features and such....

If you have the JRE, you can save the program there and test it out by putting the .bank file in the same directory. It's basically just an example though, nothing major at this point. ;)

Link to comment
Share on other sites

Wow firefly2442, that's outstanding! I thought things would be encrypted and such maknig this much more of a chore, if not nearly impossible... A nice little resource extractor/compiler will really get things rolling if there's not something hidden elswhere to styme modding.

Be nice if GRAW had a Ghost Recon like mod path, or is that really necessery? Could we for exampler compile alternative resources in new bundle files that are pointed to by an xml file? And/or are resources in an open directory path read instand of what's in a bundle file?

:)

Edited by Waika
Link to comment
Share on other sites

Here's a little Python script. It's very basic but it gets the job done. It asks you for the .bank file that you want to open. Then it asks you for the corresponding .xml file that goes with it. Then it extracts the .wav files. Pretty simple.


# Script that can open and extract .bank files for Ghost Recon: Advanced Warfighter

#

# TODO: Add files and recompile a .bank file and recreate the required xml file.

#

# http://www.rivetcode.com

# Author: firefly2442

#

# Version: 0.1

#

# Requirements:

# 1) Python (www.python.org) ... it's free!

# 2) The extracted contents of your bundle, thanks to Nemon for his great bundle extractor tool!


from Tkinter import *

from tkFileDialog import *


print "Please select the .bank music file you wish to extract."

print "-------------------------------------------------------"


bank_file = askopenfilename(filetypes=(('.bank music file', '*.bank'),('All files', '*')))


print "Location of .bank file:"

print bank_file


print "Please select the _wave.xml file that goes with the .bank file."


xml_file = askopenfilename(filetypes=(('.xml file', '*_wave.xml'),('All files', '*')))


print "Location of .xml file:"

print xml_file



# open and parse XML file

input = open(bank_file, 'rb') #rb for read in binary

for line in open(xml_file).readlines():

	if (line.find('file=') != -1):

		output = open(line[line.find('file=')+6:line.find('stream')-2], 'wb')

		output.write(input.read(int(line[line.find('size=')+6:line.find('compression')-2])))

		output.close()

input.close()


print "All files saved and processed!"

If you need any help, let me know. Make sure you have python installed before you run the script otherwise it won't work. Enjoy! :)

Link to comment
Share on other sites

Ahh, well, the bundled files are different than the .bank files. I believe Nemon has gotten his bundle extractor to recompile them... not sure though. As for the bank files, yes, that's the next program that I'll be doing. You can add wav files and it will create the bank file as well as modify and edit the corresponding XML file. :)

Link to comment
Share on other sites

Hi all

It's quite an honor to see people so determined to put your work on the autopsy table.

When you guys start picking the weapons sound files apart in attempts to mod new weapons (I of course hope you're happy with my work on the sound of the existing ones and leave them as they are) I'd be happy to answer any questions you might have - as time allows.

I bet it all becomes fairly obvious once you extract the .wav files and look at the *_sound.xml files to see how they all fit together, but anyway. For all it's worth I can share my sound design philosophies so that your modding creations fit into the game seamlessly not only on the technical level, but on the artistic as well.

Link to comment
Share on other sites

GRiN_desmond22- Thanks! Great work putting everything in xml files, makes it really easy to mod. ;)

So now i just want to learn how to repack the files ive edited.. :D

Oh wait, I just tried to extract the 50cal sounds, but nothing extracts.. Ive tried voices and music, and that worked, but extracting these 50cal sounds didnt.

Edited by -=anders=-
Link to comment
Share on other sites

GRiN_desmond22- Thanks! Great work putting everything in xml files, makes it really easy to mod. ;)

So now i just want to learn how to repack the files ive edited.. :D

Oh wait, I just tried to extract the 50cal sounds, but nothing extracts.. Ive tried voices and music, and that worked, but extracting these 50cal sounds didnt.

First off - since I haven't programmed the extract program you're using, I am really not the guy to ask for support when it doesn't work as it should.

Secondly - has anyone else successfully exctracted a weapon .bank file? If not, here are some thoughts on why it won't work:

Voices are all in mono (and all voices in any given .bank file are all the same quality), and music is all in stereo (and here too, all files in any given .bank file are all in the same quality) - however, any weapon related .bank file (such as the 50cal_wave.bank file you're trying to extract) contains a mix of files with different quality (and some a mix of both quality and mono/stereo wavs) - so I guess that might have presented a problem to your extract program. That's the only thing I can come to think of that is different between the kind of .bank files you've already successfully extracted, and the 50cal which you failed to extract.

That might help whoever created the extract program to do the necessary tweaks to it and get it to work on .bank files with all kinds of content (Firefly?).

Link to comment
Share on other sites

GRiN_desmond22- Thanks! Great work putting everything in xml files, makes it really easy to mod. ;)

So now i just want to learn how to repack the files ive edited.. :D

Oh wait, I just tried to extract the 50cal sounds, but nothing extracts.. Ive tried voices and music, and that worked, but extracting these 50cal sounds didnt.

First off - since I haven't programmed the extract program you're using, I am really not the guy to ask for support when it doesn't work as it should.

Secondly - has anyone else successfully exctracted a weapon .bank file? If not, here are some thoughts on why it won't work:

Voices are all in mono (and all voices in any given .bank file are all the same quality), and music is all in stereo (and here too, all files in any given .bank file are all in the same quality) - however, any weapon related .bank file (such as the 50cal_wave.bank file you're trying to extract) contains a mix of files with different quality (and some a mix of both quality and mono/stereo wavs) - so I guess that might have presented a problem to your extract program. That's the only thing I can come to think of that is different between the kind of .bank files you've already successfully extracted, and the 50cal which you failed to extract.

That might help whoever created the extract program to do the necessary tweaks to it and get it to work on .bank files with all kinds of content (Firefly?).

I c... So someone just have to make the program to use mixed sound quality including stereo and mono.. I wonder how though. :o
Link to comment
Share on other sites

I c... So someone just have to make the program to use mixed sound quality including stereo and mono.. I wonder how though. :o

Well, as I said, I have no idea what is the actual problem - but that's the only thing I can think of that might be the problem. The creator of the extract program you are using is the guy (or girl?) to go to. :thumbsup:

Link to comment
Share on other sites

Hmm, sounds like there is an error. ;)

I tried it out on the menu music and another bank file (can't remember the name off the top of my head) and they both worked when I was testing it. Anyway, when I get back I will look at the .xml files. Whether the wav files are stored as stereo or mon shouldn't have an impact on the way they are stored should it? I mean, it's still just an offset of a certain number of bytes? Hmm, I would need to look at the xml files again. Anyway, thanks for the post. I'll work on it when I get home! :)

Link to comment
Share on other sites

Hmm, sounds like there is an error. ;)

I tried it out on the menu music and another bank file (can't remember the name off the top of my head) and they both worked when I was testing it. Anyway, when I get back I will look at the .xml files. Whether the wav files are stored as stereo or mon shouldn't have an impact on the way they are stored should it? I mean, it's still just an offset of a certain number of bytes? Hmm, I would need to look at the xml files again. Anyway, thanks for the post. I'll work on it when I get home! :)

Yeah, that shouldnt have any impact when extracting... I don't understand why the weapon sounds should be that unusual than the other sounds, just that they're stored in both mono and stereo... Hhmmm..... Damn annoying...
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...