2017-09-12 22:42:36 +02:00
<?xml version="1.0" encoding="UTF-8" ?>
2023-07-06 10:08:05 +02:00
<class name= "AudioStreamWAV" inherits= "AudioStream" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation= "../class.xsd" >
2017-09-12 22:42:36 +02:00
<brief_description >
2019-06-22 01:04:47 +02:00
Stores audio data loaded from WAV files.
2017-09-12 22:42:36 +02:00
</brief_description>
<description >
2022-07-23 16:34:36 +02:00
AudioStreamWAV 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.
2021-05-13 02:30:34 +02:00
This class can also be used to store dynamically-generated PCM audio data. See also [AudioStreamGenerator] for procedural audio generation.
2017-09-12 22:42:36 +02:00
</description>
<tutorials >
2023-11-13 14:37:27 +01:00
<link title= "Runtime file loading and saving" > $DOCS_URL/tutorials/io/runtime_file_loading_and_saving.html</link>
2017-09-12 22:42:36 +02:00
</tutorials>
<methods >
2018-08-21 00:35:30 +02:00
<method name= "save_to_wav" >
2021-07-30 15:28:05 +02:00
<return type= "int" enum= "Error" />
2022-08-06 20:11:48 +02:00
<param index= "0" name= "path" type= "String" />
2018-08-21 00:35:30 +02:00
<description >
2022-08-12 19:51:01 +02:00
Saves the AudioStreamWAV as a WAV file to [param path]. Samples with IMA ADPCM format can't be saved.
[b]Note:[/b] A [code].wav[/code] extension is automatically appended to [param path] if it is missing.
2018-08-21 00:35:30 +02:00
</description>
</method>
2017-09-12 22:42:36 +02:00
</methods>
<members >
2019-09-24 19:45:03 +02:00
<member name= "data" type= "PackedByteArray" setter= "set_data" getter= "get_data" default= "PackedByteArray()" >
2018-04-25 21:04:03 +02:00
Contains the audio data in bytes.
2019-08-31 20:14:58 +02:00
[b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
2018-04-25 21:04:03 +02:00
</member>
2022-07-23 16:34:36 +02:00
<member name= "format" type= "int" setter= "set_format" getter= "get_format" enum= "AudioStreamWAV.Format" default= "0" >
2019-12-06 23:09:20 +01:00
Audio format. See [enum Format] constants for values.
2017-09-12 22:42:36 +02:00
</member>
2019-06-29 12:38:01 +02:00
<member name= "loop_begin" type= "int" setter= "set_loop_begin" getter= "get_loop_begin" default= "0" >
2020-04-15 23:38:12 +02:00
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.
2017-09-12 22:42:36 +02:00
</member>
2019-06-29 12:38:01 +02:00
<member name= "loop_end" type= "int" setter= "set_loop_end" getter= "get_loop_end" default= "0" >
2020-04-15 23:38:12 +02:00
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.
2017-09-12 22:42:36 +02:00
</member>
2022-07-23 16:34:36 +02:00
<member name= "loop_mode" type= "int" setter= "set_loop_mode" getter= "get_loop_mode" enum= "AudioStreamWAV.LoopMode" default= "0" >
2020-04-15 23:38:12 +02:00
The loop mode. This information will be imported automatically from the WAV file if present. See [enum LoopMode] constants for values.
2017-09-12 22:42:36 +02:00
</member>
2019-06-29 12:38:01 +02:00
<member name= "mix_rate" type= "int" setter= "set_mix_rate" getter= "get_mix_rate" default= "44100" >
2021-05-13 02:30:34 +02:00
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.
2017-09-12 22:42:36 +02:00
</member>
2019-06-29 12:38:01 +02:00
<member name= "stereo" type= "bool" setter= "set_stereo" getter= "is_stereo" default= "false" >
2019-06-29 15:24:23 +02:00
If [code]true[/code], audio is stereo.
2017-09-12 22:42:36 +02:00
</member>
</members>
<constants >
2017-11-24 23:16:30 +01:00
<constant name= "FORMAT_8_BITS" value= "0" enum= "Format" >
2019-06-22 01:04:47 +02:00
8-bit audio codec.
2017-09-16 01:46:14 +02:00
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "FORMAT_16_BITS" value= "1" enum= "Format" >
2019-06-22 01:04:47 +02:00
16-bit audio codec.
2017-09-16 01:46:14 +02:00
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "FORMAT_IMA_ADPCM" value= "2" enum= "Format" >
2019-06-22 01:04:47 +02:00
Audio is compressed using IMA ADPCM.
2017-09-16 01:46:14 +02:00
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "LOOP_DISABLED" value= "0" enum= "LoopMode" >
2017-09-16 23:12:52 +02:00
Audio does not loop.
2017-09-16 01:46:14 +02:00
</constant>
2017-11-24 23:16:30 +01:00
<constant name= "LOOP_FORWARD" value= "1" enum= "LoopMode" >
2020-04-15 23:38:12 +02:00
Audio loops the data between [member loop_begin] and [member loop_end], playing forward only.
2017-09-16 01:46:14 +02:00
</constant>
2021-10-15 15:25:00 +02:00
<constant name= "LOOP_PINGPONG" value= "2" enum= "LoopMode" >
2020-04-15 23:38:12 +02:00
Audio loops the data between [member loop_begin] and [member loop_end], playing back and forth.
2017-09-16 01:46:14 +02:00
</constant>
2018-10-28 19:37:14 +01:00
<constant name= "LOOP_BACKWARD" value= "3" enum= "LoopMode" >
2020-04-15 23:38:12 +02:00
Audio loops the data between [member loop_begin] and [member loop_end], playing backward only.
2018-10-28 19:37:14 +01:00
</constant>
2017-09-12 22:42:36 +02:00
</constants>
</class>