Skip to main content

AudioClip

info

AudioClip inherits from Object

A container for audio data. An AudioClip stores the audio file either compressed as ogg vorbis or uncompressed. AudioClips are referenced and used by AudioSources to play sounds. Check out Unity Audio Clip

Members

Properties

NameDescription
AudioClip.ambisonicReturns true if this audio clip is ambisonic (read-only).
AudioClip.channelsThe number of channels in the audio clip. (Read Only)
AudioClip.frequencyThe sample frequency of the clip in Hertz. (Read Only)
AudioClip.lengthThe length of the audio clip in seconds. (Read Only)
AudioClip.loadInBackgroundCorresponding to the "Load In Background" flag in the inspector, when this flag is set, the loading will happen delayed without blocking the main thread.
AudioClip.loadStateReturns the current load state of the audio data associated with an AudioClip.
AudioClip.loadTypeThe load type of the clip (read-only).
AudioClip.preloadAudioDataPreloads audio data of the clip when the clip asset is loaded. When this flag is off, scripts have to call AudioClip.LoadAudioData() to load the data before the clip can be played. Properties like length, channels and format are available before the audio data has been loaded.
AudioClip.samplesThe length of the audio clip in samples. (Read Only)

Methods

NameDescription
AudioClip.GetData(offsetSamples)Gets an array with sample data from the clip.
AudioClip.LoadAudioData()Loads the audio data of a clip. Clips that have "Preload Audio Data" set will load the audio data automatically.
AudioClip.SetData(data[], offsetSamples)Set sample data in a clip.
AudioClip.UnloadAudioData()Unloads the audio data associated with the clip. This works only for AudioClips that are based on actual sound file assets.

Static Methods

NameDescription
AudioClip.Create(name, lengthSamples, channels, frequency)Creates a user AudioClip with a name and with the given length in samples, channels and frequency.

Inherited Members

Inherited Properties

NameDescription
AudioClip.hideFlagsShould the object be hidden, saved with the Scene or modifiable by the user?
AudioClip.nameThe name of the object.

Inherited Methods

NameDescription
AudioClip.GetInstanceID()Returns the instance id of the object.