GetSoundPitch

Definition

double GetSoundPitch(string soundObjectName)

Description

This function returns the pitch of ambient or 3D sound soundObjectName.

Parameters

soundObjectName
Specifies the ambient or 3D sound name. You can also use the name “this” for this parameter. In this case, “this” string refers to the name of the sound to which this script is attached.

Return Value

pitch of 3D or ambient sound.

Example 1

pitch = 0.0

function Init()
    pitch = GetSoundPitch("sound1")

    message = string.format("\nSound pitch is > %.2f", pitch)
    PrintConsole(message)
end

function Update()

end
First, we get the pitch of sound “sound1”. Then we display it in the console using the PrintConsole function.

Example 2

--Name of script is GetSoundPitch2.lua

pitch = 0.0

function Init()
    pitch = GetSoundPitch("this")

    message = string.format("\nSound pitch is > %.2f", pitch)
    PrintConsole(message)
end

function Update()

end
Assume that the above script named GetSoundPitch2.lua is attached to a sound object named “sound1”. In this case, string “this”  in the GetSoundPitch function will be equal to “sound1”. In our example, the function GetSoundPitch returns the pitch of current sound, which is “sound1”.
adminGetSoundPitch