AudioStreamWAV.xml 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="AudioStreamWAV" inherits="AudioStream" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Stores audio data loaded from WAV files.
  5. </brief_description>
  6. <description>
  7. 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.
  8. This class can also be used to store dynamically-generated PCM audio data. See also [AudioStreamGenerator] for procedural audio generation.
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="save_to_wav">
  14. <return type="int" enum="Error" />
  15. <param index="0" name="path" type="String" />
  16. <description>
  17. Saves the AudioStreamWAV as a WAV file to [param path]. Samples with IMA ADPCM format can't be saved.
  18. [b]Note:[/b] A [code].wav[/code] extension is automatically appended to [param path] if it is missing.
  19. </description>
  20. </method>
  21. </methods>
  22. <members>
  23. <member name="data" type="PackedByteArray" setter="set_data" getter="get_data" default="PackedByteArray()">
  24. Contains the audio data in bytes.
  25. [b]Note:[/b] This property expects signed PCM8 data. To convert unsigned PCM8 to signed PCM8, subtract 128 from each byte.
  26. </member>
  27. <member name="format" type="int" setter="set_format" getter="get_format" enum="AudioStreamWAV.Format" default="0">
  28. Audio format. See [enum Format] constants for values.
  29. </member>
  30. <member name="loop_begin" type="int" setter="set_loop_begin" getter="get_loop_begin" default="0">
  31. 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.
  32. </member>
  33. <member name="loop_end" type="int" setter="set_loop_end" getter="get_loop_end" default="0">
  34. 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.
  35. </member>
  36. <member name="loop_mode" type="int" setter="set_loop_mode" getter="get_loop_mode" enum="AudioStreamWAV.LoopMode" default="0">
  37. The loop mode. This information will be imported automatically from the WAV file if present. See [enum LoopMode] constants for values.
  38. </member>
  39. <member name="mix_rate" type="int" setter="set_mix_rate" getter="get_mix_rate" default="44100">
  40. The sample rate for mixing this audio. Higher values require more storage space, but result in better quality.
  41. 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].
  42. 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.
  43. </member>
  44. <member name="stereo" type="bool" setter="set_stereo" getter="is_stereo" default="false">
  45. If [code]true[/code], audio is stereo.
  46. </member>
  47. </members>
  48. <constants>
  49. <constant name="FORMAT_8_BITS" value="0" enum="Format">
  50. 8-bit audio codec.
  51. </constant>
  52. <constant name="FORMAT_16_BITS" value="1" enum="Format">
  53. 16-bit audio codec.
  54. </constant>
  55. <constant name="FORMAT_IMA_ADPCM" value="2" enum="Format">
  56. Audio is compressed using IMA ADPCM.
  57. </constant>
  58. <constant name="LOOP_DISABLED" value="0" enum="LoopMode">
  59. Audio does not loop.
  60. </constant>
  61. <constant name="LOOP_FORWARD" value="1" enum="LoopMode">
  62. Audio loops the data between [member loop_begin] and [member loop_end], playing forward only.
  63. </constant>
  64. <constant name="LOOP_PINGPONG" value="2" enum="LoopMode">
  65. Audio loops the data between [member loop_begin] and [member loop_end], playing back and forth.
  66. </constant>
  67. <constant name="LOOP_BACKWARD" value="3" enum="LoopMode">
  68. Audio loops the data between [member loop_begin] and [member loop_end], playing backward only.
  69. </constant>
  70. </constants>
  71. </class>