class_audiostreamplayer.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. :github_url: hide
  2. .. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
  3. .. DO NOT EDIT THIS FILE, but the AudioStreamPlayer.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamPlayer:
  6. AudioStreamPlayer
  7. =================
  8. **Inherits:** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays back audio non-positionally.
  10. Description
  11. -----------
  12. Plays an audio stream non-positionally.
  13. To play audio positionally, use :ref:`AudioStreamPlayer2D<class_AudioStreamPlayer2D>` or :ref:`AudioStreamPlayer3D<class_AudioStreamPlayer3D>` instead of ``AudioStreamPlayer``.
  14. Tutorials
  15. ---------
  16. - :doc:`Audio streams <../tutorials/audio/audio_streams>`
  17. - `2D Dodge The Creeps Demo <https://godotengine.org/asset-library/asset/515>`__
  18. - `Audio Device Changer Demo <https://godotengine.org/asset-library/asset/525>`__
  19. - `Audio Generator Demo <https://godotengine.org/asset-library/asset/526>`__
  20. - `Audio Mic Record Demo <https://godotengine.org/asset-library/asset/527>`__
  21. - `Audio Spectrum Demo <https://godotengine.org/asset-library/asset/528>`__
  22. Properties
  23. ----------
  24. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  25. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer_property_autoplay>` | ``false`` |
  26. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  27. | :ref:`StringName<class_StringName>` | :ref:`bus<class_AudioStreamPlayer_property_bus>` | ``&"Master"`` |
  28. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  29. | :ref:`int<class_int>` | :ref:`max_polyphony<class_AudioStreamPlayer_property_max_polyphony>` | ``1`` |
  30. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  31. | :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` | :ref:`mix_target<class_AudioStreamPlayer_property_mix_target>` | ``0`` |
  32. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  33. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer_property_pitch_scale>` | ``1.0`` |
  34. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  35. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer_property_playing>` | ``false`` |
  36. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  37. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer_property_stream>` | |
  38. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  39. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer_property_stream_paused>` | ``false`` |
  40. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  41. | :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer_property_volume_db>` | ``0.0`` |
  42. +----------------------------------------------------+----------------------------------------------------------------------+---------------+
  43. Methods
  44. -------
  45. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer_method_get_playback_position>` **(** **)** |
  47. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  48. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer_method_get_stream_playback>` **(** **)** |
  49. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`play<class_AudioStreamPlayer_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  51. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`seek<class_AudioStreamPlayer_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  53. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`stop<class_AudioStreamPlayer_method_stop>` **(** **)** |
  55. +-------------------------------------------------------+----------------------------------------------------------------------------------------------------------+
  56. Signals
  57. -------
  58. .. _class_AudioStreamPlayer_signal_finished:
  59. - **finished** **(** **)**
  60. Emitted when the audio stops playing.
  61. Enumerations
  62. ------------
  63. .. _enum_AudioStreamPlayer_MixTarget:
  64. .. _class_AudioStreamPlayer_constant_MIX_TARGET_STEREO:
  65. .. _class_AudioStreamPlayer_constant_MIX_TARGET_SURROUND:
  66. .. _class_AudioStreamPlayer_constant_MIX_TARGET_CENTER:
  67. enum **MixTarget**:
  68. - **MIX_TARGET_STEREO** = **0** --- The audio will be played only on the first channel.
  69. - **MIX_TARGET_SURROUND** = **1** --- The audio will be played on all surround channels.
  70. - **MIX_TARGET_CENTER** = **2** --- The audio will be played on the second channel, which is usually the center.
  71. Property Descriptions
  72. ---------------------
  73. .. _class_AudioStreamPlayer_property_autoplay:
  74. - :ref:`bool<class_bool>` **autoplay**
  75. +-----------+-----------------------+
  76. | *Default* | ``false`` |
  77. +-----------+-----------------------+
  78. | *Setter* | set_autoplay(value) |
  79. +-----------+-----------------------+
  80. | *Getter* | is_autoplay_enabled() |
  81. +-----------+-----------------------+
  82. If ``true``, audio plays when added to scene tree.
  83. ----
  84. .. _class_AudioStreamPlayer_property_bus:
  85. - :ref:`StringName<class_StringName>` **bus**
  86. +-----------+----------------+
  87. | *Default* | ``&"Master"`` |
  88. +-----------+----------------+
  89. | *Setter* | set_bus(value) |
  90. +-----------+----------------+
  91. | *Getter* | get_bus() |
  92. +-----------+----------------+
  93. Bus on which this audio is playing.
  94. ----
  95. .. _class_AudioStreamPlayer_property_max_polyphony:
  96. - :ref:`int<class_int>` **max_polyphony**
  97. +-----------+--------------------------+
  98. | *Default* | ``1`` |
  99. +-----------+--------------------------+
  100. | *Setter* | set_max_polyphony(value) |
  101. +-----------+--------------------------+
  102. | *Getter* | get_max_polyphony() |
  103. +-----------+--------------------------+
  104. The maximum number of sounds this node can play at the same time. Playing additional sounds after this value is reached will cut off the oldest sounds.
  105. ----
  106. .. _class_AudioStreamPlayer_property_mix_target:
  107. - :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` **mix_target**
  108. +-----------+-----------------------+
  109. | *Default* | ``0`` |
  110. +-----------+-----------------------+
  111. | *Setter* | set_mix_target(value) |
  112. +-----------+-----------------------+
  113. | *Getter* | get_mix_target() |
  114. +-----------+-----------------------+
  115. If the audio configuration has more than two speakers, this sets the target channels. See :ref:`MixTarget<enum_AudioStreamPlayer_MixTarget>` constants.
  116. ----
  117. .. _class_AudioStreamPlayer_property_pitch_scale:
  118. - :ref:`float<class_float>` **pitch_scale**
  119. +-----------+------------------------+
  120. | *Default* | ``1.0`` |
  121. +-----------+------------------------+
  122. | *Setter* | set_pitch_scale(value) |
  123. +-----------+------------------------+
  124. | *Getter* | get_pitch_scale() |
  125. +-----------+------------------------+
  126. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  127. ----
  128. .. _class_AudioStreamPlayer_property_playing:
  129. - :ref:`bool<class_bool>` **playing**
  130. +-----------+--------------+
  131. | *Default* | ``false`` |
  132. +-----------+--------------+
  133. | *Getter* | is_playing() |
  134. +-----------+--------------+
  135. If ``true``, audio is playing.
  136. ----
  137. .. _class_AudioStreamPlayer_property_stream:
  138. - :ref:`AudioStream<class_AudioStream>` **stream**
  139. +----------+-------------------+
  140. | *Setter* | set_stream(value) |
  141. +----------+-------------------+
  142. | *Getter* | get_stream() |
  143. +----------+-------------------+
  144. The :ref:`AudioStream<class_AudioStream>` object to be played.
  145. ----
  146. .. _class_AudioStreamPlayer_property_stream_paused:
  147. - :ref:`bool<class_bool>` **stream_paused**
  148. +-----------+--------------------------+
  149. | *Default* | ``false`` |
  150. +-----------+--------------------------+
  151. | *Setter* | set_stream_paused(value) |
  152. +-----------+--------------------------+
  153. | *Getter* | get_stream_paused() |
  154. +-----------+--------------------------+
  155. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  156. ----
  157. .. _class_AudioStreamPlayer_property_volume_db:
  158. - :ref:`float<class_float>` **volume_db**
  159. +-----------+----------------------+
  160. | *Default* | ``0.0`` |
  161. +-----------+----------------------+
  162. | *Setter* | set_volume_db(value) |
  163. +-----------+----------------------+
  164. | *Getter* | get_volume_db() |
  165. +-----------+----------------------+
  166. Volume of sound, in dB.
  167. Method Descriptions
  168. -------------------
  169. .. _class_AudioStreamPlayer_method_get_playback_position:
  170. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  171. Returns the position in the :ref:`AudioStream<class_AudioStream>` in seconds.
  172. ----
  173. .. _class_AudioStreamPlayer_method_get_stream_playback:
  174. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  175. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer``.
  176. ----
  177. .. _class_AudioStreamPlayer_method_play:
  178. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  179. Plays the audio from the given ``from_position``, in seconds.
  180. ----
  181. .. _class_AudioStreamPlayer_method_seek:
  182. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  183. Sets the position from which audio will be played, in seconds.
  184. ----
  185. .. _class_AudioStreamPlayer_method_stop:
  186. - void **stop** **(** **)**
  187. Stops the audio.
  188. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  189. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  190. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  191. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  192. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  193. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`