Soundscripts

From Valve Developer Community
Revision as of 09:08, 2 September 2008 by TomEdwards (talk | contribs) (→‎Sound Characters: cleaned)
Jump to navigation Jump to search

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

Example Soundscript Entry

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

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.

Soundflags

Channel Flags

CHAN_REPLACE
Used when playing sounds through console commands.
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_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.

Volume Flags

  • VOL_NORM // 1.0 full volume
  • 0.0 // off

another example: "volume" "0.45,0.65" (each time the sound is played, it would have a random volume between .45 and .65)

Pitch Flags

  • PITCH_NORM 100 // non-pitch shifted
  • PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
  • PITCH_HIGH 120

another example: "pitch" "95,120" (each time the sound is played, it would have a random pitch between 95, 120)

SoundLevel Flags

  • SNDLVL_NONE = 0,
  • SNDLVL_20dB = 20, // rustling leaves
  • SNDLVL_25dB = 25, // whispering
  • SNDLVL_30dB = 30, // library
  • SNDLVL_35dB = 35,
  • SNDLVL_40dB = 40,
  • SNDLVL_45dB = 45, // refrigerator
  • SNDLVL_50dB = 50, // 3.9 // average home
  • SNDLVL_55dB = 55, // 3.0
  • SNDLVL_IDLE = 60, // 2.0
  • SNDLVL_60dB = 60, // 2.0 // normal conversation, clothes dryer
  • SNDLVL_65dB = 65, // 1.5 // washing machine, dishwasher
  • SNDLVL_STATIC = 66, // 1.25
  • SNDLVL_70dB = 70, // 1.0 // car, vacuum cleaner, mixer, electric sewing machine
  • SNDLVL_NORM = 75,
  • SNDLVL_75dB = 75, // 0.8 // busy traffic
  • SNDLVL_80dB = 80, // 0.7 // mini-bike, alarm clock, noisy restaurant, office tabulator, outboard motor, passing snowmobile
  • SNDLVL_TALKING = 80, // 0.7
  • SNDLVL_85dB = 85, // 0.6 // average factory, electric shaver
  • SNDLVL_90dB = 90, // 0.5 // screaming child, passing motorcycle, convertible ride on frw
  • SNDLVL_95dB = 95,
  • SNDLVL_100dB = 100, // 0.4 // subway train, diesel truck, woodworking shop, pneumatic drill, boiler shop, jackhammer
  • SNDLVL_105dB = 105, // helicopter, power mower
  • SNDLVL_110dB = 110, // snowmobile drvrs seat, inboard motorboat, sandblasting
  • SNDLVL_120dB = 120, // auto horn, propeller aircraft
  • SNDLVL_130dB = 130, // air raid siren
  • SNDLVL_GUNFIRE = 140, // 0.27 // THRESHOLD OF PAIN, gunshot, jet engine
  • SNDLVL_140dB = 140, // 0.2
  • SNDLVL_150dB = 150, // 0.2
  • SNDLVL_180dB = 180, // rocket launching

Wave Flag

"rndwave" // plays more than one wave file in a random order
{
	"wave" 	"common/blah1.wav"
	"wave" 	"common/blah2.wav"
	"wave" 	"common/blah3.wav"
}

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_SENTENCE
An NPC sentence.
# - CHAR_DRYMIX
Bypasses DSP.
> - 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_OMNI
Non-directional; audible everywhere. "Default mono or stereo", whatever that means.
) - 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_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 Sound 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.

Distant Variant Sounds 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 from create a mod, source sdk
  • src/public/soundchars.h from create a mod, source sdk
  • scripts/game_sounds_header.txt from create a mod, source sdk
  • scripts/game_sounds.txt from create a mod, source sdk
  • scripts/game_sounds_manifest.txt from create a mod, source sdk