Difference between revisions of "SoundData:getSample"

m (Added info about stereo interleaving.)
(Updated for 0.11.0)
Line 7: Line 7:
 
=== Arguments ===
 
=== Arguments ===
 
{{param|number|i|An integer value specifying the position of the sample (starting at 0).}}
 
{{param|number|i|An integer value specifying the position of the sample (starting at 0).}}
 +
=== Returns ===
 +
{{param|number|sample|The normalized samplepoint (range -1.0 to 1.0).}}
  
 +
== Function ==
 +
{{newin|[[0.11.0]]|110|type=variant}}
 +
Gets the value of a sample using an explicit sample index instead of interleaving them in the sample position parameter.
 +
=== Synopsis ===
 +
<source lang="lua">
 +
sample = SoundData:getSample( i, channel )
 +
</source>
 +
=== Arguments ===
 +
{{param|number|i|An integer value specifying the position of the sample (starting at 0).}}
 +
{{param|number|channel|The index of the channel to set within the given sample.}}
 
=== Returns ===
 
=== Returns ===
 
{{param|number|sample|The normalized samplepoint (range -1.0 to 1.0).}}
 
{{param|number|sample|The normalized samplepoint (range -1.0 to 1.0).}}
 +
 +
 
== See Also ==
 
== See Also ==
 
* [[parent::SoundData]]
 
* [[parent::SoundData]]
 +
* [[SoundData:setSample]]
 
* [[SoundData:getSampleCount]]
 
* [[SoundData:getSampleCount]]
 
[[Category:Functions]]
 
[[Category:Functions]]

Revision as of 03:27, 25 March 2018

Gets the value of the sample-point at the specified position. For stereo SoundData objects, the data from the left and right channels are interleaved in that order.

Function

Synopsis

sample = SoundData:getSample( i )

Arguments

number i
An integer value specifying the position of the sample (starting at 0).

Returns

number sample
The normalized samplepoint (range -1.0 to 1.0).

Function

Available since LÖVE 0.11.0
This variant is not supported in earlier versions.

Gets the value of a sample using an explicit sample index instead of interleaving them in the sample position parameter.

Synopsis

sample = SoundData:getSample( i, channel )

Arguments

number i
An integer value specifying the position of the sample (starting at 0).
number channel
The index of the channel to set within the given sample.

Returns

number sample
The normalized samplepoint (range -1.0 to 1.0).


See Also


Other Languages