Skip to main content

Module spatial

Module spatial 

Source
Expand description

Spatial audio — position-based stereo panning, distance attenuation, and per-room reverb.

Maps entity world positions to stereo pan and volume. Provides room-type reverb presets (tight combat, long boss, cathedral shrine). All sounds can be positioned in the 2D arena for immersive audio.

§Panning model

Uses a linear stereo pan where X position maps to left/right:

  • X < 0 → more left channel
  • X > 0 → more right channel
  • X = 0 → center

§Distance attenuation

Inverse-distance model with configurable reference distance and rolloff. Sounds beyond max_distance are silent.

§Reverb

Simple Schroeder reverb with 4 comb filters + 2 allpass filters. Room presets configure delay lengths, feedback, and mix.

Structs§

DistanceModel
Distance attenuation model.
ReverbParams
Reverb parameters.
SpatialAudioSystem
Manages spatial audio: positioned sounds, distance attenuation, and reverb.
SpatialReverb
Schroeder reverb: 4 parallel comb filters → 2 series allpass filters.
SpatialSound
A sound source with a position in the arena.
StereoPan
Stereo pan result: gain for left and right channels.

Enums§

RoomType
Room type for reverb preset selection.
SoundOrigin
Origin of a sound in the game world.