As with Meshes or Textures, the workflow for Audio File assets is designed to be smooth and simple. Unity can import almost every common file format, but there are a few details that are useful to be aware of when you work with audio files.
For a list of the audio formats Unity supports, refer to Supported audio file formats.
For an extensive description of the compressionA method of storing data that reduces the amount of storage space it requires. See Texture Compression, Animation Compression, Audio Compression, Build Compression.
See in Glossary formats and other options available for encoding audio data, refer to AudioClip.
Unity audio data is separate from the actual AudioClips. Audio data is the raw information about an audio file. It contains information such as length, channel count, sample rate, and compression format.
AudioClips are assets that contain the audio data and processes the audio data for use with Unity Engine.
To import an audio file to Unity, click and drag your file into your project. Unity imports the audio file as an AudioClip.
Use the settings in the AudioClip importer to determine how the clips will load at runtime. These settings let you decide which audio assets will stay in memory. This is ideal for frequent or unpredictable sounds like footsteps, weapons, or impacts.
For other assets, such as speech, background music, or ambient loops, you can set them to load on-demand or as the player progresses. This approach optimizes memory usage and improves performance.
When Unity encodes audio, the main compression formats for how Unity stores the audio on disk are the following: * PCM * ADPCM * Compressed.
Additionally there are a few platform-specific formats but they work in similar ways. The default mode is Compressed, where Unity compresses the audio data with either the Vorbis or MP3 format for standalone and mobile platforms.
Any audio file imported into Unity is available from scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary as an AudioClip instance. This provides a way for the game runtime of the audio system to access the encoded audio data. The game might access meta-information about the audio data via the AudioClip even before the actual audio data loads.
The import process extracts information such as length, channel count and sample rate from the encoded audio data and stores these details in the AudioClip. This information can be useful for automatic dialog or music sequencing systems, because the music engine can use the length to schedule music playback before the data loads. It also helps to reduce memory usage because it only keeps the audio clipsA container for audio data in Unity. Unity supports mono, stereo and multichannel audio assets (up to eight channels). Unity can import .aif, .wav, .mp3, and .ogg audio file format, and .xm, .mod, .it, and .s3m tracker module formats. More info
See in Glossary in memory the application needs at a certain time.
Unity supports the following audio file formats.
Format | Extensions |
---|---|
MPEG layer 3 | .mp3 |
Ogg Vorbis | .ogg |
Microsoft Wave | .wav |
Free Lossless Audio Codec (FLAC) | .flac |
Audio Interchange File Format | .aiff / .aif |
Ultimate Soundtracker module | .mod |
Impulse Tracker module | .it |
Scream Tracker module | .s3m |
FastTracker 2 module | .xm |
For more information about how to use sound in Unity, refer to Audio Overview.