AudioShader
Provides functionality for audio manipulation and playback, including volume and pitch adjustments, spatial considerations, and muting capabilities.
Properties
Indicates whether the audio is currently muted.
-- Check if the audio is muted
local isMuted = audioShaderInstance.isMuted
print(tostring(isMuted) -- true or false
Defines the range in which the audio can be heard.
-- Set the spatial range of the audio
audioShaderInstance.spatialRange = 10
Controls the playback volume of the audio.
-- Set the volume of the audio
audioShaderInstance.volume = 0.5
Sets a range for random volume variation.
-- Set the random volume range of the audio
audioShaderInstance.randomVolume = 0.1
Adjusts the pitch of the audio playback.
-- Set the pitch of the audio
audioShaderInstance.pitch = 1.2
Sets a range for random pitch variation.
-- Set the random pitch range of the audio
audioShaderInstance.randomPitch = 0.2
Methods
Begins playback of the audio with optional volume and pitch parameters.
-- Play the audio with custom volume and pitch
audioShaderInstance:Play(0.8, 1.1)
Parameters
volume
The volume at which to play the audio. Overrides the instance's volume property for this playback.
pitch
The pitch at which to play the audio. Overrides the instance's pitch property for this playback.
Returns
This method does not return a value.
Returns a randomly selected AudioClip from the available set.
-- Get a random AudioClip
local randomClip = audioShaderInstance:GetRandomClip()
Returns
The randomly selected AudioClip object.
Creates a new instance of AudioShader with a specified AudioClip.
-- Create a new AudioShader instance with the specified AudioClip
local audioShaderInstance = AudioShader.Create(clip)
Parameters
clip
AudioClipThe AudioClip to associate with the new AudioShader instance.
Returns
A new instance of AudioShader configured with the provided AudioClip.