Jump to content


Photo

Seif's Multimedia Tutorial #4


  • Please log in to reply
No replies to this topic

#1 Seifer

Seifer

    The best Anti-Paladin weapon is a tin opener...!

  • Member
  • 4505 posts

Posted 26 August 2004 - 05:25 PM

Music and soundsets ? Using Ogg Vorbis format:
By Seifer

Introduction

This tutorial aims at providing people with a complete recording and installation package for their MOD in ogg vorbis format. Installation, as always, shall be done through the WeiDU TP2. I?ve been looking at ways of compressing the soundsets and then decompressing back to the override folder into the only format that BGII understands, that is .wav. The problem of the WAV files is that they are huge. You'll need 4 MB for a general soundset and probably 30 MB + if you are looking at adding Romance lines and some banter.

We first looked at MP3 based on the Tashia MOD by Arian but found that the Ogg Vorbis format was even better in terms of both Quality and Compression. Besides, MP3?s are copyrighted material and any decoder provided with your MOD may infringe on this.


Section one - What is Ogg Vorbis and how does it compare to other sound formats?

Ogg Vorbis is a sound compressor that is distributed under the GNU license, which means it?s free and can be used, modified without license problems, contrary to MP3. Who remembers Napster??

Comparison of file sizes between the 3 formats wav, MP3 and Ogg Vorbis:

You can use OGG VORBIS, which compresses for an equal sound quality much more than MP3. Here is the results of compression recording 8 seconds of raw data with Audacity.exe and saving them into wav, MP3, ogg format respectively, herewith the results in file size:

Wave file (mono track, 96Kb/s, 22,050 Hz, 16 Bit) : 361 Kb
MP3 file (mono track, 96Kb/s, 22, 0050 Hz, 16 Bit) : 98.8 Kb
Ogg Vorbis file (mono track, quality 5, 22,050 Hz, 16 Bit): 68.8 Kb.

That says it all, doesn't it? And to be honest, I could not tell which one felt better in terms of sound quality. They all felt more or less the same. The size difference may not seem much between MP3 and Ogg but over 100 files (complete soundset + romance + banter); it does (100 X 30 KB = 3 MB nearly shaved off!). This made a huge difference when Dorotea?s Longer Road was repackaged and also with my Kiara and Zaiya mod.

Several tools are necessary for this tutorial, a recording and editing package as well as a tool that can convert into WAV formats during installation.

You can get audacity.exe a free sound recording and editing software utility at:
http://audacity.sourceforge.net/
http://audacity.sourceforge.net/
Audacity can record voices in Wav, MP3 and Ogg Vorbis. It also allows editing too, but you could also check for Cool Edit or Tsunami which also record in Ogg Vorbis.

You will also need a decompression for Ogg vorbis to wav, it can be downloaded here:
http://www.vorbis.co...s-1.0-win32.zip


Section 2 ? How can I use Ogg Vorbis in a mod?

Ogg Vorbis isn?t a supported format for your soundsets. Here is how we can work around it.

Step 1: RECORDING AND SAVING OGG FILES
Record your soundset using Audacity or any other and save the resulting files as Ogg Vorbis files.

XXXXXXXa.ogg : Battle Cry
XXXXXXXb.ogg : Becoming Leader
XXXXXXXc.ogg : Tired
XXXXXXXd.ogg : Bored
XXXXXXXe.ogg : Badly Wounded
XXXXXXXf.ogg : Selected 1
XXXXXXXg.ogg : Selected 2

NB: a complete list for soundset names is provided in the BGII readme file. I?ll place it here in its full glory as a reminder and to save you the hassle of opening up another window. Just copy and paste this, changing the X values to whatever you name your files and replacing the wav extension with the ogg extension.

XXXXXXXa.wav    : Battle Cry
XXXXXXXb.wav    : Becoming Leader
XXXXXXXc.wav    : Tired
XXXXXXXd.wav    : Bored
XXXXXXXe.wav    : Badly Wounded
XXXXXXXf.wav    : Selected 1
XXXXXXXg.wav    : Selected 2
XXXXXXXh.wav    : Selected 3
XXXXXXXi.wav    : Action Acknowledgement 1
XXXXXXXj.wav    : Action Acknowledgement 2
XXXXXXXk.wav    : Action Acknowledgement 3
XXXXXXXl.wav    : Being Hit
XXXXXXXm.wav    : Dying
XXXXXXXn.wav    : In Forest
XXXXXXXo.wav    : In City
XXXXXXXp.wav    : In Dungeon
XXXXXXXq.wav    : Daytime
XXXXXXXr.wav    : Nighttime
XXXXXXXs.wav    : Action Acknowledgement 4
XXXXXXXt.wav    : Action Acknowledgement 5
XXXXXXXu.wav    : Action Acknowledgement 6
XXXXXXXv.wav    : Action Acknowledgement 7
XXXXXXXw.wav    : Reaction to Party Member Death
XXXXXXXx.wav    : Rare Select 1
XXXXXXXy.wav    : Rare Select 2
XXXXXXXz.wav    : Critical Hit Given
XXXXXXX1.wav    : Critical Miss
XXXXXXX2.wav    : Target Immune
XXXXXXX3.wav    : Inventory Full
XXXXXXX4.wav    : Successfully Picked A Pocket
XXXXXXX5.wav    : Successfully Hid In shadows
XXXXXXX6.wav    : Spell Disrupted
XXXXXXX7.wav    : Set A Trap
XXXXXXX8.wav    : Battle Cry 2
XXXXXXX9.wav    : Battle Cry 3
XXXXXXX0.wav    : Selected 6
XXXXXXX_.wav    : Action Acknowledgement 8

