MiniQuake2

src/miniquake2/audio/mixer.ml

Provides miniquake2 audio mixer facilities for this project.

Package
miniquake2.audio.mixer
Reachable
Yes

Imports

Declarations

miniquake2.audio.mixer.Channel struct

channelLifeLeft

inline function channelLifeLeft(mixer, channel)

Return the channel life left value.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
channeldynamic—channel value consumed by this operation.

View source

clamp16

inline function clamp16(value)

Clamp 16.

ParameterTypeDefaultDescription
valuedynamic—Value consumed or transformed by the operation.

View source

clearAutoSounds

function clearAutoSounds(mixer)

EntityState.sound values are Quake "autosounds": they are rebuilt from the current snapshot every client frame and loop even when the WAV has no cue chunk. Their phase follows painted time so a refreshed channel does not restart at sample zero on every rendered frame.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

create

function create(sampleRate)

Creates create for the miniquake2 audio mixer module.

ParameterTypeDefaultDescription
sampleRatedynamic—sampleRate value consumed by this operation.

View source

decodeMusicChunk

function decodeMusicChunk(track, restart)

Decode music chunk.

ParameterTypeDefaultDescription
trackdynamic—track value consumed by this operation.
restartdynamic—restart value consumed by this operation.

View source

divide255Positive

inline function divide255Positive(value)

Divide 255 positive.

ParameterTypeDefaultDescription
valuedynamic—Value consumed or transformed by the operation.

View source

enableOptimizedStorage

function enableOptimizedStorage(mixer)

Disable the compact compatibility view in latency-sensitive product paths. The fixed queue remains authoritative and avoids copying every future sound whenever a new playsound is inserted or issued.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

issuePending

function issuePending(mixer, absoluteFrame)

Report whether issue pending.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
absoluteFramedynamic—absoluteFrame value consumed by this operation.

View source

MAX_CHANNELS

const MAX_CHANNELS = 32

Defines the max channels constant used by the miniquake2 audio mixer module.

View source

MAX_PLAYSOUNDS

const MAX_PLAYSOUNDS = 128

Defines the max playsounds constant used by the miniquake2 audio mixer module.

View source

mix

function mix(mixer, frameCount)

Mix state.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
frameCountdynamic—Number of frame to process.

View source

MIX_FRAC_BITS

const MIX_FRAC_BITS = 16

Defines the mix frac bits constant used by the miniquake2 audio mixer module.

View source

MIX_FRAC_ONE

const MIX_FRAC_ONE = 65536

Defines the mix frac one constant used by the miniquake2 audio mixer module.

View source

MIX_VOLUME_BITS

const MIX_VOLUME_BITS = 16

Defines the mix volume bits constant used by the miniquake2 audio mixer module.

View source

MIX_VOLUME_ONE

const MIX_VOLUME_ONE = 65536

Defines the mix volume one constant used by the miniquake2 audio mixer module.

View source

miniquake2.audio.mixer.Mixer struct

mixInto

function mixInto(mixer, output, frameCount)

Paint exactly frameCount interleaved signed-16 stereo frames into caller- owned storage. Pending sounds are issued in timestamp order and every active channel advances once, preserving deterministic mixer time across reuse.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
outputdynamic—Output collection or buffer populated by the operation.
frameCountdynamic—Number of frame to process.

View source

mixReusable

function mixReusable(mixer, frameCount)

The waveOut bridge copies submitted PCM into its own ring. The real-time product can therefore reuse one mixer-owned block and avoid a fresh bytes allocation (and later GC scan) for every audio submission.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
frameCountdynamic—Number of frame to process.

View source

MUSIC_DECODE_FRAMES

const MUSIC_DECODE_FRAMES = 4096

Defines the music decode frames constant used by the miniquake2 audio mixer module.

View source

miniquake2.audio.mixer.MusicTrack struct

pauseMusic

function pauseMusic(mixer)

Pause music.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

pendingAt

function pendingAt(mixer, index)

Return one pending sound from the authoritative fixed queue.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
indexdynamic—Zero-based index of the affected item.

View source

pendingCount

function pendingCount(mixer)

Return the number of pending sounds without exposing queue capacity.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

pickChannelSlot

function pickChannelSlot(mixer, entityNumber, entityChannel)

S_PickChannel: explicit entity channels override themselves; otherwise the shortest-lived channel is replaced. A non-player sound may never evict a live channel owned by the view entity.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
entityNumberdynamic—entityNumber value consumed by this operation.
entityChanneldynamic—entityChannel value consumed by this operation.

