MiniQuake

src/miniquake/sound/mixer.ml

Package
miniquake.sound.mixer
Reachable
Yes

Imports

Declarations

AMBIENT_WATER_ENTITY

const AMBIENT_WATER_ENTITY = -1001

Defines the ambient water entity value used by `miniquake.sound.mixer`.

View source

AMBIENT_WIND_ENTITY

const AMBIENT_WIND_ENTITY = -1002

Defines the ambient wind entity value used by `miniquake.sound.mixer`.

View source

ambientTarget

function ambientTarget(levelByte, ambientLevel)

Implements the `ambientTarget` operation for `miniquake.sound.mixer` (ambient target).

ParameterTypeDefaultDescription
levelBytedynamic—The level byte input consumed by `ambientTarget`.
ambientLeveldynamic—The ambient level input consumed by `ambientTarget`.

View source

block

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.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `block`.

View source

blockDepth

function blockDepth(mixer)

Implements the `blockDepth` operation for `miniquake.sound.mixer` (block depth).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `blockDepth`.

View source

channelVolumes

function channelVolumes(mixer, channel)

Implements the `channelVolumes` operation for `miniquake.sound.mixer` (channel volumes).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `channelVolumes`.
channeldynamic—The channel input consumed by `channelVolumes`.

View source

channelVolumesInto

function channelVolumesInto(mixer, channel, leftValues, rightValues, index)

Calculate one channel's stereo volumes into reusable parallel arrays.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `channelVolumesInto`.
channeldynamic—The channel input consumed by `channelVolumesInto`.
leftValuesdynamic—The left values input consumed by `channelVolumesInto`.
rightValuesdynamic—The right values input consumed by `channelVolumesInto`.
indexdynamic—Zero-based index of the requested entry.

View source

clampSample

function clampSample(value)

Return a validated clamp sample value.

ParameterTypeDefaultDescription
valuedynamic—Value consumed by `clampSample`.

View source

close

function close(mixer)

Implements the `close` operation for `miniquake.sound.mixer` (close).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `close`.

View source

convertToMono16

function convertToMono16(info, source, targetRate)

Convert data for convert to mono16.

ParameterTypeDefaultDescription
infodynamic—The info input consumed by `convertToMono16`.
sourcedynamic—Source value or collection to read.
targetRatedynamic—The target rate input consumed by `convertToMono16`.

View source

create

function create(filesystem, sampleRate)

Implements the `create` operation for `miniquake.sound.mixer` (create).

ParameterTypeDefaultDescription
filesystemdynamic—The filesystem input consumed by `create`.
sampleRatedynamic—The sample rate input consumed by `create`.

View source

decodeMusicChunk

function decodeMusicChunk(track, restart)

Read and validate music chunk.

ParameterTypeDefaultDescription
trackdynamic—The track input consumed by `decodeMusicChunk`.
restartdynamic—The restart input consumed by `decodeMusicChunk`.

View source

desiredQueuedBuffers

function desiredQueuedBuffers(mixer, frameTime, mixAhead)

Implements the `desiredQueuedBuffers` operation for `miniquake.sound.mixer` (desired queued buffers).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `desiredQueuedBuffers`.
frameTimedynamic—Time value used by the operation.
mixAheaddynamic—The mix ahead input consumed by `desiredQueuedBuffers`.

View source

discardOldestChannel

function discardOldestChannel(mixer, newEntityNumber)

Release or consume state for discard oldest channel.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `discardOldestChannel`.
newEntityNumberdynamic—The new entity number input consumed by `discardOldestChannel`.

View source

dynamicChannelCount

function dynamicChannelCount(mixer)

Return dynamic channel count derived from the active module state.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `dynamicChannelCount`.

View source

effectIndex

function effectIndex(mixer, name)

Return effect index derived from the active module state.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `effectIndex`.
namedynamic—Stable name that identifies the requested object or option.

View source

ensureAmbientChannel

function ensureAmbientChannel(mixer, entityNumber, channelNumber, name)

