MiniDoom

src/s_sound.ml

Implements sound and music orchestration on top of the platform audio layer.

Package
(global)
Reachable
Yes

Imports

Declarations

_S_Abs

inline function _S_Abs(v)

Returns the non-negative magnitude of an integer coordinate delta, or zero for invalid input.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_S_AngNorm

inline function _S_AngNorm(a)

Normalizes an integer to Doom's unsigned 32-bit binary-angle domain.

ParameterTypeDefaultDescription
adynamic—First input operand.

View source

_S_AngRef

inline function _S_AngRef(v)

Extracts an angle from a positioned struct or its nested mobj, defaulting to zero.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_S_Clamp

inline function _S_Clamp(v, lo, hi)

Constrains a numeric sound parameter to the supplied inclusive range.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.
lodynamic—Inclusive lower bound.
hidynamic—Inclusive upper bound.

View source

_s_debugMusicOnce

_s_debugMusicOnce

Tracks whether s debug music once is active in the s sound subsystem.

View source

_s_debugSfxOnce

_s_debugSfxOnce

Tracks whether s debug sfx once is active in the s sound subsystem.

View source

_S_DegradeUsefulness

inline function _S_DegradeUsefulness(sfx)

Decrements the canonical SFX entry's cache-use counter after a channel releases that sound.

ParameterTypeDefaultDescription
sfxdynamic—Sound-effect descriptor to process.

View source

_S_EffectiveConsoleSlot

inline function _S_EffectiveConsoleSlot()

Resolves the effective local player slot, preferring multiplayer platform slot in client mode.

View source

_S_EnsureChannels

inline function _S_EnsureChannels()

Validates the configured channel count and rebuilds an empty registry whenever its size no longer matches.

View source

_S_EnumIndex

inline function _S_EnumIndex(v, limit)

Resolves an integer, numeric value, or enum member to a bounded table index, returning -1 when unsupported.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.
limitdynamic—Limit value supplied to `_S_EnumIndex`.

View source

_S_FineSineAt

inline function _S_FineSineAt(idx)

Reads a wrapped fine-sine sample for stereo panning, returning zero when the table is unavailable.

ParameterTypeDefaultDescription
idxdynamic—Zero-based element or table index.

View source

_S_GetListener

inline function _S_GetListener()

Returns the effective local player's mobj as the positional-audio listener, or void for an invalid slot.

View source

_S_GetSfxById

inline function _S_GetSfxById(sound_id)

Resolves a valid nonzero sound id to its S_sfx metadata entry.

ParameterTypeDefaultDescription
sound_iddynamic—Sound id value supplied to `_S_GetSfxById`.

View source

