AudioObject Class

ClockStone Audio Toolkit

AudioObject Class

The object playing the audio clip associated with a AudioSubItem
Inheritance Hierarchy
SystemObject  Object
    Component
      Behaviour
        MonoBehaviour
          (Default Namespace)RegisteredComponent
            (Default Namespace)AudioObject

Namespace:  (Default Namespace)
Assembly:  AudioToolkit (in AudioToolkit.dll) Version: 8.2.0.0 (8.2.0.0)
Syntax
C#
public class AudioObject : RegisteredComponent

The AudioObject type exposes the following members.

Constructors
  NameDescription
Public methodAudioObject
Initializes a new instance of the AudioObject class
Top
Properties
  NameDescription
Public propertyaudioID
Gets the audio ID.
Public propertyaudioItem
Gets the corresponding AudioSubItem
Public propertyaudioObjectTime
Returns the high precision local time of this audio object
Public propertyaudioTime
Sets or gets the current audio time relative to ClipStartTime
Public propertycategory
Gets the category.
Public propertyclipLength
Gets the length of the clip.
Public propertycompletelyPlayedDelegate
Gets or sets the delegate to be called once an audio clip was completely played.
Public propertyisFadeOutComplete
return true if the audio has completely faded out
Public propertyisFadingIn
return true if the audio is currently fading in
Public propertyisFadingOut
return true if the audio is currently fading out
Public propertyisFadingOutOrScheduled
return true if the audio is currently fading out or is scheduled to fade out
Public propertyisPlayedAsMusicOrAmbienceSound
Returns true if the audio object is treated as music
Public propertypan
Sets or gets the audio pan.
Public propertypitch
Sets or gets the audio pitch.
Public propertyplayCalledAtTime
Gets the systemTime at which the audio Play() function was called.
Public propertyprimaryAudioSource
returns the primary AudioSource
Public propertyscheduledPlayingAtDspTime
Gets or sets the DSP time at which the audio is scheduled to play.
Public propertysecondaryAudioSource
returns the secondary AudioSource
Public propertystartedPlayingAtTime
Gets the systemTime at which the audio started playing.
Public propertystopAfterFadeOut
If enabled, the audio will stop playing if a fadeout is finished.
Public propertysubItem
Gets the corresponding AudioSubItem
Public propertytimeUntilEnd
Gets the time until the clip will stop.
Public propertyvolume
Gets or sets the volume.
Public propertyvolumeItem
Gets or sets the volume of the audio item.
Public propertyvolumeTotal
Gets the total volume.
Public propertyvolumeTotalWithoutFade
Gets the total volume.
Top
Methods
  NameDescription
Public methodDestroyAudioObject
Destroys the audio object (using ObjectPoolController if pooling is enabled)
Public methodDoesBelongToCategory
Checks if this AudioObject belongs to a specific category
Public methodFadeIn
Fades-in a playing audio.
Public methodFadeOut(Single)
Starts a fade-out. If the AudioItem mode is is a sequence, the next sub-item will continue to play after the this sub-item is completely faded out.
Public methodFadeOut(Single, Single)
Starts a fade-out at a specified time. If the AudioItem mode is is a sequence, the next sub-item will continue to play after the this sub-item is completely faded out.
Public methodFinishSequence
Finishes a playing sequence, depending on the AudioItem's loop mode :
  • LoopSequence: The sequence will stop after the current item has finished playing
  • PlaySequenceAndLoopLast: The sequence will stop after the current item has finished playing. If the sequence is during the looping part the looping will stop after the current loop reached its end.
  • IntroLoopOutroSequence: The sequence will stop after the current item has finished playing. If the sequence is during the looping part the outro will be played and the sequence will stop afterwards.
Public methodStatic memberInverseTransformPitch
Inverse pitch transformation: TransformPitch(Single)
Public methodStatic memberInverseTransformVolume
Inverse volume transformation TransformVolume(Single)
Public methodIsPaused
Determines whether the audio clip is paused.
Public methodIsPlaying
Determines if either the primary or the secondary audio clip is playing.
Public methodIsPrimaryPlaying
Determines if the primary audio clip is playing.
Public methodIsSecondaryPlaying
Determines if the secondary audio clip is playing.
Public methodPause
Pauses the audio clip.
Public methodPause(Single)
Pauses the audio clip with a fade-out.
Public methodPlay
Plays the audio clip with the specified delay.
Public methodPlayAfter
Plays the specified audio after the current has finished playing
Public methodPlayNow
Plays the specified audio.
Public methodPlayScheduled
Plays the audio clip at the specified high precision DSP time (see the Unity AudioSettings.dspTime documentation)
Public methodStop
Stops playing this instance.
Public methodStop(Single)
Stops a playing audio with fade-out.
Public methodStop(Single, Single)
Stops a playing audio with fade-out at a specified time.
Public methodCode exampleSwitchAudioSources
Switches the primary and secondary audio source
Public methodStatic memberTransformPitch
Transforms the pitch from semitones to a multiplicative factor
Public methodStatic memberTransformVolume
Transforms the volume to make it perceptually more intuitive to scale and cross-fade.
Public methodUnpause
Unpauses the audio clip.
Public methodUnpause(Single)
Unpauses the audio clip with a fade-in.
Top
Remarks
If audio object pooling is enabled make sure you store references to an AudioObject by using PoolableReferenceT
Examples
var soundFX = new PoolableReference<AudioObject>( AudioController.Play( "someSFX" ) );

// some other part of the code executed later when the sound may have stopped playing 
// and was moved back to the pool
AudioObject audioObject = soundFX.Get();
if( audioObject != null )
{
    // it is safe to access audioObject here
    audioObject.Stop();
}
See Also