Ensure sufficient storage or state for ambient channel.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `ensureAmbientChannel`.
entityNumberdynamic—The entity number input consumed by `ensureAmbientChannel`.
channelNumberdynamic—The channel number input consumed by `ensureAmbientChannel`.
namedynamic—Stable name that identifies the requested object or option.

View source

fadeAmbientChannel

function fadeAmbientChannel(channel, target, step, origin)

Implements the `fadeAmbientChannel` operation for `miniquake.sound.mixer` (fade ambient channel).

ParameterTypeDefaultDescription
channeldynamic—The channel input consumed by `fadeAmbientChannel`.
targetdynamic—The target input consumed by `fadeAmbientChannel`.
stepdynamic—The step input consumed by `fadeAmbientChannel`.
origindynamic—World-space origin of the operation.

View source

findChannel

function findChannel(mixer, entityNumber, channelNumber)

Return channel.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `findChannel`.
entityNumberdynamic—The entity number input consumed by `findChannel`.
channelNumberdynamic—The channel number input consumed by `findChannel`.

View source

hasExtension

function hasExtension(name)

Report whether extension.

ParameterTypeDefaultDescription
namedynamic—Stable name that identifies the requested object or option.

View source

isDynamicChannel

function isDynamicChannel(channel)

Report whether is dynamic channel.

ParameterTypeDefaultDescription
channeldynamic—The channel input consumed by `isDynamicChannel`.

View source

loadEffect

function loadEffect(mixer, name)

Read and validate effect.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `loadEffect`.
namedynamic—Stable name that identifies the requested object or option.

View source

localSound

function localSound(mixer, name)

Implements the `localSound` operation for `miniquake.sound.mixer` (local sound).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `localSound`.
namedynamic—Stable name that identifies the requested object or option.

View source

MAX_CHANNELS

const MAX_CHANNELS = 128

Defines the max channels value used by `miniquake.sound.mixer`.

View source

MAX_DYNAMIC_CHANNELS

const MAX_DYNAMIC_CHANNELS = 8

Defines the max dynamic channels value used by `miniquake.sound.mixer`.

View source

MAX_QUEUED_BUFFERS

const MAX_QUEUED_BUFFERS = 7

Defines the max queued buffers value used by `miniquake.sound.mixer`.

View source

MIN_QUEUED_BUFFERS

const MIN_QUEUED_BUFFERS = 3

Defines the min queued buffers value used by `miniquake.sound.mixer`.

View source

mix

function mix(mixer, frameCount)

Mix the requested value into the active audio buffer.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mix`.
frameCountdynamic—Number of entries or units to process.

View source

MIX_FRAMES

const MIX_FRAMES = 512

WinQuake reserves 128 software channels. The former 32-channel limit could evict looping/static sounds very quickly on a populated retail map.

View source

mixChannel

function mixChannel(mixer, channel, accumulator, frameCount)

Mix channel into the active audio buffer.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixChannel`.
channeldynamic—The channel input consumed by `mixChannel`.
accumulatordynamic—The accumulator input consumed by `mixChannel`.
frameCountdynamic—Number of entries or units to process.

View source

mixChannelWithStereoVolumes

function mixChannelWithStereoVolumes(mixer, channel, accumulator, frameCount, leftVolumeValue, rightVolumeValue)

Mix a channel using scalar stereo volumes.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixChannelWithStereoVolumes`.
channeldynamic—The channel input consumed by `mixChannelWithStereoVolumes`.
accumulatordynamic—The accumulator input consumed by `mixChannelWithStereoVolumes`.
frameCountdynamic—Number of entries or units to process.
leftVolumeValuedynamic—The left volume value input consumed by `mixChannelWithStereoVolumes`.
rightVolumeValuedynamic—The right volume value input consumed by `mixChannelWithStereoVolumes`.

View source

mixChannelWithVolumes

function mixChannelWithVolumes(mixer, channel, accumulator, frameCount, volumes)

Mix channel with volumes into the active audio buffer.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixChannelWithVolumes`.
channeldynamic—The channel input consumed by `mixChannelWithVolumes`.
accumulatordynamic—The accumulator input consumed by `mixChannelWithVolumes`.
frameCountdynamic—Number of entries or units to process.
volumesdynamic—The volumes input consumed by `mixChannelWithVolumes`.

