Files
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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
channel | dynamic | — | channel value consumed by this operation. |
View source
# clamp16
inline function clamp16(value)
Clamp 16.
| Parameter | Type | Default | Description |
|---|
value | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# create
function create(sampleRate)
Creates create for the miniquake2 audio mixer module.
| Parameter | Type | Default | Description |
|---|
sampleRate | dynamic | — | sampleRate value consumed by this operation. |
View source
# decodeMusicChunk
function decodeMusicChunk(track, restart)
Decode music chunk.
| Parameter | Type | Default | Description |
|---|
track | dynamic | — | track value consumed by this operation. |
restart | dynamic | — | restart value consumed by this operation. |
View source
# divide255Positive
inline function divide255Positive(value)
Divide 255 positive.
| Parameter | Type | Default | Description |
|---|
value | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# issuePending
function issuePending(mixer, absoluteFrame)
Report whether issue pending.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
absoluteFrame | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
frameCount | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
output | dynamic | — | Output collection or buffer populated by the operation. |
frameCount | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
frameCount | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# pendingAt
function pendingAt(mixer, index)
Return one pending sound from the authoritative fixed queue.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
index | dynamic | — | Zero-based index of the affected item. |
View source
# pendingCount
function pendingCount(mixer)
Return the number of pending sounds without exposing queue capacity.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
entityNumber | dynamic | — | entityNumber value consumed by this operation. |
entityChannel | dynamic | — | entityChannel value consumed by this operation. |
View source
# playMusic
function playMusic(mixer, filesystem, track, looping)
Play music.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
filesystem | dynamic | — | filesystem value consumed by this operation. |
track | dynamic | — | track value consumed by this operation. |
looping | dynamic | — | 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.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# resumeMusic
function resumeMusic(mixer)
Resume music.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# sampleAt
inline function sampleAt(sound, frame, channel)
Sample at.
| Parameter | Type | Default | Description |
|---|
sound | dynamic | — | sound value consumed by this operation. |
frame | dynamic | — | frame value consumed by this operation. |
channel | dynamic | — | channel value consumed by this operation. |
View source
# scaleChannelSampleFixed
inline function scaleChannelSampleFixed(sample, volume)
Scale channel sample fixed.
| Parameter | Type | Default | Description |
|---|
sample | dynamic | — | sample value consumed by this operation. |
volume | dynamic | — | volume value consumed by this operation. |
View source
# setListenerEntity
function setListenerEntity(mixer, number)
Set listener entity.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
number | dynamic | — | number value consumed by this operation. |
View source
# setMasterVolume
function setMasterVolume(mixer, value)
Set master volume.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
value | dynamic | — | Value consumed or transformed by the operation. |
View source
# setMusicVolume
function setMusicVolume(mixer, value)
Set music volume.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
value | dynamic | — | Value consumed or transformed by the operation. |
View source
# spatialVolumes
function spatialVolumes(listenerOrigin, listenerRight, sourceOrigin, masterVolume, attenuation)
Return the spatial volumes value.
| Parameter | Type | Default | Description |
|---|
listenerOrigin | dynamic | — | listenerOrigin value consumed by this operation. |
listenerRight | dynamic | — | listenerRight value consumed by this operation. |
sourceOrigin | dynamic | — | sourceOrigin value consumed by this operation. |
masterVolume | dynamic | — | masterVolume value consumed by this operation. |
attenuation | dynamic | — | attenuation value consumed by this operation. |
View source
# spatialVolumesInto
function spatialVolumesInto(output, listenerOrigin, listenerRight, sourceOrigin, masterVolume, attenuation)
Populate the spatial volumes destination.
| Parameter | Type | Default | Description |
|---|
output | dynamic | — | Output collection or buffer populated by the operation. |
listenerOrigin | dynamic | — | listenerOrigin value consumed by this operation. |
listenerRight | dynamic | — | listenerRight value consumed by this operation. |
sourceOrigin | dynamic | — | sourceOrigin value consumed by this operation. |
masterVolume | dynamic | — | masterVolume value consumed by this operation. |
attenuation | dynamic | — | attenuation value consumed by this operation. |
View source
# startAutoSound
function startAutoSound(mixer, sound, leftVolume, rightVolume)
Start auto sound.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
sound | dynamic | — | sound value consumed by this operation. |
leftVolume | dynamic | — | leftVolume value consumed by this operation. |
rightVolume | dynamic | — | rightVolume value consumed by this operation. |
View source
# startSound
function startSound(mixer, sound, entityNumber, entityChannel, leftVolume, rightVolume)
Start sound.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
sound | dynamic | — | sound value consumed by this operation. |
entityNumber | dynamic | — | entityNumber value consumed by this operation. |
entityChannel | dynamic | — | entityChannel value consumed by this operation. |
leftVolume | dynamic | — | leftVolume value consumed by this operation. |
rightVolume | dynamic | — | rightVolume value consumed by this operation. |
View source
# startSoundAt
function startSoundAt(mixer, sound, entityNumber, entityChannel, leftVolume, rightVolume, startFrame)
Start sound at.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
sound | dynamic | — | sound value consumed by this operation. |
entityNumber | dynamic | — | entityNumber value consumed by this operation. |
entityChannel | dynamic | — | entityChannel value consumed by this operation. |
leftVolume | dynamic | — | leftVolume value consumed by this operation. |
rightVolume | dynamic | — | rightVolume value consumed by this operation. |
startFrame | dynamic | — | startFrame value consumed by this operation. |
View source
# stopAll
function stopAll(mixer)
Stop all.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# stopMusic
function stopMusic(mixer)
Stop music.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
View source
# synchronizeMusicTrack
function synchronizeMusicTrack(mixer, filesystem, configValue)
Synchronize music track.
| Parameter | Type | Default | Description |
|---|
mixer | dynamic | — | mixer value consumed by this operation. |
filesystem | dynamic | — | filesystem value consumed by this operation. |
configValue | dynamic | — | configValue value consumed by this operation. |
View source