Soundscripts: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Clarification of comma in value)
(started trying to make more sense of the various flags)
Line 1: Line 1:
[[Category:Sound System]]
[[Category:Sound System]]
Soundscripts are located within the scripts folder. The game_sounds_manifest.txt will preload or precache the soundscripts.
Soundscripts are located within the scripts folder. The game_sounds_manifest.txt will preload or precache the soundscripts.
==Example Soundscript Entry==
==Example Soundscript Entry==
  "entry.name"
  "entry.name"
  {
  {
Line 10: Line 12:
  "wave"      "common/null.wav"
  "wave"      "common/null.wav"
  }
  }
==Custom Level Soundscripts==
==Custom Level Soundscripts==
To introduce new soundscript entries into third-party maps, create the file <code>maps/mapname_level_sounds.txt</code> and insert the entries there.
To introduce new soundscript entries into third-party maps, create the file <code>maps/mapname_level_sounds.txt</code> and insert the entries there.
==Soundflags for Soundscripts==
 
==Soundflags==
 
===Channel Flags===
===Channel Flags===
* CHAN_REPLACE = -1,
 
* CHAN_AUTO = 0,
;CHAN_REPLACE
* CHAN_WEAPON = 1,
:Unknown.
* CHAN_VOICE = 2,
;CHAN_AUTO
* CHAN_ITEM = 3,
:Default, generic channel.
* CHAN_BODY = 4,
;CHAN_WEAPON
* CHAN_STREAM = 5, // allocate stream channel from the static or dynamic area
:Player and NPC weaponsfire.
* CHAN_STATIC = 6, // allocate channel from the static area
;CHAN_VOICE
* CHAN_VOICE_BASE = 7, // allocate channel for network voice data
:Voiceover dialogue.
* CHAN_USER_BASE = (CHAN_VOICE_BASE+128) // Anything >= this number is allocated to game code.
;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 asynch load, i.e. aren't responses to particular events (like [[Soundscape]] sounds).
;CHAN_STATIC = 6
: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===
===Volume Flags===
* VOL_NORM // 1.0 full volume
* VOL_NORM // 1.0 full volume
* 0.0 // off
* 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)
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 Flags===
* PITCH_NORM 100 // non-pitch shifted
* PITCH_NORM 100 // non-pitch shifted
* PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
* PITCH_LOW 95 // other values are possible - 0-255, where 255 is very high
* PITCH_HIGH 120
* PITCH_HIGH 120
another example: "pitch" "95,120" (each time the sound is played, it would have a random pitch between 95, 120)
another example: "pitch" "95,120" (each time the sound is played, it would have a random pitch between 95, 120)
===SoundLevel Flags===
===SoundLevel Flags===
* SNDLVL_NONE = 0,
* SNDLVL_NONE = 0,
* SNDLVL_20dB = 20, // rustling leaves
* SNDLVL_20dB = 20, // rustling leaves
Line 64: Line 87:
* SNDLVL_150dB = 150, // 0.2
* SNDLVL_150dB = 150, // 0.2
* SNDLVL_180dB = 180, // rocket launching
* SNDLVL_180dB = 180, // rocket launching
===Wave Flag===
===Wave Flag===
<pre>
 
  "rndwave" // plays more than one wave file in a random order
  "rndwave" // plays more than one wave file in a random order
  {
  {
Line 72: Line 96:
  "wave" "common/blah3.wav"
  "wave" "common/blah3.wav"
  }
  }
</pre>
 
==Sound Characters for Soundscripts==
==Sound Characters==
 
*CHAR_STREAM '*'
*CHAR_STREAM '*'
// as one of 1st 2 chars in name, indicates streaming wav data
// as one of 1st 2 chars in name, indicates streaming wav data
Line 96: Line 121:
*CHAR_CRITICAL '$'
*CHAR_CRITICAL '$'
// as one of 1st 2 chars in name, memory resident, cache locked
// as one of 1st 2 chars in name, memory resident, cache locked
===Stereo Sound Directionality in Source===
===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.   
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===
===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.
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==
==References==
* '''src/public/soundflags.h''' from create a mod, source sdk
* '''src/public/soundflags.h''' from create a mod, source sdk
* '''src/public/soundchars.h''' from create a mod, source sdk
* '''src/public/soundchars.h''' from create a mod, source sdk

Revision as of 09:09, 28 January 2007

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
Unknown.
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 asynch load, i.e. aren't responses to particular events (like Soundscape sounds).
CHAN_STATIC = 6
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

  • CHAR_STREAM '*'

// as one of 1st 2 chars in name, indicates streaming wav data

  • CHAR_USERVOX '?'

// as one of 1st 2 chars in name, indicates user realtime voice data

  • CHAR_SENTENCE '!'

// as one of 1st 2 chars in name, indicates sentence wav

  • CHAR_DRYMIX '#'

// as one of 1st 2 chars in name, indicates wav bypasses dsp fx

  • CHAR_DOPPLER '>'

// as one of 1st 2 chars in name, indicates doppler encoded stereo wav: left wav (incomming) and right wav (outgoing).

  • CHAR_DIRECTIONAL '<'

// as one of 1st 2 chars in name, indicates stereo wav has direction cone: mix left wav (front facing) with right wav (rear facing) based on soundfacing direction

  • CHAR_DISTVARIANT '^'

// as one of 1st 2 chars in name, indicates distance variant encoded stereo wav (left is close, right is far)

  • CHAR_OMNI '@'

// as one of 1st 2 chars in name, indicates non-directional wav (default mono or stereo)

  • CHAR_SPATIALSTEREO ')'

// as one of 1st 2 chars in name, indicates spatialized stereo wav

  • CHAR_FAST_PITCH '}'

// as one of 1st 2 chars in name, forces low quality, non-interpolated pitch shift

  • CHAR_CRITICAL '$'

// as one of 1st 2 chars in name, memory resident, cache locked

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