Skip to content

API > AudioClip


AudioClip⚓︎

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⚓︎

Name Description
AudioClip.ambisonicProperty Returns true if this audio clip is ambisonic (read-only).
AudioClip.channelsProperty The number of channels in the audio clip. (Read Only)
AudioClip.frequencyProperty The sample frequency of the clip in Hertz. (Read Only)
AudioClip.lengthProperty The length of the audio clip in seconds. (Read Only)
AudioClip.loadInBackgroundProperty Corresponding 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.loadStateProperty Returns the current load state of the audio data associated with an AudioClip.
AudioClip.loadTypeProperty The load type of the clip (read-only).
AudioClip.preloadAudioDataProperty Preloads 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.samplesProperty The length of the audio clip in samples. (Read Only)

Methods⚓︎

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

Static Methods⚓︎

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

Inherited Members⚓︎

Inherited Properties⚓︎

Name Description
AudioClip.hideFlagsProperty Should the object be hidden, saved with the Scene or modifiable by the user?
AudioClip.nameProperty The name of the object.

Inherited Methods⚓︎

Name Description
AudioClip.GetInstanceID()Method Returns the instance id of the object.