Sound Tutorial

Tutorials for Call of Duty mapping

Moderator: Core Staff

Post Reply
User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Sound Tutorial

Post by Nightmare » March 24th, 2007, 6:32 am

Ok well its time for a new tutorial and this time I will focus on how to use sound because some people tend to have problems with it.

56k Beware; there are a few pictures.

So first I am already going to go ahead and assume you know how to make a correct pk3 file. If not then do not try this tutorial, you will probably not understand much.

Preparing on the map
So first before we are going to go into any scripting, we shall first prepare the "speaker" in the map.

To spawn a "speaker" just right click over your 2d grid and select script/model

This should appear:
Image

Just click cancel on the model selector but leave the entity editor open.
Now just enter the things below:

Key:targetname
Value:sound_tut_speaker

Remember that you can choose any name you want for the value but
Note:Always put your map name in front of the value, this prevents conflicting problems.

Ok, so now that the speaker has been added I am just going to go ahead and make a trigger to activate the sound.

Adding a trigger
To add a trigger is pretty simple, I have already explained it in my other tutorial but I will go ahead and do it again.

First: Go to your common texture and choose the trigger texture, for this I am going to make a "use" trigger meaning you will have to press F to activate.
Then: Once you have put your trigger in the selected spot right click it (with the trigger still being selected) and select trigger/use.
The outline of that trigger should become blue.

Image

Now with it still selected press n to bring up the entity editor so we can add some values.

Key:targetname
Value:sound_tut_trig

So now that we are done with the preparing it is time to go into the scripting.
Note:I am going to assume you know how to add a skybox a spawn and know how to compile a map.

Folders and CSV
Ok, so I have the pk3 set up with the maps/mp and the mp folder, but there are now some more folders to add.
So now you will have to add two more folders
Make one named sound and another named soundaliases

Note: You can put another folder inside the sound folder, this is not a required task but it helps prevent conflicting.

The folder named sound will contain the custom sound you have to put in.
Soundaliases will give the sound a type of targetname for the script to look for when in game.

Note: Only use a .wav file for a triggered or non-ambient sound, and use the mp3 format for ambient
(I have no idea why they made it like that but that’s just the way it is.)

Do not forget you can also already use sounds from the game, you will need to look at pak1.pk3 for the sound names to use.
But because we want to use our own sound we might as well just go ahead.
So remember my note above, because we are using a trigger this sound must be in .wav format.

I just quickly got a sound effect from Google. (You can find some very nice ones with some good amount of searching.)

So I will now add the .wav file in my sound/sound_tut. (remember my note above)

Now comes the tricky part, and this is adding the csv file, this can be edited using either notepad or Window's Excel.
I am going to make mine using notepad.

Code: Select all

,name,name of the alias that is used to play this sound (required)
,sequence,"used to uniquely identify alias entries when more than one sound goes to an alias, used only to catch unwanted duplicates (default = 0)"
,file,the name of the file that contains the sound data (required)
,vol_min,"0 is silent, 1 is full volume (default = 1)"
,vol_max,"0 is silent, 1 is full volume (default = same as vol_min)"
,pitch_min,"1 is normal playback, 2 is twice as fast, 0.5 is half as fast (default = 1)"
,pitch_max,"1 is normal playback, 2 is twice as fast, 0.5 is half as fast (default = same as pitch_min)"
,dist_min,"within this distance in inches, the sound is always full volume (default = 120)"
,dist_max,"outside this distance in inches, the sound is not started.  If left blank or set to 0, the sound will play from any distance.  This does not affect sound volume falloff."
,channel,"auto, menu, weapon, voice, item, body, local, music, announcer (default = auto)"
,type,streamed / loaded (default = loaded)
,probability,weight to use for the weighted probability of playing this sound instead of another sound (default = 1)
,loop,"whether this sound is ""looping"" or ""nonlooping"" (default = ""nonlooping"")"
,masterslave,"if ""master"", this is a master sound.  If a number, then this sound won't exceed this volume whenever any master sound is playing.  If blank, then neither master nor slave."
,loadspec,"space-separated list of which maps should use this alias; eg, ""burnville dawnville"".  If blank, the alias is used on all maps."

name,sequence,file,vol_min,vol_max,pitch_min,pitch_max,dist_min,dist_max,channel,type,probability,loop,masterslave,loadspec,subtitle

null,1,null.wav,,,,,,,,,,,,,

#Sounds,,,,,,,,,,,,,,,
sound_tut_s,,sound_tut/sound_tut_sound.wav,1,1,,,2000,2000,auto,,,nonlooping,,,
If this looks to complicated or overwhelming, just open this in excel.

Alright, almost done, now that we have our sound file in place and our csv file naming the sound we can now script it in.

Scripting
To start off make a notepad file in the maps/mp right beside the bsp file.

And now for the simple part:

Code: Select all

main() 
{
maps\mp\_load::main(); 
thread sound_tut();
}