View source

mixerF32

function mixerF32(value)

Implements the `mixerF32` operation for `miniquake.sound.mixer` (mixer f32).

ParameterTypeDefaultDescription
valuedynamic—Value consumed by `mixerF32`.

View source

mixForSubmit

function mixForSubmit(mixer, frameCount)

Paint one backend block into the reusable submission buffer. audioSubmit copies the samples synchronously into its fixed waveOut header ring.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixForSubmit`.
frameCountdynamic—Number of entries or units to process.

View source

mixIntoOutput

function mixIntoOutput(mixer, frameCount, output)

Mix into a caller-owned PCM buffer using persistent paint scratch storage.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixIntoOutput`.
frameCountdynamic—Number of entries or units to process.
outputdynamic—Destination buffer that receives mixed PCM samples.

View source

mixMusic

function mixMusic(mixer, accumulator, frameCount)

Mix music into the active audio buffer.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `mixMusic`.
accumulatordynamic—The accumulator input consumed by `mixMusic`.
frameCountdynamic—Number of entries or units to process.

View source

MUSIC_DECODE_FRAMES

const MUSIC_DECODE_FRAMES = 4096

Defines the music decode frames value used by `miniquake.sound.mixer`.

View source

musicInfo

function musicInfo(mixer)

Implements the `musicInfo` operation for `miniquake.sound.mixer` (music info).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `musicInfo`.

View source

nextRandom

function nextRandom()

Return next random for the active module state.

View source

open

function open(mixer)

Implements the `open` operation for `miniquake.sound.mixer` (open).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `open`.

View source

paintAccumulatorScratch

paintAccumulatorScratch

S_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.

View source

paintLeftVolumeScratch

paintLeftVolumeScratch

Tracks the module-level paint left volume scratch state owned by `miniquake.sound.mixer`.

View source

paintOutputScratch

paintOutputScratch

Tracks the module-level paint output scratch state owned by `miniquake.sound.mixer`.

View source

paintRightVolumeScratch

paintRightVolumeScratch

Tracks the module-level paint right volume scratch state owned by `miniquake.sound.mixer`.

View source

paintStaticEffectScratch

paintStaticEffectScratch

Tracks the module-level paint static effect scratch state owned by `miniquake.sound.mixer`.

View source

paintStaticRepresentativeScratch

paintStaticRepresentativeScratch

Tracks the module-level paint static representative scratch state owned by `miniquake.sound.mixer`.

View source

paintSurvivorScratch

paintSurvivorScratch

Tracks the module-level paint survivor scratch state owned by `miniquake.sound.mixer`.

View source

pauseMusic

function pauseMusic(mixer)

Implements the `pauseMusic` operation for `miniquake.sound.mixer` (pause music).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `pauseMusic`.

View source

pickDynamicChannel

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.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `pickDynamicChannel`.
newEntityNumberdynamic—The new entity number input consumed by `pickDynamicChannel`.
newChannelNumberdynamic—The new channel number input consumed by `pickDynamicChannel`.

View source

play

function play(mixer, arguments)

Play the requested value through the active media subsystem.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `play`.
argumentsdynamic—Command-line arguments to inspect or execute.

View source

playMusic

function playMusic(mixer, track, looping)

Play music through the active media subsystem.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `playMusic`.
trackdynamic—The track input consumed by `playMusic`.
loopingdynamic—The looping input consumed by `playMusic`.

View source

playVol

function playVol(mixer, arguments)

Play vol through the active media subsystem.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `playVol`.
argumentsdynamic—Command-line arguments to inspect or execute.

View source

precache

function precache(mixer, names)

Preload and register the the requested value asset.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `precache`.
namesdynamic—The names input consumed by `precache`.

View source

randomSeed

randomSeed

Tracks the module-level random seed state owned by `miniquake.sound.mixer`.

