Tutorials

Soundscapes Part 3 - Play Random



Play random

This tutorial assumes you have read part 1 and 2 of the soundscapes tutorials.

With the “playlooping” soundscape your chosen sounds will play from the moment it’s triggered and carry on until a new soundscape is triggered. With “playrandom” when the soundscape is triggered random sounds are played from a list you define. The sounds will vary in volume pitch and the length in time it takes for each sound to be triggered. The advantage of this is a more realistic ambience but at the same time sounds you want to play all the way through wont, so it’s best to combine an playrandom and a playlooping in your soundscape.

Making a playrandom soundscape is exactly the same as making a playlooping soundscape there are just different keys.

The available keys for play random are:

"Time - Time interval of the random event.

Volume - Random volume interval (0-1).

Pitch - Random pitch interval (50-250).

Attenuation - Random attenuation of sound.

Rndwave - A list of random wave files to choose from.

Position - Position to use, if spatialized (0-7). "



Taken from http://www.valve-erc.com/srcsdk/Sound/soundscapes.html

Definition of Attenuation is “The reduction in intensity of a sound signal.”

I will talk further about Position later on.

Open up your soundscapes.txt document and define your playrandom soundscape.

My playrandom soundscape looks like this:

 "soundscapes.playrandom"
{
	"dsp"	"1"
	"playrandom"
	{
		"time"         "0.1,1.5"
		"volume"       "0.5,1"
		"pitch"	       "100"
		"rndwave"
		{
			"wave"	"ambient/atmosphere/town_ambience.wav"
		}
	}
} 



Time to exaplain it.

"soundscapes.playrandom" – This is the name of the soundscape it can be anything you want.

"dsp" "1" – This is the DSP effect of the soundscape 0 turns dsp off, 1 makes the engine choose the best one. You can set your own dsp effect if you really want but it’s advised just to use 1. The dsp numbers go from 0 – 28.

"playrandom" – Plays the random sounds when triggered.

"Time" "0.1,1.5" – This mean that the individual sounds will be played randomly between 0.1 seconds and 1.5 seconds.

"volume" "0.5,1" – This means That the induvudual sounds will be played at random volumes.

"pitch" "100" – You can have varying pitches but for the tutorial I just kept it at one pitch. The pitch can vary from 50 – 250. To have different pitches put something like this in "pitch" "50,120".

"rndwave"
{
"wave" "ambient/atmosphere/town_ambience.wav"
}

- This defines wavs that you want to be played randomly.

Save you new soundscape.

Okay so now we have created our soundscape its time to get it working in game. Place an “env_soundscape” entity in your map.

Select the entity, and then bring up the “Object Properties” window:

news post image

In the key “soundscape” you need to define the name of the soundscape you want to use. Earlier I created a soundscape called "soundscapes.playrandom " in the txt document, so im going to use that one. To do this you simply put soundscapes.playrandom in the space provided:

news post image

And that’s the playrandom subscape sorted.

The next section will be on subsoundscapes.

Happy Mapping

Signy

View comments ( 11 )

Back to top