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, as defined in SNDINFO.
  • slot: the sound slot used for the sound. Unlike A_PlaySound, the slot is not 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 is not already playing something.
  • CHAN_VOICE (2)
  • CHAN_ITEM (3)
  • CHAN_BODY (4) — Default.
  • CHAN_5 (5)
  • CHAN_6 (6)
  • CHAN_7 (7)
  • flags: adjusts how the sound is played. Multiple flags can be combined by using the bitwise OR (|) operator:
  • CHANF_DEFAULT — No flags. Default.
  • CHANF_LISTENERZ — Played from the listener's Z-height. (Verification needed)
  • 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 the 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. It is equivalent to the looping parameter of A_PlaySound.
  • volume: the volume of the sound, which ranges from 0 to 1.0. Default 1.0.
  • attenuation: this is a positive value that specifies how quickly the sound fades with distance from its source. The exact formula for attenuation is: attenuation = default max hearable distance / desired max hearable distance. So, for example, in Doom the default max hearable distance is 1200; with attenuation of 20 the max hearable distance for the sound will be 60 map units (1200 / 20 = 60). This argument also accepts the following predefined constants:
  • 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. Default.
  • ATTN_IDLE — Uses Doom's normal default sound attenuation behavior.
  • ATTN_STATIC — Fades quickly (inaudible from 512 units).
  • pitch: the sound pitch to play the sound with. Default is 0, which means the engine uses whatever pitch shift (range) that is defined in SNDINFO, if any. For non-zero values anything lower than 1.0 will slow down the sound, while higher values speed it up.
  • startTime: sets how much of the sound to skip when starting. The value can be anywhere between 0 and 1.0, translating to 0% to 100%. Default is 0.


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

See also