Unity Workflow LibraryUWLAbout

Topic 11 · Audio

Music and adaptive audio

Stitch music sample-accurately on the DSP clock and drive mood changes from snapshots or middleware parameters.

Schedule on the audio clock

  • AudioSettings.dspTime is the audio system's time in seconds, based on samples processed, and much more precise than Time.time. It does not advance while the game is paused, so scheduled music needs no rescheduling after an unpause (dspTime).
  • AudioSource.PlayScheduled(time) starts a clip at an absolute dspTime. The reference calls it the preferred way to stitch clips in music players, independent of frame rate. Schedule about 100 to 200 ms ahead; a time already in the past plays as soon as possible and the missed audio is not reproduced (PlayScheduled).
  • The reference's pattern alternates two AudioSources, so loading the next segment does not disturb the playing one, and schedules each segment about a second before it is due.

Adaptive music

  • Built-in: put layers or stems on separate mixer groups and move between mixer snapshots for intensity states. Tempo, segment length and the snapshot per state are authored data, not constants.
  • FMOD: the music is an event whose behaviour (loop regions, transitions) is authored in FMOD Studio, and the game only sets parameters; the FMOD tutorial builds a looping music event and routes it to its own Music bus for mixing.
  • The game code sends state (intensity, area, combat on or off). Which music answers that state is decided in the authored asset or the middleware project, where a composer can change it without code.