Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

Editing ambientsound

From Quake Wiki

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 1: Line 1:
''void'' '''ambientsound'''(''vector'' pos, ''string'' soundPath, ''float'' volume, ''float'' attenuation)
+
====Syntax:====
 
+
<code>void ambientsound(vector pos, string sample, float volume, float attenuation)</code>
== Usage ==
 
Starts playing a sound with no connection to any entity. A sound must be precached during map load in order to be considered valid. Once an ambient sound starts playing it cannot be stopped.
 
 
 
Unlike standard sounds, ambient sounds must loop in order to be considered valid (sound markers need to be present in the file).
 
  
 +
Starts a sound as an ambient sound.  Unlike normal sounds started from the '''sound''' function, an ambient sound will never stop playing, even if the player moves out of audible range.  It will also be properly registered by the engine if it is started outside of hearing range of the player.
 
====Parameters:====
 
====Parameters:====
*''pos''
+
:<code>pos</code> - The coordinates for the origin of the sound.
:The origin of the sound.
+
:<code>sample</code> - The path to the sound file. Unlike models, sounds have /sound/ already present, so do not include that directory in the pathname.  This sound MUST be looped by placing markers in the .wav file.
*''soundPath''
+
:<code>volume</code> - A value between 0.0 and 1.0 that controls the volume of the sound. 0.0 is silent, 1.0 is full volume.
:The path of the sound file. Supports WAV (.wav) files.
+
:<code>attenuation</code> - A value greater than or equal to 0 and less than 4 that controls how fast the sound's volume attenuated from distance. 0 can be heard everywhere in the level, 1 can be heard up to 1000 units and 3.999 has a radius of about 250 units.
*''volume''
+
====Returns:====
:Can be a value from 0 to 1.
+
:void
*''attenuation''
+
====Other Details:====
:Determines the linear falloff of the sound over distance. A value of 0 (<code>ATTN_NONE</code>) will have no fall off. The larger the value, the greater the falloff. Default values:
+
There is a separate limit to how many ambient sounds can be placed in a map (even if they are the same sound).  In stock Quake, this is 128. You can view the known limits for other engines at the [[Engine Limits#Sounds|Engine Limits]] page.
:*<code>ATTN_NONE</code>
 
:*<code>ATTN_NORM</code>
 
:*<code>ATTN_IDLE</code>
 
:*<code>ATTN_STATIC</code>
 
  
== Example ==
 
// This entity plays an ambient sound when it initializes
 
void ambient_ocean()
 
{
 
    precache_sound("ambience/ocean.wav");
 
    ambientsound(self.origin, "ambience/ocean.wav", 1, ATTN_STATIC);
 
 
    remove(self);
 
}
 
  
 
[[Category:QuakeC Function]]
 
[[Category:QuakeC Function]]

Please note that all contributions to Quake Wiki are considered to be released under the GNU Free Documentation License 1.3 or later (see Quake Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel | Editing help (opens in new window)