docs
Systems
Presentation
AudioSystem
AudioSystem Overview

The AudioSystem is the Presentation-layer audio module in SaffronLibrary. It plays sound effects and music, manages layered music, applies volume settings to the Unity audio mixer, and resolves audio clips by key with localization support.

Within SaffronLibrary, the system lets other systems request audio without touching Unity audio objects. Callers build audio commands with AudioCommandFactory and send them over the command bus. An AudioFlowController owns the Audio domain and forwards commands and UI events to AudioManager, which carries out the work.

Key responsibilities:

  • Command handling: AudioManager receives audio commands and routes them to playback, pause, stop, volume, and layered music operations.
  • Playback and pooling: AudioSourcePool reuses pooled AudioSource objects for sound effects and music, and AudioPlaybackUtility applies clip settings and fades.
  • Clip resolution: AudioClipLookup and the AudioClipHolder family map clip keys to clip data, with language fallback for localized clips.
  • Volume and layered music: AudioMixerManager sets decibel levels on the mixer, and ILayeredMusicPlayer is the contract that layered music backends implement.

Who should use it:

  • Gameplay and UI developers who need to play sounds, music, or volume changes. They should use AudioCommandFactory rather than constructing commands by hand.
  • Project developers who subclass AudioManager and AudioFlowController, and implement IAudioTweener and ILayeredMusicPlayer, to supply language, volume presets, fading, and a music backend.
  • Audio content authors who build clip holder assets.

The system depends on the Contracts, Params, Bus, Flow, Initialization, and Application systems for command routing, typed parameters, and bootstrapping. See the architecture page for how these connect.