A_StartSound

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]]]]]])

Usage

Plays the specified sound.

Parameters

  • 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_WEAPON (1)
  • 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 higher the value the quicker it fades out. The numbers are fairly low. A dramatic drop off of volume is noticeable with an attenuation value of just 3 or 4. With a value of 20, for instance, the player needs 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. 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.

Examples

 ...
 states
 {
 Spawn:
   BLAH A 5 NoDelay A_StartSound("play/sound")
   BLAH BCD 6
   BLAH E -1
   stop
 ...
 }

See also