# _S_Abs
inline function _S_Abs(v)Returns the non-negative magnitude of an integer coordinate delta, or zero for invalid input.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
src/s_sound.mlImplements sound and music orchestration on top of the platform audio layer.
doomdef.ml → src/doomdef.mldoomstat.ml → src/doomstat.mli_sound.ml → src/i_sound.mli_system.ml → src/i_system.mlm_fixed.ml → src/m_fixed.mlm_random.ml → src/m_random.mlmp_platform.ml → src/mp_platform.mlp_local.ml → src/p_local.mlr_main.ml → src/r_main.mlsounds.ml → src/sounds.mlstd/math.ml → ../MiniLangCompilerOptimization/MiniLangCompilerPy/std/math.ml external dependencyw_wad.ml → src/w_wad.mlz_zone.ml → src/z_zone.mlinline function _S_Abs(v)Returns the non-negative magnitude of an integer coordinate delta, or zero for invalid input.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
inline function _S_AngNorm(a)Normalizes an integer to Doom's unsigned 32-bit binary-angle domain.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | dynamic | — | First input operand. |
inline function _S_AngRef(v)Extracts an angle from a positioned struct or its nested mobj, defaulting to zero.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
inline function _S_Clamp(v, lo, hi)Constrains a numeric sound parameter to the supplied inclusive range.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
lo | dynamic | — | Inclusive lower bound. |
hi | dynamic | — | Inclusive upper bound. |
_s_debugMusicOnceTracks whether s debug music once is active in the s sound subsystem.
_s_debugSfxOnceTracks whether s debug sfx once is active in the s sound subsystem.
inline function _S_DegradeUsefulness(sfx)Decrements the canonical SFX entry's cache-use counter after a channel releases that sound.
| Parameter | Type | Default | Description |
|---|---|---|---|
sfx | dynamic | — | Sound-effect descriptor to process. |
inline function _S_EffectiveConsoleSlot()Resolves the effective local player slot, preferring multiplayer platform slot in client mode.
inline function _S_EnsureChannels()Validates the configured channel count and rebuilds an empty registry whenever its size no longer matches.
inline function _S_EnumIndex(v, limit)Resolves an integer, numeric value, or enum member to a bounded table index, returning -1 when unsupported.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
limit | dynamic | — | Limit value supplied to `_S_EnumIndex`. |
inline function _S_FineSineAt(idx)Reads a wrapped fine-sine sample for stereo panning, returning zero when the table is unavailable.
| Parameter | Type | Default | Description |
|---|---|---|---|
idx | dynamic | — | Zero-based element or table index. |
inline function _S_GetListener()Returns the effective local player's mobj as the positional-audio listener, or void for an invalid slot.
inline function _S_GetSfxById(sound_id)Resolves a valid nonzero sound id to its S_sfx metadata entry.
| Parameter | Type | Default | Description |
|---|---|---|---|
sound_id | dynamic | — | Sound id value supplied to `_S_GetSfxById`. |
inline function _S_IDiv(a, b)Returns a signed quotient truncated toward zero, or zero for invalid operands and a zero divisor in `_S_IDiv`
| Parameter | Type | Default | Description |
|---|---|---|---|
a | dynamic | — | First input operand. |
b | dynamic | — | Second input operand. |
inline function _S_IsSeq(v)Recognizes the array and list containers used for sound tables and channel registries.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
inline function _S_LinkOf(sfx)Resolves an SFX alias link stored either as a direct metadata struct or as a table index.
| Parameter | Type | Default | Description |
|---|---|---|---|
sfx | dynamic | — | Sound-effect descriptor to process. |
inline function _S_LoadPulse(iter)Pumps window/audio updates periodically while expensive audio precache loops run.
| Parameter | Type | Default | Description |
|---|---|---|---|
iter | dynamic | — | Iter value supplied to `_S_LoadPulse`. |
inline function _S_Min(a, b)Returns the smaller operand for the sound-distance approximation.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | dynamic | — | First input operand. |
b | dynamic | — | Second input operand. |
function _S_MPSendSoundEvent(origin_p, sid, volume, targetSlot)Sends one positional/non-positional sound event from host (broadcast or target slot).
| Parameter | Type | Default | Description |
|---|---|---|---|
origin_p | dynamic | — | Origin p value supplied to `_S_MPSendSoundEvent`. |
sid | dynamic | — | Sid value supplied to `_S_MPSendSoundEvent`. |
volume | dynamic | — | Volume value supplied to `_S_MPSendSoundEvent`. |
targetSlot | dynamic | — | Target slot value supplied to `_S_MPSendSoundEvent`. |
inline function _S_MusicId(v)Converts a music enum/value into its numeric id using the smaller of NUMMUSIC and the loaded music table.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
_s_net_origin_t struct
const _S_NETMSG_SOUND = 201Defines s netmsg sound for the s sound subsystem.
inline function _S_PosRef(v)Normalizes either a positioned struct or a player wrapper to the struct that owns x/y coordinates.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
inline function _S_ReadI32(buf, off)Reads one signed 32-bit integer from multiplayer sound event payload bytes.
| Parameter | Type | Default | Description |
|---|---|---|---|
buf | dynamic | — | Buf value supplied to `_S_ReadI32`. |
off | dynamic | — | Zero-based byte or element offset. |
inline function _S_SameXY(a, b)Reports whether two positional references occupy the same fixed-point x/y location.
| Parameter | Type | Default | Description |
|---|---|---|---|
a | dynamic | — | First input operand. |
b | dynamic | — | Second input operand. |
inline function _S_SetSfxUsefulnessAndLump(sid, sfx)Writes modified lump and usefulness metadata back to a validated S_sfx table slot.
| Parameter | Type | Default | Description |
|---|---|---|---|
sid | dynamic | — | Sid value supplied to `_S_SetSfxUsefulnessAndLump`. |
sfx | dynamic | — | Sound-effect descriptor to process. |
inline function _S_SfxId(v)Converts an SFX enum/value into its numeric id using the smaller of NUMSFX and the loaded SFX table.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
_s_sfxPrecachedTracks whether s sfx precached is active in the s sound subsystem.
inline function _S_SfxPriority(sfx)Reads an SFX channel-replacement priority with NORM_PRIORITY as the missing-value default.
| Parameter | Type | Default | Description |
|---|---|---|---|
sfx | dynamic | — | Sound-effect descriptor to process. |
inline function _S_ToInt(v, fallback)Coerces numeric values to truncation-toward-zero integers and returns fallback for invalid inputs.
| Parameter | Type | Default | Description |
|---|---|---|---|
v | dynamic | — | Value consumed by the operation. |
fallback | dynamic | — | Value returned when the requested conversion or lookup is unavailable. |
inline function _S_WriteI32(buf, off, v)Writes one signed 32-bit integer into bytes for multiplayer sound event payloads.
| Parameter | Type | Default | Description |
|---|---|---|---|
buf | dynamic | — | Buf value supplied to `_S_WriteI32`. |
off | dynamic | — | Zero-based byte or element offset. |
v | dynamic | — | Value consumed by the operation. |
channel_t struct
channelsStores the channels collection used by the s sound subsystem.
mus_pausedTracks whether mus paused is active in the s sound subsystem.
mus_playingHolds the optional mus playing resource used by the s sound subsystem.
nextcleanupTracks the mutable nextcleanup value used by the s sound subsystem.
const NORM_PITCH = 128Defines norm pitch for the s sound subsystem.
const NORM_PRIORITY = 64Defines norm priority for the s sound subsystem.
const NORM_SEP = 128Defines norm sep for the s sound subsystem.
numChannelsTracks the mutable num channels value used by the s sound subsystem.
function S_AdjustSoundParams(listener, source, vol, sep, pitch)Computes distance attenuation and listener-relative stereo separation, updating caller-owned volume/separation/pitch cells.
| Parameter | Type | Default | Description |
|---|---|---|---|
listener | dynamic | — | Listener value supplied to `S_AdjustSoundParams`. |
source | dynamic | — | Source value or buffer. |
vol | dynamic | — | Vol value supplied to `S_AdjustSoundParams`. |
sep | dynamic | — | Sep value supplied to `S_AdjustSoundParams`. |
pitch | dynamic | — | Pitch value supplied to `S_AdjustSoundParams`. |
s_attenuatorTracks the mutable s attenuator value used by the s sound subsystem.
function S_ChangeMusic(music_id, looping)Stops the previous track, caches and registers the requested music lump, then starts it with the requested loop mode.
| Parameter | Type | Default | Description |
|---|---|---|---|
music_id | dynamic | — | Music id value supplied to `S_ChangeMusic`. |
looping | dynamic | — | Looping value supplied to `S_ChangeMusic`. |
s_clipping_distTracks the mutable s clipping dist value used by the s sound subsystem.
s_close_distTracks the mutable s close dist value used by the s sound subsystem.
s_currentMusicTracks the mutable s current music value used by the s sound subsystem.
const S_FRACBITS = 16Defines s fracbits for the s sound subsystem.
const S_FRACUNIT = 65536Defines s fracunit for the s sound subsystem.
function S_getChannel(origin, sfxinfo)Reserves an empty or same-origin voice, otherwise replaces an eligible channel by priority or returns -1.
| Parameter | Type | Default | Description |
|---|---|---|---|
origin | dynamic | — | Origin value supplied to `S_getChannel`. |
sfxinfo | dynamic | — | Sfxinfo value supplied to `S_getChannel`. |
function S_Init(sfxVolume, musicVolume)Initializes platform channels and volumes, clears music ownership, and resets all SFX lump/usefulness metadata.
| Parameter | Type | Default | Description |
|---|---|---|---|
sfxVolume | dynamic | — | Sfx volume value supplied to `S_Init`. |
musicVolume | dynamic | — | Music volume value supplied to `S_Init`. |
const S_MAX_VOLUME = 127Defines the maximum s max volume accepted by the s sound subsystem.
function S_MPSendPickupSoundToPlayer(playerSlot, sound_id)Sends one pickup sound to the owning player in host-authoritative multiplayer.
| Parameter | Type | Default | Description |
|---|---|---|---|
playerSlot | dynamic | — | Player slot value supplied to `S_MPSendPickupSoundToPlayer`. |
sound_id | dynamic | — | Sound id value supplied to `S_MPSendPickupSoundToPlayer`. |
s_musicZonePtrsStores the s music zone ptrs collection used by the s sound subsystem.
function S_NetRecvPacket(payload)Applies one multiplayer sound packet on clients so attenuation uses local listener position.
| Parameter | Type | Default | Description |
|---|---|---|---|
payload | dynamic | — | Payload value supplied to `S_NetRecvPacket`. |
function S_PauseSound()Pauses the active music handle exactly once and records the paused state.
function S_PrecacheLevelAudio()Resolves and precaches every named SFX lump once while periodically pumping window and audio updates.
function S_ResumeSound()Resumes a previously paused music handle and clears the paused state.
function S_SetMusicVolume(volume)Clamps and stores music volume, then forwards only the requested level to the platform mixer.
| Parameter | Type | Default | Description |
|---|---|---|---|
volume | dynamic | — | Volume value supplied to `S_SetMusicVolume`. |
function S_SetSfxVolume(volume)Clamps and stores effects volume and forwards it to the platform mixer.
| Parameter | Type | Default | Description |
|---|---|---|---|
volume | dynamic | — | Volume value supplied to `S_SetSfxVolume`. |
function S_Start()Stops residual channels and selects the looping level track from game mode, episode, and map.
function S_StartMusic(music_id)Starts a non-looping music track through the common change-music path.
| Parameter | Type | Default | Description |
|---|---|---|---|
music_id | dynamic | — | Music id value supplied to `S_StartMusic`. |
function S_StartSound(origin, sound_id)Starts an SFX at the current global effects volume.
| Parameter | Type | Default | Description |
|---|---|---|---|
origin | dynamic | — | Origin value supplied to `S_StartSound`. |
sound_id | dynamic | — | Sound id value supplied to `S_StartSound`. |
function S_StartSoundAtVolume(origin_p, sfx_id, volume)Broadcasts host audio, resolves aliases and attenuation, reserves a channel, and starts the platform SFX handle.
| Parameter | Type | Default | Description |
|---|---|---|---|
origin_p | dynamic | — | Origin p value supplied to `S_StartSoundAtVolume`. |
sfx_id | dynamic | — | Sfx id value supplied to `S_StartSoundAtVolume`. |
volume | dynamic | — | Volume value supplied to `S_StartSoundAtVolume`. |
s_stereo_swingTracks the mutable s stereo swing value used by the s sound subsystem.
function S_StopChannel(cnum)Stops a validated platform voice, decrements its SFX usefulness, and resets the logical channel slot.
| Parameter | Type | Default | Description |
|---|---|---|---|
cnum | dynamic | — | Index identifying c. |
function S_StopMusic()Resumes if needed, stops and unregisters the active song, retags its lump cache, and clears music ownership state.
function S_StopSound(origin)Finds and releases the first active channel associated with a specific sound origin.
| Parameter | Type | Default | Description |
|---|---|---|---|
origin | dynamic | — | Origin value supplied to `S_StopSound`. |
function S_UpdateSounds(listener_p)Recomputes positional parameters for playing voices and releases finished or newly inaudible channels.
| Parameter | Type | Default | Description |
|---|---|---|---|
listener_p | dynamic | — | Listener p value supplied to `S_UpdateSounds`. |
snd_MusicVolumeTracks the mutable snd music volume value used by the s sound subsystem.
snd_SfxVolumeTracks the mutable snd sfx volume value used by the s sound subsystem.