GetPitch

This function gets the pitch of a source.

Syntax

Returns

Returns the source pitch.

Example

--Create a window
window = Window:Create()
context = Context:Create(window)

--Load a sound
local sound = Sound:Load("Sound/Music/menutheme.wav")

source = Source:Create()
source:SetSound(sound)
sound:Release()
source:SetLoopMode(true)
source:Play()

while true do
--Press up/down keys to alter pitch
local pitch = source:GetPitch()
if (window:KeyDown(Key.Up))then pitch=pitch+Time:GetSpeed()*0.01 end
if (window:KeyDown(Key.Down))then pitch=pitch-Time:GetSpeed()*0.01 end
source:SetPitch(pitch)

if window:Closed() or window:KeyHit(Key.Escape) then return false end

Time:Update()
context:SetColor(0,0,0)
context:Clear()

context:SetColor(1,1,1)
context:SetBlendMode(Blend.Alpha)
context:DrawText("Pitch: "..source:GetPitch(),2,2)

context:Sync()

end