Skip to main content

Module acoustic_sab

Module acoustic_sab 

Source
Expand description

SharedArrayBuffer layout for zero-copy U3 uniform + sonic token mirror (Phase 7.4).

Layout: [header 32][uniform 352][tokens 128][float mirror 328] = 840 B (padded to 1024).

Structs§

AcousticSabHeader
SAB header — worklet polls uniform_seq / token_seq (Release/Acquire).
VoiceDescriptorSlot
64-byte cache-line-aligned voice descriptor slot with monotonic SeqLock synchronization.
VoiceSnapshot
Decoded voice snapshot returned when a SeqLock read succeeds without tear.

Constants§

ACOUSTIC_SAB_BYTES
ACOUSTIC_SAB_FLOAT_MIRROR_BYTES
ACOUSTIC_SAB_FLOAT_MIRROR_OFFSET
ACOUSTIC_SAB_HEADER_BYTES
ACOUSTIC_SAB_MAGIC
ACOUSTIC_SAB_TOKEN_BYTES
ACOUSTIC_SAB_TOKEN_OFFSET
ACOUSTIC_SAB_UNIFORM_OFFSET
ACOUSTIC_SAB_UNIFORM_PADDED
ACOUSTIC_SAB_VERSION
MAX_ACOUSTIC_VOICE_SLOTS
VOICE_DESCRIPTOR_SLOT_SIZE

Functions§

calculate_acoustic_salience
Calculate acoustic salience score $S_i = \frac{A_i \cdot \mathcal{D}}{1.0 + |\vec{P}i - \vec{P}{\text{listener}}|^2}$.
init_acoustic_sab
Initialise a SAB region: writes the header and zeroes the remaining layout. Returns false when out is smaller than ACOUSTIC_SAB_BYTES.
push_token_to_sab
Push one token into SAB ring (16 slots × 8 B).
read_uniform_from_sab
Read the AcousticUniform payload out of the SAB region; None when the slice is too short to contain it.
read_voice_slot
Consumer read: reads parameters from a voice slot; returns None if producer was writing or torn read occurred.
update_voice_slot
Producer update: writes parameters into a voice slot using odd-even SeqLock signaling.
write_uniform_to_sab
Write pod uniform + optional f32 mirror for worklet Float32Array view.
write_uniform_to_sab_with_mirror
Write the uniform plus an optional f32 mirror region for a worklet Float32Array view, then bump uniform_seq. Returns false when out is too small or the uniform would overlap the token region.