A_StartSound
Jump to navigation
Jump to search
clearscope void A_StartSound (sound whattoplay, int slot = CHAN_BODY, int flags = CHANF_DEFAULT, double volume = 1.0, double attenuation = ATTN_NORM, double pitch = 0, double startTime = 0)
Usage
Plays the specified sound from the calling actor.
Note: Audio files can NOT be played directly from ZScript. A sound must be defined in SNDINFO first, then its SNDINFO name can be referenced in ZScript. |
Parameters
- Sound whattoplay
- The desired sound to play, as defined in SNDINFO.
- int slot
- The sound slot used for the sound. Unlike A_PlaySound, the slot is not limited to predefined slots and can be any positive number other than 0 (which enables special behavior). The predefined slots are:
- CHAN_AUTO (0) — Explicitly plays the sound with the CHANF_OVERLAP flag enabled (even if it's not passed). This means that all sounds passed to this channel will play over each other, never interrupting one another. Before GZDoom 4.4.0 CHAN_AUTO used to pick the first unoccupied channel, but this behavior was dropped when the ability to play multiple sounds on the same channel was added.
- CHAN_WEAPON (1)
- CHAN_VOICE (2)
- CHAN_ITEM (3)
- CHAN_BODY (4) — The default for A_StartSound / A_PlaySound (but not S_StartSound), for historical reasons.
- CHAN_5 (5)
- CHAN_6 (6)
- CHAN_7 (7)
- int flags
Note: Please note that A_StartSound has a separate flags argument in constrast to A_PlaySound. Trying to combine channel constants and flag constants in one argument will NOT work with A_StartSound. |
- Adjusts how the sound is played. Multiple flags can be combined with
|
:- CHANF_DEFAULT — No flags. Default.
- CHANF_LISTENERZ — Play the sound from the listener's Z position instead of the caller's.
- CHANF_MAYBE_LOCAL — Sound is subject to compat_silentpickup and will not play if started by an actor other than the listener when the compatibility flag is enabled.
- CHANF_UI — Sound isn't preserved in saves and will play while the game is paused.
- CHANF_NOPAUSE — Don't pause the sound.
- CHANF_LOOP — Loops the sound.
- CHANF_OVERLAP — Don't stop any sounds in the channel and instead play over them.
- CHANF_LOCAL — Only play the sound if the listener is the one doing so.
- CHANF_NOSTOP — If the channel is occupied, do not play the sound.
- CHANF_TRANSIENT — Sound isn't preserved in saves.
- CHANF_FORCE — Play the sound even if it will be immediately paused upon doing so.
- CHANF_LOOPING — Combines CHANF_LOOP and CHANF_NOSTOP. It is equivalent to the looping parameter of A_PlaySound.
- double volume
- The volume of the sound, which ranges from 0 to 1.0. Default 1.0.
- double 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).
- double 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.
- double 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; ... }