---
title: "Music and adaptive audio"
slug: /workflows/audio-music-adaptive/
markdown: /workflows/audio-music-adaptive.md
section: audio
tier: 2
summary: "Stitch music sample-accurately on the DSP clock and drive mood changes from snapshots or middleware parameters."
sources: ['https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSource.PlayScheduled.html', 'https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSettings-dspTime.html', 'https://docs.unity3d.com/6000.0/Documentation/Manual/AudioMixer.html', 'https://www.fmod.com/docs/2.03/unity/integration-tutorial.html']
canonical: https://unityworkflowlibrary.dev/workflows/audio-music-adaptive/
read_first: /read-first.md
---

> Read first, on every prompt: [non-destructive rules](/read-first.md).

# 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](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSettings-dspTime.html)).
- `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](https://docs.unity3d.com/6000.0/Documentation/ScriptReference/AudioSource.PlayScheduled.html)).
- 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](https://www.fmod.com/docs/2.03/unity/integration-tutorial.html) 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.

## Related

- [Audio topic](/topics/audio/): every audio page in reading order.
- Next: [Timing cues to picture and gameplay](/workflows/audio-timing/).
