Difference between revisions of "Source:setPitch"

m (1 revision: Importing from potato (again).)
(Added a minor detail, since people might expect it to work differently.)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
 
Sets the pitch of the Source.
 
Sets the pitch of the Source.
 
== Function ==
 
== Function ==
Line 7: Line 6:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|float|pitch|Calculated with regard to 1 being the base pitch. Each reduction by 50 percent equals a pitch shift of -12 semitones (one octave reduction). Each doubling equals a pitch shift of 12 semitones (one octave increase). Zero is not a legal value.}}
+
{{param|number|pitch|Calculated with regard to 1 being the base pitch. Each reduction by 50 percent equals a pitch shift of -12 semitones (one octave reduction). Each doubling equals a pitch shift of 12 semitones (one octave increase). Zero is not a legal value.}}
 
=== Returns ===
 
=== Returns ===
 
Nothing.
 
Nothing.
 +
== Examples ==
 +
<source lang="lua">
 +
function love.load()
 +
    sound = love.audio.newSource("sound.wav")
 +
 +
    -- Note that this code, as-is, will set the pitch to 1.0, as per the last line, and that's how sound:play() will play it back.
 +
    sound:setPitch(0.5) -- One octave lower
 +
    sound:setPitch(2) -- One octave higher
 +
    sound:setPitch(1) -- Reset to normal pitch
 +
end
 +
</source>
 
== See Also ==
 
== See Also ==
 
* [[parent::Source]]
 
* [[parent::Source]]
 
[[Category:Functions]]
 
[[Category:Functions]]
 
{{#set:Description=Sets the pitch of the Source.}}
 
{{#set:Description=Sets the pitch of the Source.}}
 +
{{#set:Since=000}}
 +
== Other Languages ==
 +
{{i18n|Source:setPitch}}

Latest revision as of 16:43, 3 November 2016

Sets the pitch of the Source.

Function

Synopsis

Source:setPitch( pitch )

Arguments

number pitch
Calculated with regard to 1 being the base pitch. Each reduction by 50 percent equals a pitch shift of -12 semitones (one octave reduction). Each doubling equals a pitch shift of 12 semitones (one octave increase). Zero is not a legal value.

Returns

Nothing.

Examples

function love.load()
    sound = love.audio.newSource("sound.wav")

    -- Note that this code, as-is, will set the pitch to 1.0, as per the last line, and that's how sound:play() will play it back.
    sound:setPitch(0.5) -- One octave lower
    sound:setPitch(2) -- One octave higher
    sound:setPitch(1) -- Reset to normal pitch
end

See Also


Other Languages