Step 2 ? PREPARING YOUR OGG CONVERSION FILES
The first thing to do here is create a folder in your main mod directory which will hold all your voice clips and music files. This is typically called ?sounds?, or ?music? or something similar but for the sake of keeping the tutorial simple I?ll refer to this as the sound directory herein.

Then, copy all your sound files in Ogg format (XXXXXXXa.ogg) to that sound folder
and copy OGGDEC.exe in this sound folder as well. The file is provided in the Vorbis-tools.zip file

Step 3 ? MAKING A BAT FILE

.bat files are Microsoft batch files and are commonly used once Weidu has finished what is in its scope to instruct external files. A common usage of this is that external packaged utilities such as the Oggdec EXE and the TISPACK (area editing) can be instructed. This might sound like it wastes space, adding another exe but this is more then justifiable when compared against the space saved with the sound files. The content of the batch file, as far as sound sets are concerned should look like this somewhat.

MyMod\Sound\oggdec.exe  MyMod\Sounds\xxxxxxxa.ogg
MyMod\Sound\oggdec.exe  MyMod\Sounds\xxxxxxxb.ogg
MyMod\Sound\oggdec.exe MyMod\Sounds\xxxxxxx_.ogg

And so on.


Copy MyMod\Sounds\*wav Override\*.wav
Del MyMod\Sound\*.wav


Copy MyMod\Sounds\*wav Override\*.wav ? This line will copy all the converted Wav files from your sound directory to the BGII ? SoA override folder, which is where they need to be in order to play.

Del MyMod\Sound\*.wav- This line will then delete the native, converted files from your sound directory to save space. As you can imagine, it?s important that it comes AFTER the line that copies them over.

Step 4 - SCRIPTING, TP2 AND WeiDU

The first step in this part is to create a Mymodfix.bcs that can be run from any dialogue file in your mod. It will look a little like this: -

IF
True()
THEN
RESPONSE #100
  CutSceneId("Mymod")
  SetName(0001) // MyMod
  SetPlayerSound(Myself,0002,INITIAL_MEETING)
  SetPlayerSound(Myself,0003,EXISTANCE5)
  SetPlayerSound(Myself,0004,BATTLE_CRY1)
  SetPlayerSound(Myself,0005,LEADER)
  SetPlayerSound(Myself,0006,TIRED)
  SetPlayerSound(Myself,0007,BORED)
  SetPlayerSound(Myself,0008,DAMAGE)
  SetPlayerSound(Myself,0009,SELECT_COMMON1)
  SetPlayerSound(Myself,0010,SELECT_COMMON2)
  SetPlayerSound(Myself,0012,SELECT_COMMON3)
  SetPlayerSound(Myself,0013,SELECT_ACTION1)
  SetPlayerSound(Myself,0014,SELECT_ACTION2)
  SetPlayerSound(Myself,0015,SELECT_ACTION3)
  SetPlayerSound(Myself,0015,HURT)
  SetPlayerSound(Myself,0016,DYING)
  SetPlayerSound(Myself,0017,AREA_FOREST)
  SetPlayerSound(Myself,0018,AREA_CITY)
  SetPlayerSound(Myself,0019,AREA_DUNGEON)
  SetPlayerSound(Myself,0020,AREA_DAY)
  SetPlayerSound(Myself,0021,AREA_NIGHT)
  SetPlayerSound(Myself,0022,SELECT_ACTION4)
  SetPlayerSound(Myself,0023,SELECT_ACTION5)
  SetPlayerSound(Myself,0024,SELECT_ACTION6)
  SetPlayerSound(Myself,0025,SELECT_ACTION7)
  SetPlayerSound(Myself,0026,REACT_TO_DIE_GENERAL)
  SetPlayerSound(Myself,0027,SELECT_RARE1)
  SetPlayerSound(Myself,0028,SELECT_RARE2)
  SetPlayerSound(Myself,0029,CRITICAL_HIT)
  SetPlayerSound(Myself,0030,CRITICAL_MISS)
  SetPlayerSound(Myself,0031,TARGET_IMMUNE)
  SetPlayerSound(Myself,0032,INVENTORY_FULL)
  SetPlayerSound(Myself,0033,PICKED_POCKET)
  SetPlayerSound(Myself,0034,EXISTANCE1)
  SetPlayerSound(Myself,0035,EXISTANCE2)
  SetPlayerSound(Myself,0036,EXISTANCE3)
  SetPlayerSound(Myself,0037,BATTLE_CRY2)
  SetPlayerSound(Myself,0038,BATTLE_CRY3)
  SetPlayerSound(Myself,0039,SELECT_COMMON6)
  SetPlayerSound(Myself,0040,INITIAL_MEETING)
  SetPlayerSound(Myself,0041,HAPPY)
  SetPlayerSound(Myself,0042,UNHAPPY_ANNOYED)
  SetPlayerSound(Myself,0043,UNHAPPY_SERIOUS)
  SetPlayerSound(Myself,0044,UNHAPPY_BREAKING_POINT)
