# AMBIENT_WATER_ENTITY
const AMBIENT_WATER_ENTITY = -1001Defines the ambient water entity value used by `miniquake.sound.mixer`.
src/miniquake/sound/mixer.mlminiquake/array_util.ml as arrays → src/miniquake/array_util.mlminiquake/audio.ml as audio → src/miniquake/audio.mlminiquake/byteio.ml as bio → src/miniquake/byteio.mlminiquake/common.ml as common → src/miniquake/common.mlminiquake/filesystem.ml as qfs → src/miniquake/filesystem.mlminiquake/mathlib.ml as math → src/miniquake/mathlib.mlminiquake/native.ml as native → src/miniquake/native.mlminiquake/sound/snd_mem.ml as sndmem → src/miniquake/sound/snd_mem.mlminiquake/sound/wav.ml as wav → src/miniquake/sound/wav.mlminiquake/types.ml as t → src/miniquake/types.mlminiquake/world_bsp.ml as soundWorld → src/miniquake/world_bsp.mlconst AMBIENT_WATER_ENTITY = -1001Defines the ambient water entity value used by `miniquake.sound.mixer`.
const AMBIENT_WIND_ENTITY = -1002Defines the ambient wind entity value used by `miniquake.sound.mixer`.
function ambientTarget(levelByte, ambientLevel)Implements the `ambientTarget` operation for `miniquake.sound.mixer` (ambient target).
| Parameter | Type | Default | Description |
|---|---|---|---|
levelByte | dynamic | — | The level byte input consumed by `ambientTarget`. |
ambientLevel | dynamic | — | The ambient level input consumed by `ambientTarget`. |
function block(mixer)S_BlockSound/S_UnblockSound production counterpart. waveOutReset flushes all queued headers on the first nesting level; no painting/submission takes place until the matching final unblock.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `block`. |
function blockDepth(mixer)Implements the `blockDepth` operation for `miniquake.sound.mixer` (block depth).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `blockDepth`. |
function channelVolumes(mixer, channel)Implements the `channelVolumes` operation for `miniquake.sound.mixer` (channel volumes).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `channelVolumes`. |
channel | dynamic | — | The channel input consumed by `channelVolumes`. |
function channelVolumesInto(mixer, channel, leftValues, rightValues, index)Calculate one channel's stereo volumes into reusable parallel arrays.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `channelVolumesInto`. |
channel | dynamic | — | The channel input consumed by `channelVolumesInto`. |
leftValues | dynamic | — | The left values input consumed by `channelVolumesInto`. |
rightValues | dynamic | — | The right values input consumed by `channelVolumesInto`. |
index | dynamic | — | Zero-based index of the requested entry. |
function clampSample(value)Return a validated clamp sample value.
| Parameter | Type | Default | Description |
|---|---|---|---|
value | dynamic | — | Value consumed by `clampSample`. |
function close(mixer)Implements the `close` operation for `miniquake.sound.mixer` (close).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `close`. |
function convertToMono16(info, source, targetRate)Convert data for convert to mono16.
| Parameter | Type | Default | Description |
|---|---|---|---|
info | dynamic | — | The info input consumed by `convertToMono16`. |
source | dynamic | — | Source value or collection to read. |
targetRate | dynamic | — | The target rate input consumed by `convertToMono16`. |
function create(filesystem, sampleRate)Implements the `create` operation for `miniquake.sound.mixer` (create).
| Parameter | Type | Default | Description |
|---|---|---|---|
filesystem | dynamic | — | The filesystem input consumed by `create`. |
sampleRate | dynamic | — | The sample rate input consumed by `create`. |
function decodeMusicChunk(track, restart)Read and validate music chunk.
| Parameter | Type | Default | Description |
|---|---|---|---|
track | dynamic | — | The track input consumed by `decodeMusicChunk`. |
restart | dynamic | — | The restart input consumed by `decodeMusicChunk`. |
function desiredQueuedBuffers(mixer, frameTime, mixAhead)Implements the `desiredQueuedBuffers` operation for `miniquake.sound.mixer` (desired queued buffers).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `desiredQueuedBuffers`. |
frameTime | dynamic | — | Time value used by the operation. |
mixAhead | dynamic | — | The mix ahead input consumed by `desiredQueuedBuffers`. |
function discardOldestChannel(mixer, newEntityNumber)Release or consume state for discard oldest channel.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `discardOldestChannel`. |
newEntityNumber | dynamic | — | The new entity number input consumed by `discardOldestChannel`. |
function dynamicChannelCount(mixer)Return dynamic channel count derived from the active module state.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `dynamicChannelCount`. |
function effectIndex(mixer, name)Return effect index derived from the active module state.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `effectIndex`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
function ensureAmbientChannel(mixer, entityNumber, channelNumber, name)Ensure sufficient storage or state for ambient channel.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `ensureAmbientChannel`. |
entityNumber | dynamic | — | The entity number input consumed by `ensureAmbientChannel`. |
channelNumber | dynamic | — | The channel number input consumed by `ensureAmbientChannel`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
function fadeAmbientChannel(channel, target, step, origin)Implements the `fadeAmbientChannel` operation for `miniquake.sound.mixer` (fade ambient channel).
| Parameter | Type | Default | Description |
|---|---|---|---|
channel | dynamic | — | The channel input consumed by `fadeAmbientChannel`. |
target | dynamic | — | The target input consumed by `fadeAmbientChannel`. |
step | dynamic | — | The step input consumed by `fadeAmbientChannel`. |
origin | dynamic | — | World-space origin of the operation. |
function findChannel(mixer, entityNumber, channelNumber)Return channel.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `findChannel`. |
entityNumber | dynamic | — | The entity number input consumed by `findChannel`. |
channelNumber | dynamic | — | The channel number input consumed by `findChannel`. |
function hasExtension(name)Report whether extension.
| Parameter | Type | Default | Description |
|---|---|---|---|
name | dynamic | — | Stable name that identifies the requested object or option. |
function isDynamicChannel(channel)Report whether is dynamic channel.
| Parameter | Type | Default | Description |
|---|---|---|---|
channel | dynamic | — | The channel input consumed by `isDynamicChannel`. |
function loadEffect(mixer, name)Read and validate effect.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `loadEffect`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
function localSound(mixer, name)Implements the `localSound` operation for `miniquake.sound.mixer` (local sound).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `localSound`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
const MAX_CHANNELS = 128Defines the max channels value used by `miniquake.sound.mixer`.
const MAX_DYNAMIC_CHANNELS = 8Defines the max dynamic channels value used by `miniquake.sound.mixer`.
const MAX_QUEUED_BUFFERS = 7Defines the max queued buffers value used by `miniquake.sound.mixer`.
const MIN_QUEUED_BUFFERS = 3Defines the min queued buffers value used by `miniquake.sound.mixer`.
function mix(mixer, frameCount)Mix the requested value into the active audio buffer.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mix`. |
frameCount | dynamic | — | Number of entries or units to process. |
const MIX_FRAMES = 512WinQuake reserves 128 software channels. The former 32-channel limit could evict looping/static sounds very quickly on a populated retail map.
function mixChannel(mixer, channel, accumulator, frameCount)Mix channel into the active audio buffer.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixChannel`. |
channel | dynamic | — | The channel input consumed by `mixChannel`. |
accumulator | dynamic | — | The accumulator input consumed by `mixChannel`. |
frameCount | dynamic | — | Number of entries or units to process. |
function mixChannelWithStereoVolumes(mixer, channel, accumulator, frameCount, leftVolumeValue, rightVolumeValue)Mix a channel using scalar stereo volumes.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixChannelWithStereoVolumes`. |
channel | dynamic | — | The channel input consumed by `mixChannelWithStereoVolumes`. |
accumulator | dynamic | — | The accumulator input consumed by `mixChannelWithStereoVolumes`. |
frameCount | dynamic | — | Number of entries or units to process. |
leftVolumeValue | dynamic | — | The left volume value input consumed by `mixChannelWithStereoVolumes`. |
rightVolumeValue | dynamic | — | The right volume value input consumed by `mixChannelWithStereoVolumes`. |
function mixChannelWithVolumes(mixer, channel, accumulator, frameCount, volumes)Mix channel with volumes into the active audio buffer.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixChannelWithVolumes`. |
channel | dynamic | — | The channel input consumed by `mixChannelWithVolumes`. |
accumulator | dynamic | — | The accumulator input consumed by `mixChannelWithVolumes`. |
frameCount | dynamic | — | Number of entries or units to process. |
volumes | dynamic | — | The volumes input consumed by `mixChannelWithVolumes`. |
function mixerF32(value)Implements the `mixerF32` operation for `miniquake.sound.mixer` (mixer f32).
| Parameter | Type | Default | Description |
|---|---|---|---|
value | dynamic | — | Value consumed by `mixerF32`. |
function mixForSubmit(mixer, frameCount)Paint one backend block into the reusable submission buffer. audioSubmit copies the samples synchronously into its fixed waveOut header ring.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixForSubmit`. |
frameCount | dynamic | — | Number of entries or units to process. |
function mixIntoOutput(mixer, frameCount, output)Mix into a caller-owned PCM buffer using persistent paint scratch storage.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixIntoOutput`. |
frameCount | dynamic | — | Number of entries or units to process. |
output | dynamic | — | Destination buffer that receives mixed PCM samples. |
function mixMusic(mixer, accumulator, frameCount)Mix music into the active audio buffer.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `mixMusic`. |
accumulator | dynamic | — | The accumulator input consumed by `mixMusic`. |
frameCount | dynamic | — | Number of entries or units to process. |
const MUSIC_DECODE_FRAMES = 4096Defines the music decode frames value used by `miniquake.sound.mixer`.
function musicInfo(mixer)Implements the `musicInfo` operation for `miniquake.sound.mixer` (music info).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `musicInfo`. |
function nextRandom()Return next random for the active module state.
function open(mixer)Implements the `open` operation for `miniquake.sound.mixer` (open).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `open`. |
paintAccumulatorScratchS_PaintChannels owns fixed paint/volume buffers in the original engine. Keep equivalent reusable storage so a real-time 44.1-kHz stream does not allocate several large arrays for every 512-sample block.
paintLeftVolumeScratchTracks the module-level paint left volume scratch state owned by `miniquake.sound.mixer`.
paintOutputScratchTracks the module-level paint output scratch state owned by `miniquake.sound.mixer`.
paintRightVolumeScratchTracks the module-level paint right volume scratch state owned by `miniquake.sound.mixer`.
paintStaticEffectScratchTracks the module-level paint static effect scratch state owned by `miniquake.sound.mixer`.
paintStaticRepresentativeScratchTracks the module-level paint static representative scratch state owned by `miniquake.sound.mixer`.
paintSurvivorScratchTracks the module-level paint survivor scratch state owned by `miniquake.sound.mixer`.
function pauseMusic(mixer)Implements the `pauseMusic` operation for `miniquake.sound.mixer` (pause music).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `pauseMusic`. |
function pickDynamicChannel(mixer, newEntityNumber, newChannelNumber)SND_PickChannel scans the fixed eight dynamic slots in order. A matching non-zero entity channel wins immediately; otherwise the sound with the shortest remaining life is replaced, while a listener sound is protected from a non-listener replacement.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `pickDynamicChannel`. |
newEntityNumber | dynamic | — | The new entity number input consumed by `pickDynamicChannel`. |
newChannelNumber | dynamic | — | The new channel number input consumed by `pickDynamicChannel`. |
function play(mixer, arguments)Play the requested value through the active media subsystem.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `play`. |
arguments | dynamic | — | Command-line arguments to inspect or execute. |
function playMusic(mixer, track, looping)Play music through the active media subsystem.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `playMusic`. |
track | dynamic | — | The track input consumed by `playMusic`. |
looping | dynamic | — | The looping input consumed by `playMusic`. |
function playVol(mixer, arguments)Play vol through the active media subsystem.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `playVol`. |
arguments | dynamic | — | Command-line arguments to inspect or execute. |
function precache(mixer, names)Preload and register the the requested value asset.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `precache`. |
names | dynamic | — | The names input consumed by `precache`. |
randomSeedTracks the module-level random seed state owned by `miniquake.sound.mixer`.
function removeChannelAt(mixer, victim)Release state for remove channel at.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `removeChannelAt`. |
victim | dynamic | — | The victim input consumed by `removeChannelAt`. |
function resumeMusic(mixer)Implements the `resumeMusic` operation for `miniquake.sound.mixer` (resume music).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `resumeMusic`. |
function setListenerEntity(mixer, entityNumber)Update module state for listener entity.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `setListenerEntity`. |
entityNumber | dynamic | — | The entity number input consumed by `setListenerEntity`. |
function setRandomSeed(seed)Update module state for random seed.
| Parameter | Type | Default | Description |
|---|---|---|---|
seed | dynamic | — | The seed input consumed by `setRandomSeed`. |
function soundInfo(mixer)Implements the `soundInfo` operation for `miniquake.sound.mixer` (sound info).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `soundInfo`. |
function soundList(mixer)Implements the `soundList` operation for `miniquake.sound.mixer` (sound list).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `soundList`. |
function startSound(mixer, entityNumber, channelNumber, name, origin, volume, attenuation)Initialize state for start sound.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `startSound`. |
entityNumber | dynamic | — | The entity number input consumed by `startSound`. |
channelNumber | dynamic | — | The channel number input consumed by `startSound`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
origin | dynamic | — | World-space origin of the operation. |
volume | dynamic | — | The volume input consumed by `startSound`. |
attenuation | dynamic | — | The attenuation input consumed by `startSound`. |
const STATIC_CHANNEL = -32768Defines the static channel value used by `miniquake.sound.mixer`.
const STATIC_FIRST = 12Defines the static first value used by `miniquake.sound.mixer`.
function staticSound(mixer, name, origin, volume, attenuation)Implements the `staticSound` operation for `miniquake.sound.mixer` (static sound).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `staticSound`. |
name | dynamic | — | Stable name that identifies the requested object or option. |
origin | dynamic | — | World-space origin of the operation. |
volume | dynamic | — | The volume input consumed by `staticSound`. |
attenuation | dynamic | — | The attenuation input consumed by `staticSound`. |
function stopAll(mixer)Finalize state for stop all.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `stopAll`. |
function stopMusic(mixer)Finalize state for stop music.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `stopMusic`. |
function stopSound(mixer, entityNumber, channelNumber)Finalize state for stop sound.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `stopSound`. |
entityNumber | dynamic | — | The entity number input consumed by `stopSound`. |
channelNumber | dynamic | — | The channel number input consumed by `stopSound`. |
function unblock(mixer)Implements the `unblock` operation for `miniquake.sound.mixer` (unblock).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `unblock`. |
function update(mixer, frameTime, mixAhead)Implements the `update` operation for `miniquake.sound.mixer` (update).
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `update`. |
frameTime | dynamic | — | Time value used by the operation. |
mixAhead | dynamic | — | The mix ahead input consumed by `update`. |
function updateAmbient(mixer, map, origin, frameTime, ambientLevel, ambientFade)S_UpdateAmbientSounds: BSP leaves contain four ambient bytes. Stock Quake uses slot 0 for water and slot 1 for wind and fades them at ambient_fade.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `updateAmbient`. |
map | dynamic | — | The map input consumed by `updateAmbient`. |
origin | dynamic | — | World-space origin of the operation. |
frameTime | dynamic | — | Time value used by the operation. |
ambientLevel | dynamic | — | The ambient level input consumed by `updateAmbient`. |
ambientFade | dynamic | — | The ambient fade input consumed by `updateAmbient`. |
function updateEntityOrigins(mixer, entities)Update module state for entity origins.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `updateEntityOrigins`. |
entities | dynamic | — | The entities input consumed by `updateEntityOrigins`. |
function updateListener(mixer, origin, forward, right)Update module state for listener.
| Parameter | Type | Default | Description |
|---|---|---|---|
mixer | dynamic | — | The mixer input consumed by `updateListener`. |
origin | dynamic | — | World-space origin of the operation. |
forward | dynamic | — | The forward input consumed by `updateListener`. |
right | dynamic | — | The right input consumed by `updateListener`. |