HOWTO: Add a new 2D *.wav sound into your mod

DireAussie

Chieftain
Joined
Nov 12, 2005
Messages
60
There are 2 XML files:

in xml\audio:

AudioDefines.xml
Audio2DScripts.xml

Open each file and scroll to the end.

in Audio2DScripts:

Copy the last entry between <Script2DSound> and </Script2DSound> and paste in another one just below it. This will become your new sound.

Then change the "ScriptID" value to AS2D_MYSOUND where MYSOUND is what you want to call it.

Change "SoundID" to SND_MYSOUND, where MYSOUND is the same as above.

"Soundtype" should be changed to the most appropriate value. Scroll up in the file - you'll see lots of different sound types. Choose one that you feel is appropriate for your sound.

The rest of the values you can leave. Probably the most interesting to change is "iMinVolume" and "iMaxVolume", which controls how loud it will be in-game.

Here's an example of the custom sound I made:

Code:
	<Script2DSound>
		<ScriptID>AS2D_SWARM</ScriptID>
		<SoundID>SND_SWARM</SoundID>
		<SoundType>GAME_SFX</SoundType>
		<iMinVolume>80</iMinVolume>
		<iMaxVolume>80</iMaxVolume>
		<iPitchChangeDown>0</iPitchChangeDown>
		<iPitchChangeUp>0</iPitchChangeUp>
		<iMinLeftPan>-1</iMinLeftPan>
		<iMaxLeftPan>-1</iMaxLeftPan>
		<iMinRightPan>-1</iMinRightPan>
		<iMaxRightPan>-1</iMaxRightPan>
		<bLooping>0</bLooping>
		<iMinTimeDelay>0</iMinTimeDelay>
		<iMaxTimeDelay>0</iMaxTimeDelay>
		<bTaperForSoundtracks>0</bTaperForSoundtracks>
		<iLengthOfSound>0</iLengthOfSound>
		<fMinDryLevel>1.0</fMinDryLevel>
		<fMaxDryLevel>1.0</fMaxDryLevel>
		<fMinWetLevel>0.0</fMinWetLevel>
		<fMaxWetLevel>0.0</fMaxWetLevel>
	</Script2DSound>

in AudioDefines.xml:

Scroll to the bottom, then scroll up until you reach the <SoundData> fields. Copy and paste for a new entry like you did before between <SoundData> and </SoundData>

Change "SoundID" to SND_MYSOUND where MYSOUND is the same as you used above

Change "Filename" to the file of the sound on your hard drive, without the .wav extension. If you are in a mods directory then you should put the sound somewhere under the sounds folder in your mod. The rest of the values should stay the same

example:

Code:
		<SoundData>
			<SoundID>SND_SWARM</SoundID>
			<Filename>Sounds/randomevents/swarm</Filename>
			<LoadType>DYNAMIC_RES</LoadType>
			<bIsCompressed>1</bIsCompressed>
			<bInGeneric>1</bInGeneric>
		</SoundData>

Your sound is now ready to go!

Code to play the sound:

Make sure you have imported python extensions into the file that will play the sound:
Code:
from CvPythonExtensions import *

The code to play the sound:

Code:
CyAudioGame().Play2DSound("AS2D_SWARM")
 
Could someone here give a more detailed example of the pythonpart of it? What do I have to do to import python extensions to what file?:confused:

Edit: I mean where exactly do I have to place a code to play a sound and what else?
 
Ploeperpengel said:
Could someone here give a more detailed example of the pythonpart of it? What do I have to do to import python extensions to what file?:confused:

Edit: I mean where exactly do I have to place a code to play a sound and what else?

That import part goes at the top of whatever file that you're going to play it at. The actual line of code goes where you want to play it.

It really depends when you want it to play. For example, if you want it to play whenever an improvement is finished, put it in the CvCustomUtils.py file in the "onImprovementBuilt" function.

Nice tutorial DireAussie. Very clean and easy to read :goodjob:
 
Ok this seems indeed complicated then. I want to add all the Dragonsounds to my mod but guess I will have to put pythoncodes in many different files then, right? I really got no idea what pythonfile is meant for what actionsound:sad:
 
Ploeperpengel said:
Ok this seems indeed complicated then. I want to add all the Dragonsounds to my mod but guess I will have to put pythoncodes in many different files then, right? I really got no idea what pythonfile is meant for what actionsound:sad:

Well, if it's just something that is done for a unit, like the sound when it trains or when it moves, you can put it into the ArtDefine of a unit (file CIV4ArtDefines_Unit.xml). This tutorial explains how to do something when an event occurs, which typically means you're using Python to make the audio play.

I'm not sure about where in the XML to find the death sounds and stuff, but you'd probably find that in XML as well.
 
The problem is I already done all of that but don't get any result. I copy pasted everything from FFH where it works and didn't notice any different xml settings there from vanilla nor do I receive errormessages but I just don't get any sound so I thought action and selection sound would need some python.
I don't get any clue now:(
 
this is an innocent question, but I've played edit-audio files before...

there is no special file type/parameter that has to be used?

I think on civ(3?) you had to have a .wav recorded at mono only on tuesday's while jumping on one leg... so I ask about civ4 before I get excited.
 
I know this thread has been dead for ages, but I almost have new sounds programmed in and I'm stuck on the last step.

I have done the AudioDefines and the 2D sound XML files, and now I am just trying to get the sound to appear in the game. Specifically, I want a different sound for when a city reaches legendary culture than a normal border expansion.

What do I have to do to link my new sound file with the event? I have been searching all afternoon and can't find the related files.
 
Top Bottom