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

Audio Clip

Audio Clips are used by Audio Sources to represent the audio asset imported into Unity. Unity supports both Mono and Stereo audio assets.


The Audio Clip Inspector

Audio Clips just work. The only thing you should have to do with them is reference them from within Audio Sources.

Properties

Sound assets only have read-only properties. Some of these properties can be changed in the Import Settings

FormatThe format the sound is stored in. Unity supports 4 raw formats and one compressed:
Mono 8 bit8 bit uncompressed mono PCM audio
Mono 16 bit16 bit uncompressed mono PCM audio
Stereo 8 bit8 bit uncompressed stereo PCM audio
Stereo 16 bit16 bit uncompressed stereo PCM audio
Ogg VorbisOgg Vorbis encoded stereo or mono audio
LengthThe duration of the sound file in seconds.
FrequencyThe sampling frequency of the file.

Importing Audio Assets

Unity features support for two types of audio: Uncompressed Audio or Ogg Vorbis. Any type of audio file you import into your project will be converted to one of these formats.

File Type Conversion

.AIFFConverted to uncompressed audio on import, best for short sound effects.
.WAVConverted to uncompressed audio on import, best for short sound effects.
.MP3Converted to Ogg Vorbis on import, best for longer music tracks.
.OGGCompressed audio format, best for longer music tracks.

Import Settings

If you are importing a file that is not already compressed as Ogg Vorbis, you have a number of options in the Import Settings of the Audio Clip in the Inspector. Here, you can compress the Clip into Ogg Vorbis format, force it into Mono or Stereo playback, and tweak other options. There are positives and negatives for both Ogg Vorbis and uncompressed audio. Each has its own ideal usage scenarios, and you generally should not use either one exclusively.


The Audio Clip Import Settings
Audio FormatOnly available if the file was initially saved in an uncompressed format.
UncompressedBest for short sound effects. For more info, jump to the using uncompressed audio section.
Ogg VorbisBest for longer audio files like music. For more info, jump to the using Ogg Vorbis section.
ChannelsYou can force the sound to play back in Mono or Stereo. This is important for using Positional Audio.
BitrateSet the bitrate to optimize file size of compressed Ogg Vorbis Clip``
Decompress on loadIf enabled, this Clip will be decompressed into memory when the containing level is loaded. This is important for optimizing player experience.

Using Positional Audio

Positional audio is the placement and volume of sounds across the computer speakers. It simulates distance and location of sounds by fading volume and panning across speakers. Unity supports Positional audio, but only mono Audio Clips are played positionally. Stereo sounds are always at the volume and panning determined by the asset file. For this reason, mono Clips are best for sound effects, and stereo Clips are best for music.

There are special cases, like if you wanted music playing from two unique in-game speaker environment objects. The closer you move your character to one of the speakers, the louder the music will get. This setup would require the speaker music in mono format.

If you have an Audio Clip that is in stereo, but you want to use it positionally, change the Channels property to Force Mono in the Import Settings. This allows you to be very creative with how you use audio in your game.

When to use Uncompressed Audio

If you are creating a web player game, do not use uncompressed audio. Only use Ogg Vorbis.

Uncompressed has the benefit of being quick to play without increasing CPU taxation. This is because it does not need to be decompressed before it can be played. However, uncompressed audio is quite large so it will increase the size of your player. Usually short Clips like sound effects are good for uncompressed audio, unless you are publishing a web player. If you are publishing a web player, you don't want to increase the file size any more than is absolutely necessary so you basically won't use uncompressed audio, unless you have a few crucial sounds that are shorter than 0.5 seconds. Clips that Uncompressed audio should usually be either 22khz or 11khz. Ideally you should not use 44khz since that takes up too much disk space and the quality difference is not very audible.

When to use Ogg Vorbis

If you are creating a web player game, always use Ogg Vorbis.

Ogg Vorbis files have the benefit of being compressed, which minimizes the amount of disk space they consume. This means that you can include long audio files without making a huge increase in the file size of your player. However, before they can be played back they must be decompressed. This takes time and processor cycles. Frequency of Ogg Vorbis files should be 44khz, because playback will be faster than files with a 22khz frequency.

Loading Ogg Vorbis files

If you're using Ogg Vorbis, you have an option to choose when the Clip will be decompressed. The option is set in the Import Settings:

DecompressOnLoad enabledDecompress and load the Clip into RAM when the player is loading.
DecompressOnLoad disabled (Live decompression)Decompress and play the Clip real-time when the Clip is triggered to start.

Decompressing on load is the most common. It means that the levels containing the Clip will take longer to load initially, and it will use up more of the end-user's RAM. Live decompression does not load the Clip data into RAM at level load. Instead, it requires the CPU to decompress the sound real-time. This means it is more CPU intensive rather than RAM intensive.

To summarize, enable decompression on load as much as possible, and definitely for all short Clips. Pick live decompression for longer Clips like music tracks. All Ogg Vorbis Clips using live decompression will increase CPU usage. It can use a substantial amount of CPU to live decompress multiple Clips at once, so you should avoid playing more than 2 live decompression Clips at once.

Hints