sound_tut() 
{ 
speaker = getent ("sound_tut_speaker","targetname");
trigger = getent ("sound_tut_trig","targetname");
while(1)
{
trigger waittill ("trigger");
speaker playsound("sound_tut_s");
wait(2);
}
}
All you will need to do is change the names according to the values you gave them.
So save this as a gsc file and make your pk3 with all four folders in them.

Congratulations!
You have made it through and have successfully made a working sound script!

Here is the zip file containing everything, even the .map file
Click Here

Well, I hope this tutorial helped anyone out; I will try to come with some more tutorials later!
Made By Nightmare
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
[SoE]_Zaitsev
Core Staff
Core Staff
Posts: 14220
Joined: October 21st, 2004, 7:17 pm
Location: Holland
Contact:

Post by [SoE]_Zaitsev » March 24th, 2007, 1:18 pm

I didn't read it (I probably won't understand a thing) but very nice job! :D
matt101harris wrote:big cock was the first thing that came to my head lol

User avatar
waywaaaard
Core Staff
Core Staff
Posts: 2214
Joined: February 6th, 2006, 3:18 pm
Location: Germany/Bayern

Post by waywaaaard » March 24th, 2007, 2:54 pm

woot it worked yeah thanks nightmare woot

so now i can really finish that map - it should be a really unique and good one
THAT HANDS WERE NOT TRACED!
visit my blog: Link
Soviet wrote:Yeah, watch out, Peds will hit you with his +5 D-Battleaxe of homosexuality :roll:

Soviet
Core Staff
Core Staff
Posts: 7760
Joined: April 23rd, 2005, 9:12 pm
Location: Plano, Texas
Contact:

Post by Soviet » March 25th, 2007, 5:38 pm

there are actually two ways to do it, but the way you showed is 50 times easier, gj :)
Image
ImageImageImage
Image
"Zaitsev is a cunt." - Pedsdude

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » March 26th, 2007, 3:54 am

I will gladly make another tutorial on request, just ask and I will make one. :D
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Coontang
CJ G0D!
CJ G0D!
Posts: 1797
Joined: March 4th, 2007, 3:48 pm
Location: Painting by numbers

Post by Coontang » August 9th, 2007, 10:00 pm

Would one on adding ambients be possible?
Image
JDogg: 'I have a video of me pissing, wanna see?'

User avatar
Nightmare
Core Staff
Core Staff
Posts: 2688
Joined: January 12th, 2006, 10:09 pm
Contact:

Post by Nightmare » August 9th, 2007, 11:24 pm

I explained above, its the same thing except you don't need a speaker and the command is

Code: Select all

ambientPlay("sound");
Coding is Poetry. Mapping is Art.
"Cause im the sexiest mapper ever...except for nm, that sexy man" - Soviet

-=[CoDJumper.com Movies]=-
[Ambush] || [Backlot] || [Bloc] || [Bog] || [Broadcast] || [Chinatown] || [Countdown]
[Crash] || [Creek] || [Crossfire] || [District] || [Downpour] || [Killhouse] || [Overgrown]
[Pipeline] || [Shipment & Wetwork] || [Showdown] || [Strike] || [Vacant]

User avatar
Cpt.Cool
CJ Worshipper
CJ Worshipper
Posts: 204
Joined: May 31st, 2007, 2:27 am
Contact:

Post by Cpt.Cool » August 31st, 2007, 2:38 pm

Dont you need to put it in a misc folder so ppl with uo can hear it too?
Image
Image
YaNo wrote:I use Cool as my UO compiler :) Try it, it works!

Pedsdude
Site Admin
Site Admin
Posts: 15908
Joined: October 15th, 2004, 7:18 pm
Location: UK

Post by Pedsdude » August 31st, 2007, 4:54 pm

Serves them right for jumping on UO!
Image
Image

User avatar
Cpt.Cool
CJ Worshipper
CJ Worshipper
Posts: 204
Joined: May 31st, 2007, 2:27 am
Contact:

Post by Cpt.Cool » September 5th, 2007, 1:35 pm

hey, im a good jumper w/o sprint, sometimes, ok, im a sprinter :(
Image
Image
YaNo wrote:I use Cool as my UO compiler :) Try it, it works!

Rukariox
CJ Wannabe
CJ Wannabe
Posts: 34
Joined: July 30th, 2009, 7:30 pm

Re: Sound Tutorial

Post by Rukariox » April 30th, 2010, 8:11 am

Hoyou spawn a speaker within a player?

megazor
CJ Worshipper
CJ Worshipper
Posts: 414
Joined: July 22nd, 2009, 3:02 am
Location: Russia, Vladivostok

Re: Sound Tutorial

Post by megazor » April 30th, 2010, 11:51 am

Code: Select all

entity playLocalSound(sSoundAlias)
for example,

Code: Select all

player playLocalSound("lol")

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests