Soundscripts

From Valve Developer Community
Revision as of 06:59, 26 June 2009 by Corewarp (talk | contribs)
Jump to: navigation, search

Soundscripts are located within the scripts folder. The game_sounds_manifest.txt will preload or precache the soundscripts.

Example entry

entry.name
{
	channel		CHAN_AUTO
	volume		VOL_NORM
	pitch		PITCH_NORM
	soundlevel	SNDLVL_NORM
	wave		common/null.wav
}

If a value has a space or tab character within it, wrap it in "quote marks".

Tip.png Tip: To have a random numeric value chosen every time the sound plays, type a lower bound and a higher bound, separated by a comma. Example: volume 0.45,0.65.

Custom Level Soundscripts

To introduce new soundscript entries into third-party maps, create the file maps/<mapname>_level_sounds.txt and insert the entries there.

Commands

Wave

Filename of the sound to play.

wave	common/blah1.wav

You can also have the engine pick from a list of random files. A given sound won't repeat until all of the others have played. Note that the random choice is decided by the server, not the client.

rndwave
{
	wave	common/blah1.wav
	wave	common/blah2.wav
	wave	common/blah3.wav
}

Volume

A number between 0 and 1, where 1 is the sound's original volume. VOL_NORM will insert your mod's default volume, which will probably be 1.

Pitch

Any number between 0 and 255, where 100 is the sound's original pitch and 255 is high.

  • PITCH_LOW = 95
  • PITCH_HIGH = 120

Channel

To do: What does it matter which channel a sound is in?
Makes it so that entities like: env_microphone can pick it up. And will make npc's like: npc_combine_s respound differently to it. CHAN_GUNFIRE for example and so on. Basicly: Different respondses.

CHAN_AUTO
Default, generic channel.
CHAN_WEAPON
Player and NPC weaponsfire.
CHAN_VOICE
Voiceover dialogue.
CHAN_ITEM
Generic physics impact sounds, health/suit chargers, 'use' sounds.
CHAN_BODY
Clothing, ragdoll impacts, footsteps, knocking/pounding/punching etc.
CHAN_STREAM
Sounds that can be delayed by an async load, i.e. aren't responses to particular events (like Soundscapes sounds).
CHAN_REPLACE
Used when playing sounds through console commands.
CHAN_STATIC
Unknown. A sound coming from a permanently fixed location?
CHAN_VOICE_BASE
Network voice data (online voice communications)
CHAN_USER_BASE+<number>
Custom channels can be defined here.

SoundLevel

The sound's attenuation; how fast it drops away. The engine starts running into trouble below 60dB.

Code Value Description
SNDLVL_NONE 0 Silence
SNDLVL_20dB Rustling leaves
SNDLVL_25dB Whispering
SNDLVL_30dB Library
SNDLVL_35dB
SNDLVL_40dB
SNDLVL_45dB Refrigerator
SNDLVL_50dB 3.9 Average home
SNDLVL_55dB 3.0
SNDLVL_IDLE 2.0 Normal conversation, clothes dryer
SNDLVL_65dB 1.5 Washing machine, dishwasher
SNDLVL_STATIC 1.25
SNDLVL_70dB 1.0 Car, vacuum cleaner, mixer, electric sewing machine
SNDLVL_NORM 0.8 Busy traffic
SNDLVL_80dB 0.7 Mini-bike, alarm clock, noisy restaurant, office tabulator, outboard motor, passing snowmobile
SNDLVL_TALKING 0.7 Valve's chosen dialogue attenuation
SNDLVL_85dB 0.6 Average factory, electric shaver
SNDLVL_90dB 0.5 Screaming child, passing motorcycle, convertible ride on freeway
SNDLVL_95dB
SNDLVL_100dB 0.4 Subway train, diesel truck, woodworking shop, pneumatic drill, boiler shop, jackhammer
SNDLVL_105dB Helicopter, power mower
SNDLVL_110dB Snowmobile (drivers seat), inboard motorboat, sandblasting
SNDLVL_120dB Car horn, propeller aircraft
SNDLVL_130dB Air raid siren
SNDLVL_GUNFIRE 0.27 Threshold of pain, gunshot, jet engine
SNDLVL_140dB 0.2
SNDLVL_150dB 0.2
SNDLVL_180dB Rocket launching

Sound Characters

The first two characters of a WAV's name are scanned for the following:

* - CHAR_STREAM
Streams from the disc, get flushed soon after. Use for one-off dialogue files or music.
# - CHAR_DRYMIX
Bypasses DSP.
@ - CHAR_OMNI
Non-directional; audible everywhere. "Default mono or stereo", whatever that means.
> - CHAR_DOPPLER
Doppler encoded stereo: left for heading towards the listenr and right for heading away.
< - CHAR_DIRECTIONAL
Stereo with direction: left channel for front facing, right channel for rear facing. Mixed based on listener's direction.
^ - CHAR_DISTVARIANT
Distance-variant stereo. Left channel is close, right channel is far. Transition distance is hard-coded; see below.
) - CHAR_SPATIALSTEREO
Spatialized stereo - the two audio channels are to be used literally. See below.
} - CHAR_FAST_PITCH
Forces low quality, non-interpolated pitch shift.
$ - CHAR_CRITICAL
Memory resident; cache locked.
! - CHAR_SENTENCE
An NPC sentence.
? - CHAR_USERVOX
Voice chat data. You shouldn't ever need to use this.

For example:

)weapons/m4a1/m4_shoot.wav
*@npc/vo/announcer/specialoffer.wav

Stereo directionality in Source

Adding ) in front of a stereo sound name in the soundscript such as ")weapons/m4a1/m4_shoot.wav" tells the sound engine that it is a spatialized sound. Use this on any stereo sound to give it directionality. If this is not used, when a sound originates to the right or left of you it will still sound like it is directly in front of you and you will not be able to tell where the sound is coming from (important on stereo gunshots). Stereo wav's that you want directionality with MUST have ) in them. Mono's do not need them, they will be spatialized already.

Distance variance in Source

Adding ^ in front of a sound name, such as "^weapons/explode3.wav" tells the sound engine that it is a distance based sound. The left channel of the .wav is the 'near' sound that will play when the sound originates close to you, and the right channel is the 'far' sound that will play when the sound originates far from you. If the ^ mark is not used in the soundscript the sound is treated as stereo with no directionality or distance. This is a different feature than the sndlvl entry to control attenuation. This distant variant feature allows you to play two different sounds (but using only one file) and cross-fading between the two depending on how far away the sound originates. Currently the fade distances are hardcoded to begin at 20 feet (240 world units) and end at 110 feet (1320 world units) and cannot be changed in a mod.

References

  • src/public/soundflags.h
  • src/public/soundchars.h
  • scripts/game_sounds_header.txt
  • scripts/game_sounds.txt
  • scripts/game_sounds_manifest.txt