godot/doc/classes/AudioStreamSample.xml

72 lines
4.3 KiB
XML
Raw Normal View History

<?xml version="1.0" encoding="UTF-8" ?>
2022-08-05 16:51:38 +00:00
<class name="AudioStreamSample" inherits="AudioStream" version="3.6" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
<brief_description>
Stores audio data loaded from WAV files.
</brief_description>
<description>
AudioStreamSample stores sound samples loaded from WAV files. To play the stored sound, use an [AudioStreamPlayer] (for non-positional audio) or [AudioStreamPlayer2D]/[AudioStreamPlayer3D] (for positional audio). The sound can be looped.
This class can also be used to store dynamically-generated PCM audio data. See also [AudioStreamGenerator] for procedural audio generation.
</description>
<tutorials>
</tutorials>
<methods>
2018-08-20 22:35:30 +00:00
<method name="save_to_wav">
<return type="int" enum="Error" />
<argument index="0" name="path" type="String" />
2018-08-20 22:35:30 +00:00
<description>
Saves the AudioStreamSample as a WAV file to [code]path[/code]. Samples with IMA ADPCM format can't be saved.
[b]Note:[/b] A [code].wav[/code] extension is automatically appended to [code]path[/code] if it is missing.
2018-08-20 22:35:30 +00:00
</description>
</method>
</methods>
<members>
<member name="data" type="PoolByteArray" setter="set_data" getter="get_data" default="PoolByteArray( )">
Contains the audio data in bytes.
[b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
</member>
<member name="format" type="int" setter="set_format" getter="get_format" enum="AudioStreamSample.Format" default="0">
Audio format. See [enum Format] constants for values.
</member>
<member name="loop_begin" type="int" setter="set_loop_begin" getter="get_loop_begin" default="0">
The loop start point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.
</member>
<member name="loop_end" type="int" setter="set_loop_end" getter="get_loop_end" default="0">
The loop end point (in number of samples, relative to the beginning of the sample). This information will be imported automatically from the WAV file if present.
</member>
<member name="loop_mode" type="int" setter="set_loop_mode" getter="get_loop_mode" enum="AudioStreamSample.LoopMode" default="0">
The loop mode. This information will be imported automatically from the WAV file if present. See [enum LoopMode] constants for values.
</member>
<member name="mix_rate" type="int" setter="set_mix_rate" getter="get_mix_rate" default="44100">
The sample rate for mixing this audio. Higher values require more storage space, but result in better quality.
In games, common sample rates in use are [code]11025[/code], [code]16000[/code], [code]22050[/code], [code]32000[/code], [code]44100[/code], and [code]48000[/code].
According to the [url=https://en.wikipedia.org/wiki/Nyquist%E2%80%93Shannon_sampling_theorem]Nyquist-Shannon sampling theorem[/url], there is no quality difference to human hearing when going past 40,000 Hz (since most humans can only hear up to ~20,000 Hz, often less). If you are using lower-pitched sounds such as voices, lower sample rates such as [code]32000[/code] or [code]22050[/code] may be usable with no loss in quality.
</member>
<member name="stereo" type="bool" setter="set_stereo" getter="is_stereo" default="false">
If [code]true[/code], audio is stereo.
</member>
</members>
<constants>
2017-11-24 22:16:30 +00:00
<constant name="FORMAT_8_BITS" value="0" enum="Format">
8-bit audio codec.
</constant>
2017-11-24 22:16:30 +00:00
<constant name="FORMAT_16_BITS" value="1" enum="Format">
16-bit audio codec.
</constant>
2017-11-24 22:16:30 +00:00
<constant name="FORMAT_IMA_ADPCM" value="2" enum="Format">
Audio is compressed using IMA ADPCM.
</constant>
2017-11-24 22:16:30 +00:00
<constant name="LOOP_DISABLED" value="0" enum="LoopMode">
2017-09-16 21:12:52 +00:00
Audio does not loop.
</constant>
2017-11-24 22:16:30 +00:00
<constant name="LOOP_FORWARD" value="1" enum="LoopMode">
Audio loops the data between [member loop_begin] and [member loop_end], playing forward only.
</constant>
2017-11-24 22:16:30 +00:00
<constant name="LOOP_PING_PONG" value="2" enum="LoopMode">
Audio loops the data between [member loop_begin] and [member loop_end], playing back and forth.
</constant>
<constant name="LOOP_BACKWARD" value="3" enum="LoopMode">
Audio loops the data between [member loop_begin] and [member loop_end], playing backward only.
</constant>
</constants>
</class>