View source

removeChannelAt

function removeChannelAt(mixer, victim)

Release state for remove channel at.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `removeChannelAt`.
victimdynamic—The victim input consumed by `removeChannelAt`.

View source

resumeMusic

function resumeMusic(mixer)

Implements the `resumeMusic` operation for `miniquake.sound.mixer` (resume music).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `resumeMusic`.

View source

setListenerEntity

function setListenerEntity(mixer, entityNumber)

Update module state for listener entity.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `setListenerEntity`.
entityNumberdynamic—The entity number input consumed by `setListenerEntity`.

View source

setRandomSeed

function setRandomSeed(seed)

Update module state for random seed.

ParameterTypeDefaultDescription
seeddynamic—The seed input consumed by `setRandomSeed`.

View source

soundInfo

function soundInfo(mixer)

Implements the `soundInfo` operation for `miniquake.sound.mixer` (sound info).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `soundInfo`.

View source

soundList

function soundList(mixer)

Implements the `soundList` operation for `miniquake.sound.mixer` (sound list).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `soundList`.

View source

startSound

function startSound(mixer, entityNumber, channelNumber, name, origin, volume, attenuation)

Initialize state for start sound.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `startSound`.
entityNumberdynamic—The entity number input consumed by `startSound`.
channelNumberdynamic—The channel number input consumed by `startSound`.
namedynamic—Stable name that identifies the requested object or option.
origindynamic—World-space origin of the operation.
volumedynamic—The volume input consumed by `startSound`.
attenuationdynamic—The attenuation input consumed by `startSound`.

View source

STATIC_CHANNEL

const STATIC_CHANNEL = -32768

Defines the static channel value used by `miniquake.sound.mixer`.

View source

STATIC_FIRST

const STATIC_FIRST = 12

Defines the static first value used by `miniquake.sound.mixer`.

View source

staticSound

function staticSound(mixer, name, origin, volume, attenuation)

Implements the `staticSound` operation for `miniquake.sound.mixer` (static sound).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `staticSound`.
namedynamic—Stable name that identifies the requested object or option.
origindynamic—World-space origin of the operation.
volumedynamic—The volume input consumed by `staticSound`.
attenuationdynamic—The attenuation input consumed by `staticSound`.

View source

stopAll

function stopAll(mixer)

Finalize state for stop all.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `stopAll`.

View source

stopMusic

function stopMusic(mixer)

Finalize state for stop music.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `stopMusic`.

View source

stopSound

function stopSound(mixer, entityNumber, channelNumber)

Finalize state for stop sound.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `stopSound`.
entityNumberdynamic—The entity number input consumed by `stopSound`.
channelNumberdynamic—The channel number input consumed by `stopSound`.

View source

unblock

function unblock(mixer)

Implements the `unblock` operation for `miniquake.sound.mixer` (unblock).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `unblock`.

View source

update

function update(mixer, frameTime, mixAhead)

Implements the `update` operation for `miniquake.sound.mixer` (update).

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `update`.
frameTimedynamic—Time value used by the operation.
mixAheaddynamic—The mix ahead input consumed by `update`.

View source

updateAmbient

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.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `updateAmbient`.
mapdynamic—The map input consumed by `updateAmbient`.
origindynamic—World-space origin of the operation.
frameTimedynamic—Time value used by the operation.
ambientLeveldynamic—The ambient level input consumed by `updateAmbient`.
ambientFadedynamic—The ambient fade input consumed by `updateAmbient`.

View source

updateEntityOrigins

function updateEntityOrigins(mixer, entities)

Update module state for entity origins.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `updateEntityOrigins`.
entitiesdynamic—The entities input consumed by `updateEntityOrigins`.

View source

updateListener

function updateListener(mixer, origin, forward, right)

Update module state for listener.

ParameterTypeDefaultDescription
mixerdynamic—The mixer input consumed by `updateListener`.
origindynamic—World-space origin of the operation.
forwarddynamic—The forward input consumed by `updateListener`.
rightdynamic—The right input consumed by `updateListener`.

View source