Ambient generic
Jump to navigation
Jump to search

This entity is also available as [[{{{1}}}|{{{1}}}]] for the Half-Life Engine.
Entity description
It plays a sound, either once or on loop, and either from a location in the world or globally.
Use it to play and control a 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.

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. [todo tested in ?]
Bug:Problems with sounds being unstoppable (detailed below) can be avoided by adding this C++ code to your mod. [todo tested in ?]
Bug:Killing this entity while a looped sound is playing will make it play forever for the entire map duration. [todo tested in ?]
Bug:The ambient_generic will not update its position while the sound is playing if parented. [todo tested in ?]
Bug:Too many ambient_generics playing at once will cause other the sound engine to become corrupted globally and cause extreme lag! This is related to the internal sound limit of roughly 64 sounds. Due to another bug, ambient_generics still "play" when outside the distance, even if not audible to the client. [todo tested in ?]
Keyvalues
- Sound Name (message)
<string>
- The soundscript name of, or direct path to, the sound to play. For scripted sentences, type "!" followed by the sentence name. (Example: !COMBINE_THROW_GRENADE4)
Note:Music should be flagged as music with the '#' character before the sound path (e.g. #music/song01.wav) and placed in "sound/music/..." directory in order for it to be affected by the "Music Volume" slider in the options menu.
- Max Audible Distance
<float>
- Maximum distance in units at which the sound plays for a client.
Bug:The sound still actually plays outside the distance. [todo tested in ?]
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
<targetname>
- 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 lip-sync to it.
Bug:If the ambient_generic is killed, the sound will play at the origin of the map (at 0,0,0). [todo tested in ?]
Bug:Entity must be spawned at map start, or else sound will play at the location of the ambient_generic. Using AddOutput to assign the SourceEntityName after the entity spawns does not work. [todo tested in ?]
Bug:Multiple ambient_generics won't stack on the same entity. [todo tested in ?]
- Volume
<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 Volume input does.
Bug:The sound does not play at all if the volume is 0. [todo tested in ?]
- Start Volume
<int 0-10>
- Fade in time in seconds
<int 0-100>
- Fade out time in seconds
<int 0-100>
- 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.
Bug:Very high or very low values can cause other sounds to be distorted. [todo tested in ?]
- Start pitch <int 1-255>
- Spin up time
<int 0-100>
- Spin down time
<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.
- Dynamic Presets
<choices>
- Various DSP effects that can be applied.
- LFO type
<int>
- Type of Low Frequency Oscillation to employ.
- Off (default)
- Square Wave (alternate between low and high)
- Triangle Wave (crossfade between high and low)
- Random
- LFO rate
<int 0-1000>
- How frequently the LFO effect repeats itself.
- LFO modulation - pitch
<int 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
<int 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
<int>
- Appears to be a intended to increase pitch in time with
ToggleSound
inputs, but:Bug:Non-functional. [todo tested in ?]
Flags
- 1: Play everywhere
- Sound plays at a constant volume, no matter how far away the listener is from the sound source. Todo: How does this interact with env_microphone sound detection?
- Sound plays at a constant volume, no matter how far away the listener is from the sound source.
Bug:This flag is broken at engine level for Soundscripts. It will only work when a sound is played with its raw filename. [todo tested in ?]
- 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! [todo tested in ?]
- 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! [todo tested in ?]
Inputs
- Pitch
<int>
- 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!. [todo tested in ?]
PlaySound
- Starts the sound.
StopSound
- Stops a looping sound. Does not stop a non-looping sound: this is intentional, and can be changed with C++. However, a non-looping sound can be stopped by using the Volume input with a value of 0.
ToggleSound
- Toggles a looping sound between playing and stopped. Behaves like
PlaySound
if the sound is unlooped. Volume <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 ambient_generic plays its sound when prompted by other inputs, not play it by itself. [todo tested in ?]
Bug:Setting the volume to 0 will cause the sound to pause, rather than play silently. [todo tested in ?]
FadeIn <int>
- Fades the sound up to full volume over a specified number of seconds, with a range from 0 to 100 seconds.
Bug:Non-functional, except in Portal 2. [todo tested in ?]
FadeOut <int>
- 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. [todo tested in ?]
Outputs
See also
- Adjust ambient_generic volume higher than 10 (Advanced Mapping Tutorial)
- env_soundscape - used to play many ambient/background sounds from a single entity via a script
- Looping a Sound - which requires modifying the actual .wav file
- Setting up ambient_generics in Counter-Strike: Source using logic_auto - a substitute for creating a proper env_soundscape.