Audio Clip
Manual     Reference     Scripting   
Reference Manual > Components > Asset Components > Audio Clip

Audio Clip

Audio Clips are audio data used by Audio Sources. Unity supports mono, stereo and multi (up to 8) channels audio assets. Unity supports importing the following audio file formats: .aif, .wav, .mp3, and .ogg, and the following tracker module file formats: .xm, .mod, .it, and .s3m. The tracker module assets works the same way as any other audio assets in Unity except no waveform preview can be rendered to the asset import inspector.


The Audio Clip Inspector

Properties

Audio FormatThe specific format that will be used for the sound at runtime.
NativeLarger file size, higher quality. Best for very short sound effects.
CompressedSmaller file size, lower/variable quality. Best for medium length sound effects and music.
3D SoundIf enabled, the sound will play back in 3D space. Both Mono and Stereo sounds can be played in 3D.
Force to monoIf enabled, the audio clip will be down-mixed to a single channel sound.
Load TypeThe way Unity load audio assets runtime.
Decompress on loadDecompress sounds upon load. Use this for smaller compressed sounds to avoid the performance overhead of decompressing on the fly. Beware that decompressing sounds on load will use ~10x more memory than keeping them compressed in memory, so don't use this for large files.
Compressed in memoryKeep sounds compressed in memory and decompress while playing. This have a slight performance overhead (esp. for Ogg/Vorbis compressed files) so only use this for bigger files.
Stream from discStream audio data directly from disc. This uses a fraction of the original sounds size of memory. Use this for your music or very long tracks. Depending on the hardware, a general advice is to keep this down to 1-2 simultaneously streams.
CompressionAmount of Compression to be applied to a Compressed clip. Statistics about file size can be seen beneath the slider. It is suggested to drag the slider to a place that leaves the playback "good enough" but still at a small enough size to meet your file size/distribution needs.
Hardware Decoding(iOS ONLY) Available for compressed audio on iOS devices. Uses Apple's hardware decoder for less CPU intensive decompression. Check out Platform Specific details for more info.
Gapless looping(Android/iOS ONLY) Use this when compressing a perfect looping audio source file (in a non-compressed PCM format) to preserve the loop. Standard MPEG encoders introduce silence around the loop point, which will play as little "click" or "pop". Unity handles this smoothly for you.

Importing Audio Assets

Unity supports both Compressed and Native Audio. Any type of file (except MP3/Ogg Vorbis) will be initially imported as Native. Compressed audio files must be decompressed by the CPU while the game is running, but are smaller in file size. If Stream is checked the audio is decompressed on the fly, or else the audio is decompressed entirely upon load. Native PCM formats (WAV, AIFF) have the benefit of being higher fidelity without increasing CPU taxation, but create much larger files. Module files (.mod,.it,.s3m..xm) can deliver very high quality with an extremely low footprint.

As a general rule of thumb, Compressed audio(or modules) are best for long files like background music or dialog, and uncompressed is better for short sound effects. Tweak the amount of Compression with the compression slider to just before the difference in sound quality is noticeable.

Using 3D Audio

If an audio clip is marked as a 3D Sound then it will be played back to simulate its position in the game world's 3D space. 3D sounds emulate distance and location of sounds by attenuating volume and panning across speakers. Both mono and multiple channel sounds can be positioned in 3D. For multiple channel audio, use the spread option on the Audio Source to spread and split out the discrete channels in speaker space. Unity offers a variety of options to control and fine-tune the audio behavior in 3D space. Take a look at Audio Source.

Platform specific details

iOS

On mobile platforms compressed audio is encoded as MP3 for less CPU intensive decompression.

For performance reasons audio clips can be played back using the Apple hardware codec. To enable this check the "Hardware Decoding" checkbox in the Audio Importer. Note that only one hardware audio stream can be decompressed at a time, including the background iPod audio.

If the hardware decoder is not available, the decompression will fall back on the software decoder (on iPhone 3GS or newer Apple's software decoder is used over Unity's(FMOD) own decoder).

Android

On mobile platforms compressed audio is encoded as MP3 for less CPU intensive decompression.

Page last updated: 2011-05-30