This article's documentation is for anything that uses the Source engine. Click here for more information.

Ambient generic: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
m (→‎Flags: Grammar correction)
 
(136 intermediate revisions by 43 users not shown)
Line 1: Line 1:
{{toc-right}}
{{LanguageBar}}
{{Source topicon}}
{{tabs|Ambient generic|goldsrc=1|source=1|main=source}}
{{this is a|point entity|name=ambient_generic|sprite=1}}


[[Image:Ambient generic.png|left|link=]]
{{CD|CAmbientGeneric|file1=ambientgeneric.cpp}}


{{base point|ambient_generic}} It plays a sound, either once or on loop, and either from a location in the world or globally.
This entity plays a sound, either once or on loop and either globally or from a location in the world (spatial).
{{clr|left}}
Use it to play and control a
* [[Soundscripts|soundscript]] sound,
* a raw [[WAV]], [[MP3]], [[OGG]] {{only|{{bms}}{{p2ce}}{{Garry's Mod}}{{doi}}}}, or [[FLAC]] {{p2ce|only}} file, or
* a [[sentence]].
All three can be browsed with the [[Hammer Sound Browser]], being named "Game Sounds", "Raw" and "Scenes", in this order.
{{important|The majority of sound properties that can be set with this entity are intended to only apply to '''raw''' sounds. Since soundscripts are defined in text files where their desired sound properties are specified, soundscripts ignore this entity's settings by design. Note that this also means that soundscripts have the advantage of being able to change sound files and properties in a map without having to recompile it. The same applies to [[soundscape]]s.}}


Use it to play and control a [[Soundscripts|soundscript]] sound, a raw .wav sample or a [[scripted sentence]]. Unlike textures, and models, you must restart Hammer for the sound browser to be able to see the sound.
== Bugs and caveats ==
 
{{important|Parenting is not supported (entity can be parented but the position of the sound it emits isn't updated). Proper way to have a sound follow an entity is achieved by using <code>SourceEntityName</code> {{↓|Keyvalues|keyvalue}} with targetname of an entity that is networked to client for example {{ent|info_target}} with flag '''Transmit to client''' ticked.}}
{{bug|ambient_generics used to play looping sounds in [[Counter-Strike Source]] must be activated with a [[logic_auto]] or they will stop playing once the first round starts.}}
{{bug|hidetested=1|<code>ambient_generic</code>s used to play looping sounds in {{css|2}} must be activated with a {{ent|logic_auto}}, or they will stop playing once the first round starts.}}
 
{{bug|hidetested=1|Killing this entity while a looped sound is playing will make it play forever for the entire map duration. This also may cause looping sounds to stack up and eventually overflow the sound limit (detailed below), even if they aren't audible.
{{bug|Problems with sounds being unstoppable (detailed below) can be avoided [[Ambient generic: stop and toggle fix|by adding this C++ code to your mod]].}}
{{code fix|Problems with sounds being unstoppable can be avoided [[Ambient generic: stop and toggle fix|by adding this C++ code to your mod]].|code}}}}
 
{{bug|Looping sounds might become attached to certain players when they are not supposed to. E.g., if you are away from a sound, and a player near the sound dies and then spectates you, the sound may become attached to you. The exact consistency/behavior of this bug is still unknown.}}
== See also ==
{{bug|Too many <code>ambient_generic</code>s playing at once will cause the sound engine to become corrupted globally and potentially cause extreme lag! This occurs if the internal entity sound limit of 64 (32 in {{csgo}}) is hit. Due to another bug, <code>ambient_generic</code>s still "play" when outside the maximum distance, even if not audible to the client. Use <code>snd_show 1</code> to visualize sounds considered "active". Too many yellow-colored sound names is a bad sign.}}
 
{{workaround|Use {{ent|env_soundscape}}s (which count towards a different static limit of 64) where possible and forcefully disable any sounds that aren't necessary to play yet. The amount of sounds currently playing can be visualized with the <code>snd_show</code> command.|offset=1}}
* [[env_soundscape]] - used to play many ambient/background sounds from a single entity [[soundscape|via a script]]
{{bug|Looping sounds using LFO cannot be stopped via the <code>StopSound</code> input.}}
* [[Looping a Sound]] - which requires modifying the actual .wav file
{{note|The behavior of sound is different for ''mono'' and ''stereo''. Stereo sounds only fade in and out (they are already using surrounding information built into them). Mono sounds are processed by the audio engine to sound like they are coming from a specific position. These behaviors can be overridden by using [[Soundscripts#Sound_Characters|Sound Characters]].}}
* [http://www.slackiller.com/New%20Tuts/sound.html Setting up ambient_generics in Counter-Strike: Source using logic_auto] - a substitute for creating a proper env_soundscape.
{{Note|In {{hl2|1}}, since November 26, 2024 update (post-20th anniversary), {{code|ambient_generic}} (used for music) will continue to play on the next map. This can be enabled/disabled through {{code|save_transition_music}} [[console variable]].}}


== Keyvalues ==
== Keyvalues ==
; Sound Name(message) <code><[[string]]></code>
: The [[soundscript]] name of, or direct path to, the sound to play. For [[scripted sentence]]s, type "!" followed by the sentence name. (Example: ''!COMBINE_THROW_GRENADE4'')
; Max Audible Distance <code><[[float]]></code>
: Maximum distance in [[unit]]s at which the sound plays for a client. {{note|Volume fades to nothing as the player approaches this distance, which can make it seem as if the sound stops playing too early.}}
; SourceEntityName <code><[[targetname]]></code>
: If specified, the sound will play from this entity instead of the ambient_generic. If the target is an NPC capable of lipsynching, and phoneme data is found within the sound, the target will lipsynch to it. {{bug|Upon Entity destruction, sound will play at origin (0,0,0 of map).}}
; Volume <code><[[int]] 0-10></code>
: How loud to play the sound. 0 is silent and 10 is normal. Default is 10.
; Start Volume <code><int 0-10></code>
; Fade in time in seconds <code><int 0-100></code>
; Fade out time in seconds <code><int 0-100></code>
: How long to spend fading in and out, and what volume to start at. Default is no fading.
; Pitch <int 1-255>
: Pitch, where 1 is low, 100 is normal, and 255 is high.
; Start pitch <int 1-255>
; Spin up time <code><int 0-100></code>
; Spin down time <code><int 0-100></code>
: How long to spend spinning pitch up/down at the start/end of playback, and what pitch to start at. Default is no spinning.
; Dynamic Presets <code><choices></code>
: Various [[DSP]] effects that can be applied.
; LFO type <code><int></code>
: Type of [[LFO|Low Frequency Oscillation]] to employ.
:* Off (default)
:* Square Wave (alternate between low and high)
:* Triangle Wave (sharper transitions)
:* Random
; LFO rate <code><int 0-1000></code>
: How frequently the LFO effect repeats itself. <!-- per second? -->
; LFO modulation - pitch <code><int 0-100></code>
: Affects the sound pitch or [[Wikipedia:vibrato|vibrato]]. Higher numbers change the pitch more - warbling singers use little, police sirens use a lot.
; LFO modulation - volume <code><int 0-100></code>
: Affects the volume of the sound, causing it to "pulse." Similar to [[Wikipedia:tremolo|tremolo]].
; Incremental Spinup Count <code><int></code>
: Appears to be a intended to increase pitch in time with <code>ToggleSound</code> inputs, but: {{bug|Non-functional.}}
{{KV Targetname}}
{{KV Targetname}}
{{KV|Sound Name|intn=message|sound|The sound to play. Can be:}}
:* A [[soundscript]] name.
:* A raw file, as a direct path to a sound file relative to {{path|<moddir>/sounds/}}. Direct paths to a sound file can be prefixed with [[Soundscripts#Sound characters|sound characters]].
:* A [[sentence]], prefixed with <code>!</code>, for example <code style=white-space:nowrap>!COMBINE_THROW_GRENADE4</code>.


== Flags ==
{{KV|Max Audible Distance|intn=radius|float|
Rough (!) distance in [[unit]]s at which the sound is audible for a client. Volume fades to nothing as the player approaches this distance but it cannot be expected to be exact. This determines the [[Soundscripts#SoundLevel|soundlevel]] for raw sounds, which is <code>SNDLVL_70dB</code> at the default value of 1250 units. [[DSP]] may affect the actual audible radius, too. The sound system still actually plays the sound outside the distance, which is why [[soundscape]]s may be a better solution for environmental sounds.
}}
{{KV|SourceEntityName|intn=SourceEntityName|targetname|If specified, the sound will play from the first entity by this name it finds instead of the <code>ambient_generic</code>. If the target is an NPC capable of lipsynching, and phoneme data is found within the sound, the target will lip-sync to it.{{warning|If the <code>ambient_generic</code> is [[kill]]ed, the sound will play at the origin of the map (at 0,0,0).}}{{important|The source entity must exist when ambient_generic is being spawned, or else the sound will play at the location of the <code>ambient_generic</code>.}}{{note|Using [[AddOutput]] to assign the <code>SourceEntityName</code> is not supported.}}}}
{{KV|Volume|intn=health|int 0-10|How loud to play the sound. 0 is silent and 10 is normal. Default is 10.{{tip|This keyvalue doesn't allow decimals, but the <code>Volume</code> input does.}}{{tip|Sounds may be hard to hear even at full volume. Naming custom sounds according to the [[soundmixer]] can be used to make them naturally louder (or quieter).}}}}
{{KV|Start Volume|intn=volstart|int 0-10}}
{{KV|Fade in time in seconds|intn=fadeinsecs|int 0-100}}
{{KV|Fade out time in seconds|intn=fadeoutsecs|int 0-100|How long to spend fading in and out, and what volume to start at. Default is no fading.}}
{{KV|Pitch|intn=pitch|int 0-255|Pitch, where 1 is low, 100 is normal, and 255 is high.{{bug|Very high or very low values can cause other sounds to be distorted.}}}}
{{KV|Start pitch|intn=pitchstart|int 0-255}}
{{KV|Spin up time|intn=spinup|int 0-100}}
{{KV|Spin down time|intn=spindown|int 0-100|How long to spend spinning pitch up/down at the start/end of playback, and what pitch to start at. Default is no spinning.}}
{{KV|Dynamic Presets|intn=preset|choices|Various [[DSP]] effects that can be applied.}}
{{KV|LFO type|intn=lfotype|int|Type of [[LFO|Low Frequency Oscillation]] to employ.
:0. Off (default)
:1. Square Wave (alternate between low and high)
:2. Triangle Wave (crossfade between high and low)
:3. Random}}
{{KV|LFO rate|intn=lforate|int 0-1000|How frequently the LFO effect repeats itself.}}
{{KV|LFO modulation - pitch|intn=lfomodpitch|int 0-100|Affects the sound pitch or [[Wikipedia:vibrato|vibrato]]. Higher numbers change the pitch more; warbling singers use little, police sirens use a lot.}}
{{KV|LFO modulation - volume|intn=lfomodvol|int 0-100|Affects the volume of the sound, causing it to "pulse." Similar to [[Wikipedia:tremolo|tremolo]]. At a really high rate, this can make the same effect as talking through fan blades.}}
{{KV|Incremental Spinup Count|intn=cspinup|int|Appears to be a intended to increase pitch in time with <code>ToggleSound</code> inputs. {{bug|Non-functional.}}}}


*1 : Play everywhere
{{KV|m_bDontModifyPitchVolOnSpawn|intn=m_bDontModifyPitchVolOnSpawn|bool|When the 'Start Silent' flag is left unchecked, a SOUNDSCRIPTED ambient_generic will first pull its pitch & volume values from inside the entity itself upon map load/spawn, and NOT from what's dictated in the actual soundscript. This option, when enabled, will prevent this from happening and ensure no discontinuity occurs when toggling the sound off and on again. (Set to Disabled by default)|only={{BMS}}}}
*:Sound always plays from all speakers at its configured volume. It doesn't bypass DSP effects, however. {{bug|This flag '''is broken at engine level''' for [[Soundscripts]]. It will only work when a sound is played with its raw filename.}}
*16 : Start Silent
: The map will start without this sound playing. Enabled by default. {{bug|Looping sounds that do not start silent cannot be controlled!}}
*32 : Is NOT Looped
: Changes how the ambient_generic handles stopping and starting playback. It ''won't'' stop a sound that loops from looping, but it is still '''very important''' to set it to the right value. You might not be able to stop and/or start the sound if it isn't! {{bug|Having this option ticked while using a looped sound WILL prevent you from controlling it!}}


== Inputs ==
== Inputs ==
{{I|Pitch|param=int|If sound is not playing this will play the sound with specified pitch. If sound is playing it changes its pitch. Pitch is expressed as a range from 1 to 255, where 100 is the sound's original pitch.
:{{note|Doesn't change the pitch keyvalue. Any PlaySound inputs used after this will play the sound with value set in pitch keyvalue which can be changed via [[AddOutput]].}}
:{{bug|tested=Half-Life 2|If used to start playing a looping sound then in order to stop it the PlaySound must be sent before StopSound otherwise StopSound will have no effect.}}}}
{{I|PlaySound|Starts the sound.}}
{{I|StopSound|Stops a looping sound. Does ''not'' stop a non-looping sound; however, a non-looping sound can be stopped by using the Volume input with a value of 0.{{ModernFix|If necessary, you can allow this input to stop a non-looping sound [[Ambient generic: stop and toggle fix|via C++]].|code}}}}
{{I|ToggleSound|Toggles a looping sound between playing and stopped. Behaves like <code>PlaySound</code> if the sound doesn't loop.}}
{{I|Volume|param=float|Plays the sound at a volume from 0 to 10, where 10 is the loudest.{{bug|Volume will play the sound without informing the rest of the entity. This makes looping sounds unstoppable! It is speculated that the input is supposed to change the volume at which the <code>ambient_generic</code> plays its sound when prompted by other inputs, not play it by itself.}}{{note|Setting the volume to 0 will cause the sound to pause, rather than play silently.}}}}
{{I|FadeIn|param=int|Fades the sound up to full volume over a specified number of seconds, with a range from 0 to 100 seconds.{{note|In {{portal2|4}} it is necessary for the sound to get faded out at least once before this input has any effect.}}}}
{{I|FadeOut|param=int|Fades the sound to silence over a specified number of seconds, with a range from 0 to 100 seconds.{{bug|tested={{hl2}}|Will bring the sound up to full volume (i.e., 10) before beginning to fade it. If the sound has already played once, it might play the sound from the beginning before fading it.}}}}


;Pitch <code><[[int]]></code>
== Flags ==
:Sets the sound pitch, expressed as a range from 1 to 255, where 100 is the sound's original pitch. {{bug|Pitch will play the sound without informing the rest of the entity. This makes looping sounds unstoppable! It is speculated that the input is supposed to change the pitch at which the ambient_generic plays its sound when prompted by other inputs, not play it by itself.}}
{{fl|1|Play everywhere|Sound plays at a constant volume, no matter how far away the listener is from the sound source. This applies only to raw sound, not to soundscripts. {{todo|How does this interact with {{ent|env_microphone}} sound detection?}}}}
; <code>PlaySound</code>
{{fl|16|Start Silent|The map will start without this sound playing. Enabled by default.{{bug|Looping sounds that do not start silent cannot be controlled!}}}}
: Starts the sound.
{{fl|32|Not toggled (Is NOT looped)|Changes how the <code>ambient_generic</code> handles stopping and starting playback; enable this for non-looping sounds. In fact, this flag doesn't let you decide whether or not to loop the sound file, instead the sound system needs it to be set to the right value to start and stop the sound properly. Sound files with [[Looping a sound|loop markers]] always loop, files without never loop. If a sound doesn't do what you expect, then the sound file probably has no loop markers although it should, or vice versa. {{bug|In multiplayer, if this flag is NOT set on a non-looping sound and any player's connection is briefly dropped, the sound will play again for everyone in the server! This is due to the entity recalculating its networking state and re-sending it to that player, but it unfortunately sends it to everyone else as well. Looping sounds don't have this problem as they do not restart while already playing.}}}}
; <code>StopSound</code>
{{fl|64|Do NOT Pause when game is Paused|Don't pause sound when game is paused.|only=BMS}}
: Stops a looping sound. Does ''not'' stop a non-looping sound: this is intentional, and can be changed [[Ambient generic: stop and toggle fix|with C++]].
; <code>ToggleSound</code>
: Toggles a looping sound between playing and stopped. Behaves like <code>PlaySound</code> if the sound is unlooped.
; <code>Volume <int></code>
: Plays the sound at a volume from 0 to 10, where 10 is the loudest. {{bug|Volume will play the sound without informing the rest of the entity. This makes looping sounds unstoppable! It is speculated that the input is supposed to change the volume at which the ambient_generic plays its sound when prompted by other inputs, not play it by itself.}}
; <code>FadeIn <int></code>
:Fades the sound up to full volume over a specified number of seconds, with a range from 0 to 100 seconds. {{bug|Non-functional.}}
; <code>FadeOut <int></code>
:Fades the sound to silence over a specified number of seconds, with a range from 0 to 100 seconds. {{bug|Will bring the sound up to full volume (i.e. 10) before beginning to fade it.}}
{{I Targetname}}
 
== Outputs ==
 
{{O Targetname}}


== See also ==
* [[Sound and Music]]
* [http://www.gamebanana.com/tuts/5141 Adjust ambient_generic volume higher than 10] (Advanced Mapping Tutorial)
* {{ent|env_soundscape}} - used to play many ambient/background sounds from a single entity [[soundscape|via a script]].
* {{ent|music_track}} - used to dynamically play music in {{bms|4}}.
* [[Looping a Sound]] - which requires modifying the actual [[WAV]] file
* [http://www.slackiller.com/New%20Tuts/sound.html Setting up <tt>ambient_generic</tt>s in Counter-Strike: Source using <tt>logic_auto</tt>] - a substitute for creating a proper <code>env_soundscape</code>.
[[Category:Sound System]]
[[Category:Sound System]]

Latest revision as of 14:11, 30 August 2025

English (en)Français (fr)Hrvatski (hr)Русский (ru)中文 (zh)Translate (Translate)

Ambient generic.png

ambient_generic is a point entity available in all Source Source games.

C++ Class hierarchy
CAmbientGeneric
CPointEntity
CBaseEntity
C++ sound.cpp

This entity plays a sound, either once or on loop and either globally or from a location in the world (spatial).

Use it to play and control a

All three can be browsed with the Hammer Sound Browser, being named "Game Sounds", "Raw" and "Scenes", in this order.

Icon-Important.pngImportant:The majority of sound properties that can be set with this entity are intended to only apply to raw sounds. Since soundscripts are defined in text files where their desired sound properties are specified, soundscripts ignore this entity's settings by design. Note that this also means that soundscripts have the advantage of being able to change sound files and properties in a map without having to recompile it. The same applies to soundscapes.

Bugs and caveats

Icon-Important.pngImportant:Parenting is not supported (entity can be parented but the position of the sound it emits isn't updated). Proper way to have a sound follow an entity is achieved by using SourceEntityName keyvalue ↓ with targetname of an entity that is networked to client for example info_target with flag Transmit to client ticked.
Icon-Bug.pngBug:ambient_generics used to play looping sounds in Counter-Strike: Source Counter-Strike: Source must be activated with a logic_auto, or they will stop playing once the first round starts.
Icon-Bug.pngBug:Killing this entity while a looped sound is playing will make it play forever for the entire map duration. This also may cause looping sounds to stack up and eventually overflow the sound limit (detailed below), even if they aren't audible.
Cpp.pngCode Fix:Problems with sounds being unstoppable can be avoided by adding this C++ code to your mod.
Icon-Bug.pngBug:Looping sounds might become attached to certain players when they are not supposed to. E.g., if you are away from a sound, and a player near the sound dies and then spectates you, the sound may become attached to you. The exact consistency/behavior of this bug is still unknown.  [todo tested in ?]
Icon-Bug.pngBug:Too many ambient_generics playing at once will cause the sound engine to become corrupted globally and potentially cause extreme lag! This occurs if the internal entity sound limit of 64 (32 in Counter-Strike: Global Offensive) is hit. Due to another bug, ambient_generics still "play" when outside the maximum distance, even if not audible to the client. Use snd_show 1 to visualize sounds considered "active". Too many yellow-colored sound names is a bad sign.  [todo tested in ?]
PlacementTip.pngWorkaround:Use env_soundscapes (which count towards a different static limit of 64) where possible and forcefully disable any sounds that aren't necessary to play yet. The amount of sounds currently playing can be visualized with the snd_show command.
Icon-Bug.pngBug:Looping sounds using LFO cannot be stopped via the StopSound input.  [todo tested in ?]
Note.pngNote:The behavior of sound is different for mono and stereo. Stereo sounds only fade in and out (they are already using surrounding information built into them). Mono sounds are processed by the audio engine to sound like they are coming from a specific position. These behaviors can be overridden by using Sound Characters.
Note.pngNote:In Half-Life 2, since November 26, 2024 update (post-20th anniversary), ambient_generic (used for music) will continue to play on the next map. This can be enabled/disabled through save_transition_music console variable.

Keyvalues

Name (targetname) <string>[ Edit ]
The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g. parentname or target).
Also displayed in Hammer's 2D views and Entity Report.
See also:  Generic Keyvalues, Inputs and Outputs available to all entities

Sound Name (message) <sound>
The sound to play. Can be:
  • A soundscript name.
  • A raw file, as a direct path to a sound file relative to 🖿<moddir>/sounds/. Direct paths to a sound file can be prefixed with sound characters.
  • A sentence, prefixed with !, for example !COMBINE_THROW_GRENADE4.


Max Audible Distance (radius) <float>
Rough (!) distance in units at which the sound is audible for a client. Volume fades to nothing as the player approaches this distance but it cannot be expected to be exact. This determines the soundlevel for raw sounds, which is SNDLVL_70dB at the default value of 1250 units. DSP may affect the actual audible radius, too. The sound system still actually plays the sound outside the distance, which is why soundscapes may be a better solution for environmental sounds.
SourceEntityName (SourceEntityName) <targetname>
If specified, the sound will play from the first entity by this name it finds instead of the ambient_generic. If the target is an NPC capable of lipsynching, and phoneme data is found within the sound, the target will lip-sync to it.
Warning.pngWarning:If the ambient_generic is killed, the sound will play at the origin of the map (at 0,0,0).
Icon-Important.pngImportant:The source entity must exist when ambient_generic is being spawned, or else the sound will play at the location of the ambient_generic.
Note.pngNote:Using AddOutput to assign the SourceEntityName is not supported.
Volume (health) <integer 0–10>
How loud to play the sound. 0 is silent and 10 is normal. Default is 10.
Tip.pngTip:This keyvalue doesn't allow decimals, but the Volume input does.
Tip.pngTip:Sounds may be hard to hear even at full volume. Naming custom sounds according to the soundmixer can be used to make them naturally louder (or quieter).
Start Volume (volstart) <integer 0–10>
Fade in time in seconds (fadeinsecs) <integer 0–100>
Fade out time in seconds (fadeoutsecs) <integer 0–100>
How long to spend fading in and out, and what volume to start at. Default is no fading.
Pitch (pitch) <integer 0–255>
Pitch, where 1 is low, 100 is normal, and 255 is high.
Icon-Bug.pngBug:Very high or very low values can cause other sounds to be distorted.  [todo tested in ?]
Start pitch (pitchstart) <integer 0–255>
Spin up time (spinup) <integer 0–100>
Spin down time (spindown) <integer 0–100>
How long to spend spinning pitch up/down at the start/end of playback, and what pitch to start at. Default is no spinning.
Dynamic Presets (preset) <choices>
Various DSP effects that can be applied.
LFO type (lfotype) <integer>
Type of Low Frequency Oscillation to employ.
0. Off (default)
1. Square Wave (alternate between low and high)
2. Triangle Wave (crossfade between high and low)
3. Random
LFO rate (lforate) <integer 0–1000>
How frequently the LFO effect repeats itself.
LFO modulation - pitch (lfomodpitch) <integer 0–100>
Affects the sound pitch or vibrato. Higher numbers change the pitch more; warbling singers use little, police sirens use a lot.
LFO modulation - volume (lfomodvol) <integer 0–100>
Affects the volume of the sound, causing it to "pulse." Similar to tremolo. At a really high rate, this can make the same effect as talking through fan blades.
Incremental Spinup Count (cspinup) <integer>
Appears to be a intended to increase pitch in time with ToggleSound inputs.
Icon-Bug.pngBug:Non-functional.  [todo tested in ?]


m_bDontModifyPitchVolOnSpawn (m_bDontModifyPitchVolOnSpawn) <boolean> (only in Black Mesa)
When the 'Start Silent' flag is left unchecked, a SOUNDSCRIPTED ambient_generic will first pull its pitch & volume values from inside the entity itself upon map load/spawn, and NOT from what's dictated in the actual soundscript. This option, when enabled, will prevent this from happening and ensure no discontinuity occurs when toggling the sound off and on again. (Set to Disabled by default)

Inputs

Pitch <integerRedirectInput/integer>
If sound is not playing this will play the sound with specified pitch. If sound is playing it changes its pitch. Pitch is expressed as a range from 1 to 255, where 100 is the sound's original pitch.
Note.pngNote:Doesn't change the pitch keyvalue. Any PlaySound inputs used after this will play the sound with value set in pitch keyvalue which can be changed via AddOutput.
Icon-Bug.pngBug:If used to start playing a looping sound then in order to stop it the PlaySound must be sent before StopSound otherwise StopSound will have no effect.  (tested in: Half-Life 2)
PlaySound
Starts the sound.
StopSound
Stops a looping sound. Does not stop a non-looping sound; however, a non-looping sound can be stopped by using the Volume input with a value of 0.
Cpp.pngCode Fix:If necessary, you can allow this input to stop a non-looping sound via C++.
ToggleSound
Toggles a looping sound between playing and stopped. Behaves like PlaySound if the sound doesn't loop.
Volume <floatRedirectInput/float>
Plays the sound at a volume from 0 to 10, where 10 is the loudest.
Icon-Bug.pngBug:Volume will play the sound without informing the rest of the entity. This makes looping sounds unstoppable! It is speculated that the input is supposed to change the volume at which the ambient_generic plays its sound when prompted by other inputs, not play it by itself.  [todo tested in ?]
Note.pngNote:Setting the volume to 0 will cause the sound to pause, rather than play silently.
FadeIn <integerRedirectInput/integer>
Fades the sound up to full volume over a specified number of seconds, with a range from 0 to 100 seconds.
Note.pngNote:In Portal 2 Portal 2 it is necessary for the sound to get faded out at least once before this input has any effect.
FadeOut <integerRedirectInput/integer>
Fades the sound to silence over a specified number of seconds, with a range from 0 to 100 seconds.
Icon-Bug.pngBug:Will bring the sound up to full volume (i.e., 10) before beginning to fade it. If the sound has already played once, it might play the sound from the beginning before fading it.  (tested in: Half-Life 2)

Flags

Play everywhere : [1]
Sound plays at a constant volume, no matter how far away the listener is from the sound source. This applies only to raw sound, not to soundscripts.
Todo: How does this interact with env_microphone sound detection?
Start Silent : [16]
The map will start without this sound playing. Enabled by default.
Icon-Bug.pngBug:Looping sounds that do not start silent cannot be controlled!  [todo tested in ?]
Not toggled (Is NOT looped) : [32]
Changes how the ambient_generic handles stopping and starting playback; enable this for non-looping sounds. In fact, this flag doesn't let you decide whether or not to loop the sound file, instead the sound system needs it to be set to the right value to start and stop the sound properly. Sound files with loop markers always loop, files without never loop. If a sound doesn't do what you expect, then the sound file probably has no loop markers although it should, or vice versa.
Icon-Bug.pngBug:In multiplayer, if this flag is NOT set on a non-looping sound and any player's connection is briefly dropped, the sound will play again for everyone in the server! This is due to the entity recalculating its networking state and re-sending it to that player, but it unfortunately sends it to everyone else as well. Looping sounds don't have this problem as they do not restart while already playing.  [todo tested in ?]
Do NOT Pause when game is Paused : [64] (only in Black Mesa)
Don't pause sound when game is paused.

See also