Skip to content

Audio

Sektor's runtime audio is event-driven, deterministic, and save-exact. Sounds are components you author in the Inspector, Event Sheets drive them with picked-instance precision, and playback state is real simulation state: it participates in replay hashes and restores from a save file to the exact PCM sample.

The Audio Source component

Field Notes
audioAsset An imported PCM WAV from your project
playOnStart Begin playing when Play begins
loop Loop until stopped
volume Authored gain, 0 to 1
spatialBlend 0 is pure 2D; 1 is fully positional

spatialBlend interpolates between flat 2D playback and world-space distance attenuation with stereo pan relative to the gameplay Camera. Music sits at 0, a crackling campfire at 1, UI feedback anywhere between.

Driving audio from Events

Audio actions obey normal picked-instance rules: play a sound on the torch the player lit, not on all forty torches.

Operation Kind
audio.play Action, starts from the beginning
audio.pause / audio.resume / audio.stop Actions
audio.set_volume Action, immediate runtime gain
audio.fade_volume Action, fixed-tick linear fade
audio.is_playing / audio.is_paused Conditions
audio.on_finished Trigger, fires once when a non-looping clip completes

Sting, then back to the music

Event 1, trigger QuestCompleted custom event: audio.fade_volume on Music to 0.2 over 0.5 seconds, audio.play on VictorySting.

Event 2, trigger audio.on_finished on VictorySting: audio.fade_volume on Music back to 0.65 over 1 second.

Deterministic and save-exact

Playback cursors, gains, generations, and in-progress fades are authoritative fixed-tick state:

  • They participate in the replay state hash, so an automated test can prove audio behavior did not drift.
  • Player saves capture them, and loading seeks the recreated voice to the saved PCM sample. Load mid-song and the song continues from that instant.

Studio Play and the standalone Player project this state into the same native mixer.

Diagnostics

runtime.audio.instances exposes each source's status, playback and duration seconds, runtime gain, loop state, completion edge, and any active fade. Platform-level state lives under runtime.audio.activeSourceCount and lastError. An AI collaborator inspects these instead of assuming a sound reached the device.

Recipe: a campfire that sounds real

  1. Import campfire_loop.wav (PCM WAV) via the Assets panel.
  2. Select your campfire model, Add Component → Audio Source: the loop asset, loop on, playOnStart on, volume 0.8, spatialBlend 1.
  3. Press Play and walk around the fire. It pans and fades with distance.
  4. Add an interaction: on E pressed near the fire, audio.stop on the picked campfire and swap its emissive off. The fire you doused goes silent; the others keep crackling.

Automate it

{"op":"component.add","id":9,"type":"audio_source"}
{"op":"component.audio_source.set","id":9,"audioAsset":"asset_audio_0123456789",
 "playOnStart":true,"loop":true,"volume":0.65,"spatialBlend":0.8}

Scope today

Buses, DSP and reverb, pitch, compressed and streamed codecs, and per-play transient voices are deliberately later layers. The current foundation covers component-attached 2D and 3D playback with the full deterministic contract.