Unity Workflow LibraryUWLAbout

Topic 11 · Audio

Audio import settings and memory

Load type, compression format and per-platform overrides, then gains read from the imported clip.

What the import settings do

From the Audio Clip Import Settings reference:

Setting Documented behaviour
Decompress On Load Decompresses when loaded. Vorbis decompressed on load uses about ten times the memory of keeping it compressed (ADPCM about 3.5 times), so not for large files
Compressed In Memory Stays compressed and decompresses while playing, on the mixer thread (DSP CPU in the Profiler's Audio module)
Streaming Decodes from disk with a minimal buffer, on a streaming thread; each streaming clip has about 200 KB overhead even with no audio loaded
PCM Uncompressed; for short effects; lightest on CPU
ADPCM 3.5 times smaller than PCM, much lower CPU than MP3/Vorbis; for noisy, frequent sounds such as footsteps, impacts and weapons
Vorbis/MP3 Smaller files at lower quality; for medium-length effects and music; Quality slider sets compression
Force To Mono Down-mixes to one channel, then peak-normalizes the result
Preload Audio Data When off, playing the clip loads it on demand, which can delay larger files; call AudioClip.LoadAudioData first
Load In Background Loads asynchronously; play requests wait until the clip is loaded; query AudioClip.loadState
  • Overrides are per platform. Load Type, Compression Format, Sample Rate Setting and Quality are set per platform tab, so Android and desktop can differ.
  • Tuning quality. The reference's method: start high, lower Quality until the loss is audible, then raise it slightly until it is not.

AUDIO-IMPORT-PER-PLATFORM

  • World SFX: Force To Mono; Vorbis quality 0.7 or more on desktop (pack clips imported at quality 0.0 are audibly degraded); Android override Vorbis 0.5 at 22,050 Hz; Decompress On Load under about 1.5 s, Compressed In Memory above. UI clicks stay stereo, ADPCM on Android for clicks under 0.25 s.
  • Retire long clips nothing needs (a 6.8 s, 5 MB mp3 on a weapon row) rather than compressing them harder.

SET-GAIN-FROM-THE-IMPORTED-CLIP

  • Import settings change level: Force To Mono raised measured stereo loudness by up to about 4 dB (see FORCE-TO-MONO-GATES-NORMALIZE). Change imports first, then read loudness from the imported clip and set each row's gain against a per-topic target in dBFS. Frequent small sounds sit lowest (shots about -27, impacts -24), rare moments highest (-15 to -20). Row loudness went from an unplanned -19.8 to -5.8 spread to an authored -27 to -15.
  • A source clip sitting 5 dB or more under its target is swapped, not gained: gain cannot fix a quiet click without raising its noise.

AUDIO-IMPORT-COMPARES-FIELDS-NOT-EQUALS

  • AudioImporterSampleSettings.Equals never matched a freshly read copy, so an authoring step that "reimports only when the settings changed" reimported on every run. Each reimport unloads the clip, and the next sample read failed with "Cannot read clip".
  • Compare loadType, compressionFormat, quality and sampleRateSetting field by field, and write only on a real difference.
  • Before reading samples, call AudioClip.LoadAudioData in a separate step and wait until loadState is Loaded. The load is asynchronous, so a read in the same call can still find the clip empty.

GETDATA-NEEDS-A-DECOMPRESSED-CLIP

  • AudioClip.GetData fails on clips imported as CompressedInMemory or Streaming. Those are the load types this spoke recommends for clips longer than about 1.5 s, so a loudness census that reads every clip through GetData breaks on exactly the long clips.
  • For those clips, measure loudness from the source audio file (decode the WAV and take the loudest 100 ms RMS), then add the import's own level change: Force To Mono can raise a stereo clip up to ~4 dB (SET-GAIN-FROM-THE-IMPORTED-CLIP). Alternatively, measure a temporary DecompressOnLoad import and restore the original settings. Record in the census which method measured each clip.

  • The GetData reference confirms it: compressed clips return samples only with Load Type Decompress On Load, streamed clips never do, and a failed read fills zeroes, logs an error and returns false.