SmoothAudioLoop

Author: Jessy

Description
NOTE: This will not work on the iPhone, using compressed audio.

This is a script that allows for audio to be looped before a playback iteration reaches its conclusion. The main purpose of this is to make it possible to preserve the sound that exists in an audio file after an effective musical phrase has ended. For example, you will never hear the natural decay of a crash cymbal in a standard drum loop, because that would leave a gaping hole before the beat started back up again. Properly set up with the correct duration of your music, this script will permit seamless looping of audio, while preserving sonic tails, potentially resulting in much more natural-sounding loops.

You will likely either need to be a musician, or work closely with one, to really take advantage of this script. Despite its simplicity, it adds important functionality that can not be achieved with the standard "Loop" checkbox provided by Unity on all Audio Sources. Both JavaScript and C# versions are available below.