_S_IDiv

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`

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_S_IsSeq

inline function _S_IsSeq(v)

Recognizes the array and list containers used for sound tables and channel registries.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_S_LinkOf

inline function _S_LinkOf(sfx)

Resolves an SFX alias link stored either as a direct metadata struct or as a table index.

ParameterTypeDefaultDescription
sfxdynamic—Sound-effect descriptor to process.

View source

_S_LoadPulse

inline function _S_LoadPulse(iter)

Pumps window/audio updates periodically while expensive audio precache loops run.

ParameterTypeDefaultDescription
iterdynamic—Iter value supplied to `_S_LoadPulse`.

View source

_S_Min

inline function _S_Min(a, b)

Returns the smaller operand for the sound-distance approximation.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_S_MPSendSoundEvent

function _S_MPSendSoundEvent(origin_p, sid, volume, targetSlot)

Sends one positional/non-positional sound event from host (broadcast or target slot).

ParameterTypeDefaultDescription
origin_pdynamic—Origin p value supplied to `_S_MPSendSoundEvent`.
siddynamic—Sid value supplied to `_S_MPSendSoundEvent`.
volumedynamic—Volume value supplied to `_S_MPSendSoundEvent`.
targetSlotdynamic—Target slot value supplied to `_S_MPSendSoundEvent`.

View source

_S_MusicId

inline function _S_MusicId(v)

Converts a music enum/value into its numeric id using the smaller of NUMMUSIC and the loaded music table.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_s_net_origin_t struct

_S_NETMSG_SOUND

const _S_NETMSG_SOUND = 201

Defines s netmsg sound for the s sound subsystem.

View source

_S_PosRef

inline function _S_PosRef(v)

Normalizes either a positioned struct or a player wrapper to the struct that owns x/y coordinates.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_S_ReadI32

inline function _S_ReadI32(buf, off)

Reads one signed 32-bit integer from multiplayer sound event payload bytes.

ParameterTypeDefaultDescription
bufdynamic—Buf value supplied to `_S_ReadI32`.
offdynamic—Zero-based byte or element offset.

View source

_S_SameXY

inline function _S_SameXY(a, b)

Reports whether two positional references occupy the same fixed-point x/y location.

ParameterTypeDefaultDescription
adynamic—First input operand.
bdynamic—Second input operand.

View source

_S_SetSfxUsefulnessAndLump

inline function _S_SetSfxUsefulnessAndLump(sid, sfx)

Writes modified lump and usefulness metadata back to a validated S_sfx table slot.

ParameterTypeDefaultDescription
siddynamic—Sid value supplied to `_S_SetSfxUsefulnessAndLump`.
sfxdynamic—Sound-effect descriptor to process.

View source

_S_SfxId

inline function _S_SfxId(v)

Converts an SFX enum/value into its numeric id using the smaller of NUMSFX and the loaded SFX table.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.

View source

_s_sfxPrecached

_s_sfxPrecached

Tracks whether s sfx precached is active in the s sound subsystem.

View source

_S_SfxPriority

inline function _S_SfxPriority(sfx)

Reads an SFX channel-replacement priority with NORM_PRIORITY as the missing-value default.

ParameterTypeDefaultDescription
sfxdynamic—Sound-effect descriptor to process.

View source

_S_ToInt

inline function _S_ToInt(v, fallback)

Coerces numeric values to truncation-toward-zero integers and returns fallback for invalid inputs.

ParameterTypeDefaultDescription
vdynamic—Value consumed by the operation.
fallbackdynamic—Value returned when the requested conversion or lookup is unavailable.

View source

_S_WriteI32

inline function _S_WriteI32(buf, off, v)

Writes one signed 32-bit integer into bytes for multiplayer sound event payloads.

ParameterTypeDefaultDescription
bufdynamic—Buf value supplied to `_S_WriteI32`.
offdynamic—Zero-based byte or element offset.
vdynamic—Value consumed by the operation.

View source

channel_t struct

channels

channels

Stores the channels collection used by the s sound subsystem.

View source

mus_paused

mus_paused

Tracks whether mus paused is active in the s sound subsystem.

View source

mus_playing

mus_playing

Holds the optional mus playing resource used by the s sound subsystem.

View source

nextcleanup

nextcleanup

Tracks the mutable nextcleanup value used by the s sound subsystem.

View source

NORM_PITCH

const NORM_PITCH = 128

Defines norm pitch for the s sound subsystem.

View source

NORM_PRIORITY

const NORM_PRIORITY = 64

Defines norm priority for the s sound subsystem.

View source

NORM_SEP

const NORM_SEP = 128

Defines norm sep for the s sound subsystem.

View source

numChannels

numChannels

Tracks the mutable num channels value used by the s sound subsystem.

View source

S_AdjustSoundParams

function S_AdjustSoundParams(listener, source, vol, sep, pitch)

Computes distance attenuation and listener-relative stereo separation, updating caller-owned volume/separation/pitch cells.

ParameterTypeDefaultDescription
listenerdynamic—Listener value supplied to `S_AdjustSoundParams`.
sourcedynamic—Source value or buffer.
voldynamic—Vol value supplied to `S_AdjustSoundParams`.
sepdynamic—Sep value supplied to `S_AdjustSoundParams`.
pitchdynamic—Pitch value supplied to `S_AdjustSoundParams`.

View source

s_attenuator

s_attenuator

Tracks the mutable s attenuator value used by the s sound subsystem.

View source

S_ChangeMusic

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.

ParameterTypeDefaultDescription
music_iddynamic—Music id value supplied to `S_ChangeMusic`.
loopingdynamic—Looping value supplied to `S_ChangeMusic`.

View source

s_clipping_dist

s_clipping_dist

Tracks the mutable s clipping dist value used by the s sound subsystem.

View source

s_close_dist

s_close_dist

Tracks the mutable s close dist value used by the s sound subsystem.

View source

s_currentMusic

s_currentMusic

Tracks the mutable s current music value used by the s sound subsystem.

View source

S_FRACBITS

const S_FRACBITS = 16

Defines s fracbits for the s sound subsystem.

View source

S_FRACUNIT

const S_FRACUNIT = 65536

Defines s fracunit for the s sound subsystem.

View source

S_getChannel

function S_getChannel(origin, sfxinfo)

Reserves an empty or same-origin voice, otherwise replaces an eligible channel by priority or returns -1.

ParameterTypeDefaultDescription
origindynamic—Origin value supplied to `S_getChannel`.
sfxinfodynamic—Sfxinfo value supplied to `S_getChannel`.

View source

S_Init

function S_Init(sfxVolume, musicVolume)

Initializes platform channels and volumes, clears music ownership, and resets all SFX lump/usefulness metadata.

ParameterTypeDefaultDescription
sfxVolumedynamic—Sfx volume value supplied to `S_Init`.
musicVolumedynamic—Music volume value supplied to `S_Init`.

View source

S_MAX_VOLUME

const S_MAX_VOLUME = 127

Defines the maximum s max volume accepted by the s sound subsystem.

View source

S_MPSendPickupSoundToPlayer

function S_MPSendPickupSoundToPlayer(playerSlot, sound_id)

Sends one pickup sound to the owning player in host-authoritative multiplayer.

ParameterTypeDefaultDescription
playerSlotdynamic—Player slot value supplied to `S_MPSendPickupSoundToPlayer`.
sound_iddynamic—Sound id value supplied to `S_MPSendPickupSoundToPlayer`.

View source

s_musicZonePtrs

s_musicZonePtrs

Stores the s music zone ptrs collection used by the s sound subsystem.

View source

S_NetRecvPacket

function S_NetRecvPacket(payload)

Applies one multiplayer sound packet on clients so attenuation uses local listener position.

ParameterTypeDefaultDescription
payloaddynamic—Payload value supplied to `S_NetRecvPacket`.

View source

S_PauseSound

function S_PauseSound()

Pauses the active music handle exactly once and records the paused state.

View source

S_PrecacheLevelAudio

function S_PrecacheLevelAudio()

Resolves and precaches every named SFX lump once while periodically pumping window and audio updates.

View source

S_ResumeSound

function S_ResumeSound()

Resumes a previously paused music handle and clears the paused state.

View source

S_SetMusicVolume

function S_SetMusicVolume(volume)

Clamps and stores music volume, then forwards only the requested level to the platform mixer.

ParameterTypeDefaultDescription
volumedynamic—Volume value supplied to `S_SetMusicVolume`.

View source

S_SetSfxVolume

function S_SetSfxVolume(volume)

Clamps and stores effects volume and forwards it to the platform mixer.

ParameterTypeDefaultDescription
volumedynamic—Volume value supplied to `S_SetSfxVolume`.

View source

S_Start

function S_Start()

Stops residual channels and selects the looping level track from game mode, episode, and map.

View source

S_StartMusic

function S_StartMusic(music_id)

Starts a non-looping music track through the common change-music path.

ParameterTypeDefaultDescription
music_iddynamic—Music id value supplied to `S_StartMusic`.

View source

S_StartSound

function S_StartSound(origin, sound_id)

Starts an SFX at the current global effects volume.

ParameterTypeDefaultDescription
origindynamic—Origin value supplied to `S_StartSound`.
sound_iddynamic—Sound id value supplied to `S_StartSound`.

View source

S_StartSoundAtVolume

function S_StartSoundAtVolume(origin_p, sfx_id, volume)

Broadcasts host audio, resolves aliases and attenuation, reserves a channel, and starts the platform SFX handle.

ParameterTypeDefaultDescription
origin_pdynamic—Origin p value supplied to `S_StartSoundAtVolume`.
sfx_iddynamic—Sfx id value supplied to `S_StartSoundAtVolume`.
volumedynamic—Volume value supplied to `S_StartSoundAtVolume`.

View source

s_stereo_swing

s_stereo_swing

Tracks the mutable s stereo swing value used by the s sound subsystem.

View source

S_StopChannel

function S_StopChannel(cnum)

Stops a validated platform voice, decrements its SFX usefulness, and resets the logical channel slot.

ParameterTypeDefaultDescription
cnumdynamic—Index identifying c.

View source

S_StopMusic

function S_StopMusic()

Resumes if needed, stops and unregisters the active song, retags its lump cache, and clears music ownership state.

View source

S_StopSound

function S_StopSound(origin)

Finds and releases the first active channel associated with a specific sound origin.

ParameterTypeDefaultDescription
origindynamic—Origin value supplied to `S_StopSound`.

View source

S_UpdateSounds

function S_UpdateSounds(listener_p)

Recomputes positional parameters for playing voices and releases finished or newly inaudible channels.

ParameterTypeDefaultDescription
listener_pdynamic—Listener p value supplied to `S_UpdateSounds`.

View source

snd_MusicVolume

snd_MusicVolume

Tracks the mutable snd music volume value used by the s sound subsystem.

View source

snd_SfxVolume

snd_SfxVolume

Tracks the mutable snd sfx volume value used by the s sound subsystem.

View source