Audio
Logical tracks (Master, Music, Sfx, UI, Other), per-sound handles, and bus commands consumed by UnityAudioAdapter. Persistent audio settings are stored under Persistent.audio.* (for example audio.soundMasterVolume).
Adapter: UnityAudioAdapter.
State (Persistent sample)
| Key | Purpose |
|---|---|
| Per-track volume/on/mutedVolume | Persisted via SaveTrackState (key naming in source) |
soundPoolSize, soundPoolCanExpand, soundMixerValuesMultiplier | Adapter/pool tuning |
How it looks in persistent.json
Track volumes / mute flags are stored under Persistent.audio.* (often edited through Setting with keys like audio.soundMasterVolume). The Audio service also keeps active sounds in memory; snapshot shape includes a sounds list when you call GetSettings.
{
"Persistent": {
"audio": {
"soundMasterVolume": 1,
"soundMasterOn": true,
"soundMasterMutedVolume": 0.5,
"soundMusicVolume": 1,
"soundMusicOn": true,
"soundSfxVolume": 1,
"soundSfxOn": true,
"soundUiVolume": 1,
"soundOtherVolume": 1
}
}
}Events
There is no separate GnosisAudioEvents type; GnosisAudioService publishes these string ids for UnityAudioAdapter (see GnosisAudioService.cs). Treat them as requests consumed by the adapter.
| Event id | Role |
|---|---|
REQUEST_SOUND_PLAY | Play / one-shot sound |
REQUEST_SOUND_CONTROL | Stop / pause / resume / free a handle |
REQUEST_SOUND_FADE | Fade a sound |
REQUEST_SOUND_SOLO | Solo on a track |
REQUEST_SOUND_TRACK_CONTROL | Track-level control |
REQUEST_SOUND_ALL_CONTROL | Global all-sounds control |
Functions (summary)
| Area | Functions |
|---|---|
| Snapshot | GetSettings, UpdateSettings |
| Playback | PlaySound (clipId, track, options), StopSound, PauseSound, ResumeSound, FreeSound |
| Global | StopAllSounds, PauseAllSounds, ResumeAllSounds, FreeAllSounds |
| Tracks | SetTrackVolume, MuteTrack, UnmuteTrack, FadeTrack |
| Per-sound | FadeSound, SoloSoundOnTrack, UnsoloAllTracks |
Parameters: see inline descriptors in GnosisAudioService.cs (SoundTrack enum string names for track).
Usage example — PlaySound
private int? PlayUiClick()
{
if (Context?.Store == null || Context.CallService == null)
return null;
var args = GnosisNode.CreateObject(Context.Store);
args.Set("clipId", "ui_click");
args.Set("track", "UI");
args.Set("loop", false);
var result = CallService("Audio", "PlaySound", args);
if (!result.Success || !result.Data.IsValid)
return null;
var h = result.Data["handle"];
return h.IsValid ? (int)(float)h : null;
}Statistics
None.