View source

playMusic

function playMusic(mixer, filesystem, track, looping)

Play music.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
filesystemdynamic—filesystem value consumed by this operation.
trackdynamic—track value consumed by this operation.
loopingdynamic—looping value consumed by this operation.

View source

refreshPendingView

function refreshPendingView(mixer)

Rebuild the legacy compact view only for component tests and API clients that explicitly retain it. Product mixers disable this allocation path.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

resumeMusic

function resumeMusic(mixer)

Resume music.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

sampleAt

inline function sampleAt(sound, frame, channel)

Sample at.

ParameterTypeDefaultDescription
sounddynamic—sound value consumed by this operation.
framedynamic—frame value consumed by this operation.
channeldynamic—channel value consumed by this operation.

View source

scaleChannelSampleFixed

inline function scaleChannelSampleFixed(sample, volume)

Scale channel sample fixed.

ParameterTypeDefaultDescription
sampledynamic—sample value consumed by this operation.
volumedynamic—volume value consumed by this operation.

View source

setListenerEntity

function setListenerEntity(mixer, number)

Set listener entity.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
numberdynamic—number value consumed by this operation.

View source

setMasterVolume

function setMasterVolume(mixer, value)

Set master volume.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
valuedynamic—Value consumed or transformed by the operation.

View source

setMusicVolume

function setMusicVolume(mixer, value)

Set music volume.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
valuedynamic—Value consumed or transformed by the operation.

View source

spatialVolumes

function spatialVolumes(listenerOrigin, listenerRight, sourceOrigin, masterVolume, attenuation)

Return the spatial volumes value.

ParameterTypeDefaultDescription
listenerOrigindynamic—listenerOrigin value consumed by this operation.
listenerRightdynamic—listenerRight value consumed by this operation.
sourceOrigindynamic—sourceOrigin value consumed by this operation.
masterVolumedynamic—masterVolume value consumed by this operation.
attenuationdynamic—attenuation value consumed by this operation.

View source

spatialVolumesInto

function spatialVolumesInto(output, listenerOrigin, listenerRight, sourceOrigin, masterVolume, attenuation)

Populate the spatial volumes destination.

ParameterTypeDefaultDescription
outputdynamic—Output collection or buffer populated by the operation.
listenerOrigindynamic—listenerOrigin value consumed by this operation.
listenerRightdynamic—listenerRight value consumed by this operation.
sourceOrigindynamic—sourceOrigin value consumed by this operation.
masterVolumedynamic—masterVolume value consumed by this operation.
attenuationdynamic—attenuation value consumed by this operation.

View source

startAutoSound

function startAutoSound(mixer, sound, leftVolume, rightVolume)

Start auto sound.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
sounddynamic—sound value consumed by this operation.
leftVolumedynamic—leftVolume value consumed by this operation.
rightVolumedynamic—rightVolume value consumed by this operation.

View source

startSound

function startSound(mixer, sound, entityNumber, entityChannel, leftVolume, rightVolume)

Start sound.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
sounddynamic—sound value consumed by this operation.
entityNumberdynamic—entityNumber value consumed by this operation.
entityChanneldynamic—entityChannel value consumed by this operation.
leftVolumedynamic—leftVolume value consumed by this operation.
rightVolumedynamic—rightVolume value consumed by this operation.

View source

startSoundAt

function startSoundAt(mixer, sound, entityNumber, entityChannel, leftVolume, rightVolume, startFrame)

Start sound at.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
sounddynamic—sound value consumed by this operation.
entityNumberdynamic—entityNumber value consumed by this operation.
entityChanneldynamic—entityChannel value consumed by this operation.
leftVolumedynamic—leftVolume value consumed by this operation.
rightVolumedynamic—rightVolume value consumed by this operation.
startFramedynamic—startFrame value consumed by this operation.

View source

stopAll

function stopAll(mixer)

Stop all.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

stopMusic

function stopMusic(mixer)

Stop music.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.

View source

synchronizeMusicTrack

function synchronizeMusicTrack(mixer, filesystem, configValue)

Synchronize music track.

ParameterTypeDefaultDescription
mixerdynamic—mixer value consumed by this operation.
filesystemdynamic—filesystem value consumed by this operation.
configValuedynamic—configValue value consumed by this operation.

View source