CAmbientGeneric

From Source Entities
(Redirected from Ambient generic)
Jump to navigation Jump to search

Code classes:

Ambient generic.png

CAmbientGeneric plays a sound, either once or on loop, and either from a location in the world or globally.

Classnames:

  • ambient_generic

It can play:

  • Soundscripts (referred to as a Game Sound) (e.g. npc_barney.ba_laugh03)
  • Raw .wav samples (or mp3, in some games) (e.g. vo/canals/male01/gunboat_owneyes.wav)
  • Scripted sentences from sentences.txt (e.g. !COMBINE_THROW_GRENADE4) (cannot play a Scene (VCD) file)

Bug: As a general note, this entity's behavior can be very inconsistent and buggy. Advanced sound manipulation is best done through soundscripts or by putting effects directly on the sound file.

Bug: Parenting does not always work with ambient_generic. Use SourceEntityName.

Bug: Known to ignore inputs sent by ent_fire under some specific (To do: Uncertain) circumstances.

Flags[edit | edit source]

  • 1: Play everywhere - Sound becomes audible through the entire map and always has the same volume regardless of position. To do: Does this affect env_microphone at all? Bug: This seems to be broken for soundscripts, but raw filenames and scripted sentences still work.
  • 16: Start Silent - Makes the sound not play when the map loads. Sounds should usually start silent unless they are looped.
  • 32: Is NOT Looped - Allows the sound to be played rapidly without interrupting itself. Bug: Causes the sound to never start on spawn, regardless of Start Silent. Also causes the entity to ignore StopSound, and react to ToggleSound incorrectly. Sometimes causes other odd behavior with specially-configured sounds such as weapon fire and speech.

Keyvalues[edit | edit source]

Sound Name (message) <sound>
Sound to play.
Max Audible Distance (radius) <float>
Maximum distance that this sound may be heard from. Bug: Impressively, sounds are still slightly audible outside this range.
SourceEntityName (SourceEntityName) <target_destination>
A location that the sound will play at instead of from the ambient_generic.
Bug: That entity must exist when this entity is spawned, or else the sound will still play at the ambient_generic. Using AddOutput to change this keyvalue does not work.
Dynamic Presets (preset) <choices>
Various effect filters that change how sounds sound. Note that these are not DSP effects. Setting this will override many of the settings below.
Pitch (pitch) <integer>
Pitch of the sound on a range from 0 to 255. Default is 100. Note: Soundscripts will not have their pitch changed.
Start Pitch (pitchstart) <integer>
A pitch for the sound to "spin up" (start) and "spin down" (end) at. See Spin up/down time. Bug: When this number is set higher than Pitch, only a small blip of the sound will play before the sound stops prematurely.
Spin up time (0-100) (spinup) <integer>
When the sound begins playing, it will take this long for it to transition from Start Pitch to Pitch. To do: What is the number measured in? Deciseconds?
Spin down time (0-100) (spindown) <integer>
When the sound is told to quit playing (through StopSound or ToggleSound, but not due to the file itself ending), it will take this long to transition from Pitch to Start Pitch (once this transition is over, then the sound finishes entirely).
Volume (health) <integer>
Volume for this sound to play at by default on a range from 0 (silent) to 10.
Start Volume (volstart) <integer>
A volume for the sound to fade in from and fade out to. See Fade in/out time in seconds.
Fade in time in seconds (0-100) (fadeinsecs) <integer>
When the sound begins playing, it will take this long to transition from Start Volume to Volume.
Fade out time in seconds (0-100) (fadeoutsecs) <integer>
When the sound is told to quit playing (through StopSound or ToggleSound, but not due to the file itself ending), it will take this long to transition from Volume to Start Volume (once this transition is over, then the sound finishes entirely).
LFO Type (lfotype) <choices>
A Low Frequency Oscillation pattern to apply to the sound.
  • 0: None
  • 1: Square - Sound abruptly switches between high and low.
  • 2: Triangle - Sound smoothly transitions between high and low.
  • 3: Random - Sound changes unpredictably between high and low.
LFO rate (0-1000) (lforate) <integer>
Times per second[Confirm] that the oscillation occurs.
LFO mod pitch (0-100) (lfomodpitch) <integer>
Pitch to modulate down to. Bug: When using this, the sound may temporarily stop if the value is higher than Pitch or if Pitch is not at 100.
LFO mod vol (0-100) (lfomodvol) <integer>
Volume to modulate down to. Bug: When using this, the sound may temporarily stop if the value is higher than Volume x 10 or if Volume is not at 10.
Incremental Spinup Count (cspinup) <integer>
If Dynamic Presets is Incremental Spinup, an amount by which to increase the pitch when ToggleSound is sent.

Inputs[edit | edit source]

Pitch <integer>
Plays the sound at a particular pitch.
PlaySound
Starts the sound.
StopSound
Stops the sound.
ToggleSound
Starts sound if not playing, and stops sound if playing. If Dynamic Presets is Incremental Spinup, increases the pitch by the amount in Incremental Spinup Count.
Volume <float>
Plays the sound at a particular volume. (To clarify, this does not simply change the active volume of the sound. It stops the sound and makes it begin playing again.)
FadeIn <integer>
Starts sound with a transition from silence to full volume, lasting a given number of seconds. To do: Seems to only work with very specific setups? Needs to be researched.
FadeOut <integer>
Fades the sound to silence over a specified number of seconds.