END



Now, from here, you can replace the numeric values 0001-0044 (or whatever you?ve chosen to use) with the REPLACE command to the actual in-game lines that you want. This will either be done via the Tp2 alone or with a TP2/TRA combination. Hence: -

REPLACE ~0001~ ~MYMOD~ //IT'S NAME
REPLACE ~0002~ ~FIRST DIALOG LINE HERE~
REPLACE ~0003~ ~MY MOD's BIOGRAPHY.~
REPLACE ~0004~ ~~ [XXXXXXXI]
REPLACE ~0005~ ~~ [XXXXXXXJ]
REPLACE ~0006~ ~~ [XXXXXXX2]

ETC..............


Step 5: THE INSTALLATION FROM YOUR TP2

AT_INTERACTIVE_EXIT ~myMod\Sounds\Install.bat~

In a nut shell, that?s all there is too it.. On running WeiDU, it will automatically, convert all your recorded Ogg files into .Wav files, then copy them to the Override folder where they can be used by your CUSTOM MOD.
As soon as the script (MYMODFIX.BCS) is run (I usually assign it just before joining), then your MOD will find its sound set.

Step 6: ADDING MUSIC TO THE MOD
At this stage, we need to introduce another tool. This tool is a .Wav to .ACM converter that?s used in Fallout II modding. It can be found here: -

http://www.teamx.ru/utils/snd2acm.rar

You?ll need to place a copy of the snd2.acm.exe in you?re the sound directory of your mod. Unlike the voice clip, the music files undergo two transformations rather then just one.

Step 6: MAKING THE INFINITY ENGINE MUS FILE

This has been documented elsewhere but I?ll add a condensed version here. Open a blank .txt file and add the following text:-

MXMYMOD
1
A  @TAG END


As with most file names in the Infinity Engine, make sure that this doesn?t exceed 8 characters. In this instance, I mean the MXMyMod file name. Change the .txt extension to a .mus extension and add it to your sound directory folder. It?s important to note as well, that you have to do this for each soundtrack you intend to add. One file WILLNOT cater for all your additions.

Step 7: BAT FILE ADDENDUM

Remember that .bat file we made earlier? Well, you?re going to need it again for the following. If you?ve not gotten a sound set to add yet, don?t worry, just make a new bat file and correlate the names accordingly. The first step is to add a new command at the very top of the bat file.

MD Music\MxMyMod


MD is the DOS command for ?Make Directory.? This is going to be the target folder for your converted music file. You also need to remember to have included a command to convert your .ogg file into a .wav. It?s the wav file that we are interested in. So, what have we got thus far? We have a music file that?s been converted to wav format and a new folder for it in the BGII music directory. Next we need to add the following line to the bat file.


MyMod\Sounds\Snd2acm.exe -wav MyMod\Sounds\MxMyMod.wav MyMod\Sounds\MxMyModA.acm


This is probably the longest line that you?re going to have to add to the bat file and is the line that instructs the snd2acm.exe to take your ogg-wav converted file and turn it into an ACM file. The last elements of this part of the tutorial simply deal with getting the ACM file into the directory you created earlier. The coding looks like this:-


Copy MyMod\sounds\MxMod.acm Music\MxMyMod
Del MyMod\Sounds\MxMyMod.acm


That coding will also make sure that the ACM file is deleted from your mod sound directory once it has been copied over. Lastly, if you have added the sound set from above, this command has to come last:-
Del MyMod\Sounds\*.wav

As it will ensure that all the wav files, including the music files, are all deleted from your mod sound directory.

Section 8: MORE TP2 EDITING

The last section of the tutorial is simply getting the tracks added to the in-game list. TP2 coding to the effect of: -

COPY ~MyMod\Sounds\MxMyMod.mus~ ~Music\MxmyMod.mus~
ADD_MUSIC  ~MyMod~    ~Music\MxMyMod.mus~


The variable %MyMod% is now associated with the number of this MUS file. Example usage of this is as follows:-

COPY ~mymod/script.bcs~ ~override/script.bcs~
  REPLACE_TEXTUALLY 999999 ~%MyMod%~


And that?s all there is to it. If you run into any problems, either PM me here or at FW (my usual haunt) or email me ? Olryx2@Yahoo.co.uk

Edited by Seifer, 29 May 2005 - 04:20 AM.

how come you always look so damn cool in every photo I see you in?!?


Speaking of modding, I listened to IER 3 yesterday, so you can have another quote for your signature: how come you sound so damn cool, as well as look it? It's unfair. Seriously.


Still a cyberjock, still hacking the matrix, still unsure of what that means.

TeamBG member - http://www.teambg.eu