Ambient generic: Difference between revisions
Jump to navigation
Jump to search
Code Fix:Problems with sounds being unstoppable can be avoided by adding this C++ code to your mod.
Bug:Changing the volume while playing a looping sound will not work.
Confirm:This has only been tested in
and
, need testing in
Source 2013,
Left 4 Dead engine branch, and
Alien Swarm engine branch [todo tested in ?]
m (→Flags: Removed stray curly brace, moved bug template to fix indentation) |
|||
Line 18: | Line 18: | ||
{{ModernNote|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]].}} | {{ModernNote|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]].}} | ||
{{ModernWarning|Using the Soundscript name of a sound, as opposed to its "raw" audio file, will apply all the soundscript settings.<br> Example: In {{l4d2|2}}, the soundscript of <code>dlc.Generator_start_run_loop</code> is set to play everywhere but at lower volume even if "Play everywhere" is not set. But using its raw sound <code>Generator_start_run_loop.wav</code> works as intended.}} | {{ModernWarning|Using the Soundscript name of a sound, as opposed to its "raw" audio file, will apply all the soundscript settings.<br> Example: In {{l4d2|2}}, the soundscript of <code>dlc.Generator_start_run_loop</code> is set to play everywhere but at lower volume even if "Play everywhere" is not set. But using its raw sound <code>Generator_start_run_loop.wav</code> works as intended.}} | ||
{{Bug|Changing the volume while playing a looping sound will not work. {{ModernConfirm|This has only been tested in {{portal2}} and {{p2ce}}, need testing in {{src13|2}}, {{l4dbranch|2}}, and {{asbranch|2}}}}}} | |||
== Keyvalues == | == Keyvalues == |
Revision as of 10:53, 19 July 2023
![]() |
---|
CAmbientGeneric |
![]() |
This entity 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 or MP3 sample, or a scripted_sentence.
Bugs/Limitations
Template:ModernTip Template:ModernBug Template:ModernBug Template:ModernBug

Template:ModernBug Template:ModernBug Template:ModernWorkaround Template:ModernBug Template:ModernNote Template:ModernWarning







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)Template:ModernNoteTemplate:ModernNote
- Max Audible Distance (radius) <float>
- Maximum distance in units at which the sound plays for a client.Template:ModernBugTemplate:ModernBugTemplate:ModernNote
- SourceEntityName (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.Template:ModernBugTemplate:ModernBugTemplate:ModernBugTemplate:ModernBugTemplate:ModernNote
- Volume (health) <integer 0–10>
- How loud to play the sound. 0 is silent and 10 is normal. Default is 10.
Template:ModernTip Template:ModernTip Template:ModernBug
- 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.Template:ModernBug
- 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. Template:ModernBug
- Name (targetname) <string>[ Edit ]
- The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
Inputs
- Pitch <integer >
- Sets the sound pitch, expressed as a range from 1 to 255, where 100 is the sound's original pitch.Template:ModernBug
- 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.
Code 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 <float >
- Plays the sound at a volume from 0 to 10, where 10 is the loudest.Template:ModernBugTemplate:ModernNote
- FadeIn <integer >
- Fades the sound up to full volume over a specified number of seconds, with a range from 0 to 100 seconds.Template:ModernBug
- FadeOut <integer >
- Fades the sound to silence over a specified number of seconds, with a range from 0 to 100 seconds.Template:ModernBug
Flags
- Play everywhere : [1]
- 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?
- Template:ModernBug
- Start Silent : [16]
- The map will start without this sound playing. Enabled by default.Template:ModernBug
- Is NOT Looped : [32]
- 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!Template:ModernBug
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_generic
s in Counter-Strike: Source usinglogic_auto
- a substitute for creating a properenv_soundscape
.