Difference between revisions of "SoundData:getSample"

m (Have API docs describe what the API does, but also mention the relevant feature an user might expect it to do, regarding the API's behaviour.)
m (0.11.0 -> 11.0)
 
(4 intermediate revisions by 4 users not shown)
Line 1: Line 1:
Gets the sample at the specified position.
+
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.
 
+
Valid indices start at 0 and go up to buffer length minus one. Non-integer indices are floored, which means the function does not do value interpolation of any kind.
+
 
== Function ==
 
== Function ==
 
=== Synopsis ===
 
=== Synopsis ===
Line 8: Line 6:
 
</source>
 
</source>
 
=== Arguments ===
 
=== Arguments ===
{{param|number|i|The position of the sample (0 means first sample). Values are not interpolated, so use whole numbers only.}}
+
{{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|[[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 get within the given sample.}}
 
=== Returns ===
 
=== Returns ===
{{param|number|sample|The normalized sample (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]]
{{#set:Description=Gets the sample at the specified position.}}
+
{{#set:Description=Gets the value of the samplepoint at the specified position.}}
 
{{#set:Since=000}}
 
{{#set:Since=000}}
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|SoundData:getSample}}
 
{{i18n|SoundData:getSample}}

Latest revision as of 15:16, 22 December 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 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 get within the given sample.

Returns

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


See Also


Other Languages