From ZDoom Wiki
Jump to navigation Jump to search

clearscope void A_StartSound [(sound whattoplay [, int slot [, int flags [, double volume [, double attenuation [, double pitch [, double starttime]]]]]])]


Plays the specified sound.


  • whattoplay: the desired sound to play.
  • slot: the sound slot used for the sound. Unlike A_PlaySound, the slot isn't limited to predefined slots and can be any number other than 0 (which instructs GZDoom to use another slot) and -1. The predefined slots are:
  • CHAN_AUTO — 0 (use the first channel that isn't already playing something)
  • CHAN_VOICE — 2
  • CHAN_ITEM — 3
  • CHAN_BODY — 4 (default)
  • CHAN_5 — 5
  • CHAN_6 — 6
  • CHAN_7 — 7
  • flags: bitflag parameters that adjust how the sound is played:
  • CHANF_DEFAULT — equal to 0 "just to make the code look better". The default.
  • CHANF_LISTENERZ — played from the listener's Z-height. (Needs verifying)
  • CHANF_MAYBE_LOCAL — is subject to compat_silentpickup and will not play if the sound is made by an actor other than the local player's camera when compatibility flag is enabled.
  • CHANF_UI — is not preserved in savegames.
  • CHANF_NOPAUSE — does not pause in menus.
  • CHANF_LOOP — loops the sound.
  • CHANF_OVERLAP — does not stop any sounds in the channel and instead plays over them.
  • CHANF_LOCAL — only plays locally for the calling actor.
  • CHANF_NOSTOP — if the channel is occupied, do not play the sound
  • CHANF_LOOPING — combines CHANF_LOOP and CHANF_NOSTOP, equivalent to the 'looping' parameter of A_PlaySound.
  • volume: the volume of the sound, to a maximum of the default 1.0.
  • attenuation: this is a positive value that specifies how quickly the sound fades with distance from its source. The higher the value the quicker it fades out. The numbers are fairly low. You will notice dramatic drop off of volume with an attenuation value of just 3 or 4 and by the time you use a value of 20 you need to be within around 64 units of the sound source to hear it clearly. The following predefined constants exist:
  • ATTN_NONE — Plays the sound globally at the specified volume, disregarding distance.
  • ATTN_NORM — Uses the close_dist and clipping_dist fields defined in the sound definition. This is the default.
  • ATTN_IDLE — Uses DOOM's normal default sound attenuation behavior.
  • ATTN_STATIC — Fades quickly (inaudible from 512 units).
For example, if you want to have a sound play at the specified volume regardless of distance (anywhere on the map), use ATTN_NONE.
  • pitch: the sound pitch to play the sound with. Default is 1.0, which means the engine will use whatever pitch shift (range) is defined in SNDINFO, if any. Lower values will slow down the sound, and higher will speed it up.
  • startTime: Sets how much of the sound to skip when starting. The value can be anywhere between 0.0 to 1.0, translating to 0% to 100%. Default is 0.


   BLAH A 5 NoDelay A_StartSound("play/sound")
   BLAH E -1

See also