Manual     Reference     Scripting   
Unity Manual > User Guide > Creating Gameplay > Sound

This document is unofficially translated by users.Please see the original document here.

Please send e-mail to here, when you have any question about the translation.


Audio Listener

The Audio Listener acts as a microphone-like device. It receives input from any given Audio Source in the scene and plays sounds through the computer speakers. It is traditionally attached to the Main Camera.

The Audio Listener, attached to the Main Camera


The Audio Listener has no properties. It simply must be added to work. It is always added to the Main Camera by default.


The Audio Listener works in conjunction with Audio Sources, allowing you to create the aural experience for your games. When the Audio Listener is attached to a GameObject in your scene, any Sources that are close enough to the Listener will be picked up and output to the computer's speakers. Each scene can only have 1 Audio Listener to work properly.

As long as the Sources are in mono format, the Listener will automatically position the sound correctly in the stereo field, at the correct volume. Stereo Sources will automatically play in both speakers. For example, if your character walks off a street into a night club, the night club's music should probably be stereo, while the individual voices of characters in the club should be mono with their realistic positioning being handled by Unity.

You should attach the Audio Listener to either the Main Camera or to the GameObject that represents the player. Try both to find what suits your game best.


Audio Source

The Audio Source takes an Audio Clip and plays it from a position in the world.

The Audio Source in the Scene View and Inspector


Audio ClipReference to the sound clip file that will be played
Play On AwakeIf enabled, the sound will start playing the moment the scene launches. If disabled, you need to start it using the Play() command from scripting.
VolumeHow loud the sound is at a distance of 1 world unit (1 meter) from the Audio Listener.
PitchAmount of change in pitch due to slowdown/speed up of the Audio Clip. Value 1 is normal playback speed.
Min VolumeThe minimum value of the sound. No matter how far away you get, the sound will not get softer than this value.
Max VolumeHow loud the sound gets at the loudest. No matter how close you get, the sound will never get louder than this value.
Rolloff FactorHow fast the sound fades. The higher the value, the closer the Listener has to be before hearing the sound.
LoopEnable this to make the Audio Clip loop when it reaches the end.

Creating Audio Sources

Audio Sources don't do anything without an assigned Audio Clip. The Clip is the actual sound file that will be played back. The Source is like a controller for starting and stopping playback of that clip, and modifying other audio properties.

To create a new Audio Source:

  1. Import your audio files into your Unity Project. These are now Audio Clips.
  2. Go to GameObject->Create Empty from the menubar.
  3. With the new GameObject selected, select Component->Audio->Audio Source.
  4. Assign the Audio Clip property of the Audio Source Component in the Inspector.


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. Unity supports importing the following audio file formats: .aif, .wav, .mp3, and .ogg.

The Audio Clip Inspector


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. In Unity 2.6, both Mono and Stereo sounds can be played in 3D
Force to monoIf enabled, the stereo audio clip will be condensed to a single channel mono sound.
Decompress On LoadIf enabled, this clip will be loaded into memory as soon as the scene containing it is loaded. It is suggested that you leave this on, otherwise your game may have reduced performance as the sound is decompressed real-time at runtime.
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.

Importing Audio Assets

Unity supports both Compressed and Uncompressed Audio. Any type of file except .mp3 will be initially imported as Uncompressed. MP3 and Compressed audio files must be decompressed by the CPU while the game is running, but are smaller in file size. Native formats have the benefit of being higher fidelity without increasing CPU taxation, but create much larger files.

As a general rule of thumb, Compressed audio is best for long files like background music or dialog, and uncompressed is better for short sound effects that are under two seconds. However...

If you are creating a web player game, you should Compress as much of your audio as possible. This will help you attain the smallest file size for webplayer downloads. If you tweak the amount of Compression, the difference in sound quality won't be 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 simulate distance and location of sounds by fading volume and panning across speakers. Unity supports 3D audio, and any stereo or mono clip can be played back in 3D space. However, mono 3D sounds are the most common.

Loading Compressed Audio

Compressed audio files have an option to choose when the Clip will be decompressed. The option is set in the Import Settings:

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

Decompressing on load is the most commonly used option, and shouldn't really be disabled unless you have a special case. 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.