Soundmixer

From Valve Developer Community
Jump to navigation Jump to search

Overview

Soundmixers define volume control over various sound categories, known as 'mix groups'. Sounds will be automatically assigned to the corresponding mixer group at runtime using the file name (matched by substring), entity classname, channel, and soundlevel. These criteria can be used by themselves or combined to filter out very specific sounds. Custom sounds can be put under these categories by naming them accordingly, to make them louder (or quieter) than normally possible without stacking. Custom mix groups and rules can also be made, but there are limits:

  • Up to 64 unique mix groups
  • Up to 76 group rules entries
  • Up to 32 sound mixers
  • All strings are limited to 31 characters!

Usage

Soundmixers can be used to ensure that important dialogue is clearly heard despite ambient noise, sounds of combat, or other characters talking; to tone down excessively loud effects and preventing them from drowning out sounds; to imitate feeling of concussion or hearing loss; even to make surreal-sounding soundscapes where playback of sounds defies conventional expectations.

An example of usage: Team Fortress 2 Team Fortress 2 uses a freeze-cam specific soundmixer to quieten most sounds in the game except for player dialog and important sound cue.

Soundmixers are meant to be applied within soundscapes. A soundscape can define an existing soundmixer and, when that soundscape is active, the soundmixer will adjust the volume of the sounds based on the soundmixer's rules. High-priority sounds that are set to higher value, will play at that value and lower-priority sounds will not be allowed to go "over" them. Conversely, sounds with lowered value will sound quieter than they usually would. Sounds with higher priority can make other sounds "duck" in volume, by using "causes ducking" and "is ducked" values.

Note.pngNote:All soundscapes use soundmixer "Default_Mix" unless another is specified. That means that transitioning from a soundscape with your soundmixer, to another, even if it doesn't explicitly specify a soundmixer, will cause it to reset to "Default_Mix".
Tip.pngTip:The active soundmixer can be seen (and specified) by using snd_soundmixer command.
Tip.pngTip:Use command snd_showmixer 1 to turn on the mixer interface which lets you see the mix groups in use, their mix values and volume meter during playback.

For example, creating a new mixer with the following rules

// add this within GROUPRULES table
// group name | directory or .wav name | classname | channel | sndlvl_min | sndlvl_max | priority | is ducked | causes ducking | duck to % | duck threshold
"awesome_sounds" "/my_awesome_sounds"        ""         ""         ""          ""         "100"        "0"            "0"           "100"          "0"

// add this below GROUPRULES table
"soundmixer_test"
{
	"awesome_sounds" 		"0.05"
	
	"All"				"1"
}

And referencing it in the soundscape

soundscape_test
{	
	"soundmixer" "soundmixer_test"
	
	// the rest is whatever your soundscape is...
	"dsp" "1"
}

Will mean that, while that soundscape is active, all sounds matching the group rule (in that example, all sounds down the path of sound\my_awesome_sounds) play only at 5% of their normal volume, and all others at 100%. This applies to any sounds matching the group criteria, not just the ones emitted by the active soundscape - so it will affect ambient_generics, NPC, gunfire, etc.

Other examples:

Using a soundmixer to tone down a particularly loud sound effect

Add this within GROUPRULES table, toward the top for more specific rules, or toward the bottom for more general rules

This rule looks up sounds that are in the dropship folder AND are loud (soundlevel above 120 dB)

"Dropship_Fly" "/combine_gunship/dropship_" ""	""	"121"	""	"50"	"0"	"0"	"100"	"0"

Add this entry below GROUPRULES table:

"soundmixer_quiet_dropship"
{
	// the dropship fly loop is overbearing in our map. Tone it down in the soundscapes in the area where it's heard.
	"Dropship_Fly"			"0.40"

	// the rest of values is copied from Valve's "Default_mix"
	"Explosions"			"0.90"
	"Player_Weapons_Loud"	"1.0"
	"Player_Suit"			"0.56"
	"Weapons"				"0.79"

	"AHELI_WEAPON"			"0.85"
	"GUNSHIP_WEAPON"		"0.85"
	"STRIDER_WEAPON"		"0.85"
	"bullethit"				"0.67"
	
	"Music"					"1.0"
	
	"All"					"0.72"
}

Reference your soundmixer in the soundscape:

soundscape_dropship_area // the area where dropship flies by
{	
	"soundmixer" "soundmixer_quiet_dropship"
	
	// the rest is whatever your soundscape is...
	"dsp" "1"
	"playsoundscape" "d1_canals_watercanal"
}
Todo: Left 4 Dead 2 has an extended soundmixers system which also needs to be documented. Mix layers have two additional columns which have unknown purpose.
Todo: Add explanation on ducking.
The quick summary is sounds with high priority that have "causes ducking" "1" will cause sounds with lower priority than them, that also have "is ducked" "1", to become muffled during high priority sounds' playback.
Todo: Also explain how ordering of grouprules matters. The top is for more specific ones, the bottom is for more general ones. What is different about placing one rule above another, then using both within a soundmixer?

Game-specific soundmixer list