Jump to content
Official BF Editor Forums
Sign in to follow this  
PanzerSmurf

Decoding / Encoding .ogg Files

Recommended Posts

I have finally succeeded my attempt to figure out how these damn .ogg files work. DICE took the liberty (unfortunately) to hard code serials into the engine.

So, to achieve a successful input of new sounds, you need to do the following.

First and foremost, you are going to need to grab Vorbis' .ogg tools off of this website (the encoder file set). Now, let's get our hands dirty.

Let's say we wish to replace the M1A2 cockpit ambience with a Panzer's ambience...

1. First, create your sounds files as always (.wav).

2. Grab an .ogg file from another tank's cockpit ambience in Battlefield 2. Let's use the default M1A2 .ogg file.

...Objects_clientVehiclesLandUSTNK_M1A2SoundsM1A2_cockpit.ogg

3. Now, open up your command prompt (Start > Run > cmd)

4. You should now pinpoint cmd to the location you had installed the Vorbiss tools. In my case, it's C:Program FilesVorbis

5. Before we continue, we need to obtain the serial number I talked about earlier: type the following into the cmd prompt.

ogginfo M1A2_cockpit.ogg

8. It will give you some information at the top that should look like this:

New logical stream <#1, serial: 00000e9a>

6. Write the serial number provided (00000e9a) down. You should also pay attention to the "Nominal bitrate" (56.001000), which you should also write down.

7. We need to convert the Unicode the program spat out into ASCII. To do so, you need to go to this page.

8. On the page I just provided, you will see the field "Input Base". Set that to "hex or U+xxxx".

9. In the "Enter Number" field, you are going to type in the serial number you just obtained from the M1A2_cockpit.ogg file (00000e9a).

10. After that, you simply need to hit the "Process" button.

11. Once you hit "Process", you will see numbers and letters in the four boxes below. What we want is from the "Dec" field (3738).

Note: the ASCII should be eight characters long, so keep in mind the webpage is removing the four beginning zeroes. The actual ASCII code is 00003738.

12. To convert the .wav file into an .ogg file, the formula is as follows (typed into the cmd prompt, of course):

oggenc -b (bitrate) -s (serial number) (newsound.wav)

13. So in or case it should read as follows:

oggenc -b 56.001000 -s 00003738 Panzer_cockpit.wav

It should start encoding the .wav file.

14. After the Encoding has completed, you are going to want to make sure the serial numbers and bitrates are the exact same. So type the following into the cmd prompt to double check them:

ogginfo M1A2_cockpit.ogg

ogginfo Panzer_cockpit.ogg

If the serial numbers match, then you have successfully encoded an .ogg file! If you guys have any questions, feel free to ask. I should also note this works with ANY .ogg file, be it ambience or menu / loading music.

Share this post


Link to post
Share on other sites

Great tutorial, i have been trying to add an ambience sound to my chopper but always got weird bug like the sound repeating over and over, now with the good bitrate it works.

Share this post


Link to post
Share on other sites

I want to add to this lovely post by posting my BF2 sound tool pack. Its all the tools you need to follow this guys nice tutorial and get in sounds properly. It include the right version of the sound files and batch files that do the conversion properly.

I wont host these forever if some one wants to host them somewhere go ahead.

http://files.filefront.com/Bf2_Sound_Tools...;/fileinfo.html

Share this post


Link to post
Share on other sites
Guest

I am having trouble with this. I am trying to convert a .wav into a a new bit of menu music, but I cannot get the bitrates to match exactly.The files I have are menumusic.wav (the file I want to convert) and menu_music.ogg (the original BF2 menu music).

The serial number for the original is 00005a99 (which converts to 0023193) and the nominal bitrate is 112.001000 kb/s .

I am using the following batch file:

oggenc -b 112.001000 -s 0023193 menumusic.wav

However, when the two files are compared, the new file is at only an even 112.0000000 kb/s and I cannot get it to play in-game. I am assuming the path for the music is common/sound/menu/music/menu_music.ogg.

Thanks.

Eskimo

Share this post


Link to post
Share on other sites

What if you are trying to add different load music to a custom map and not a mod. I realise that you can't have it install .ogg's into people's BF2 folders, is there a location that I should put the .ogg in the client.zip and a certain path I should write to the info file?

I would love to have custom music for my maps, but I don't want to make it a mod just to do that, any help would be apprecaited.

Share this post


Link to post
Share on other sites
Guest

C4Explosives:

Go to yourmodfolder/levels/yourlevelname/info/yourlevelname.desc . Open it with Wordpad or another such program.

Find the line that says the following:

<music> common/sound/menu/music/load_MEC_music.ogg </music>

Change the path to the desired file and save. :)

Share this post


Link to post
Share on other sites
C4Explosives:

Go to yourmodfolder/levels/yourlevelname/info/yourlevelname.desc . Open it with Wordpad or another such program.

Find the line that says the following:

<music> common/sound/menu/music/load_MEC_music.ogg </music>

Change the path to the desired file and save. :)

as long as you don't mean switching simply between mec and chinese music, that just might work.

Share this post


Link to post
Share on other sites
C4Explosives:

Go to yourmodfolder/levels/yourlevelname/info/yourlevelname.desc . Open it with Wordpad or another such program.

Find the line that says the following:

<music> common/sound/menu/music/load_MEC_music.ogg </music>

Change the path to the desired file and save. :)

I've found this technique works for a great many things when it comes to adding certain content without the need for it to be a mod. Very very helpful.

Share this post


Link to post
Share on other sites
Guest

Just to be clear, the names can be anything but the serials need to match. based on the situation, Right? This obviously won't be an issue for original objects sucha s custom imported vehicles, right?

Share this post


Link to post
Share on other sites

to insert new ogg's do i need to use the serial, new ogg's being loading map music and ambient music for custom items..... do i need to use a serial, if so whuich one....

Share this post


Link to post
Share on other sites

never mind, bf2 loads wav files as is......

Share this post


Link to post
Share on other sites

Google'ing for 'Hex-Dec Converter' gave me a lot of them :P

Here's a small extract :

http://www.parkenet.com/apl/HexDecConverter.html

http://www.bitfaeule.de/

http://www.easycalculation.com/hexa-decimal-binary.php

I'm using my Palm PDA with 'EasyCalc' , a superior Calculator which includes Octal, Hex, Bin and Dec conversions and tons of other functions. If you're owning a PDA this might be the right thing for you.

Share this post


Link to post
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.

Loading...
Sign in to follow this  

×
×
  • Create New...