Skip to Content

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)

KeyPurpose
Per-track volume/on/mutedVolumePersisted via SaveTrackState (key naming in source)
soundPoolSize, soundPoolCanExpand, soundMixerValuesMultiplierAdapter/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.json
{ "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 idRole
REQUEST_SOUND_PLAYPlay / one-shot sound
REQUEST_SOUND_CONTROLStop / pause / resume / free a handle
REQUEST_SOUND_FADEFade a sound
REQUEST_SOUND_SOLOSolo on a track
REQUEST_SOUND_TRACK_CONTROLTrack-level control
REQUEST_SOUND_ALL_CONTROLGlobal all-sounds control

Functions (summary)

AreaFunctions
SnapshotGetSettings, UpdateSettings
PlaybackPlaySound (clipId, track, options), StopSound, PauseSound, ResumeSound, FreeSound
GlobalStopAllSounds, PauseAllSounds, ResumeAllSounds, FreeAllSounds
TracksSetTrackVolume, MuteTrack, UnmuteTrack, FadeTrack
Per-soundFadeSound, SoloSoundOnTrack, UnsoloAllTracks

Parameters: see inline descriptors in GnosisAudioService.cs (SoundTrack enum string names for track).

Usage example — PlaySound

AudioService.Example1.cs
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.

Last updated on