class_audiostreamplayer2d.rst 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/3.6/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/3.6/doc/classes/AudioStreamPlayer2D.xml.
  6. .. _class_AudioStreamPlayer2D:
  7. AudioStreamPlayer2D
  8. ===================
  9. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  10. Plays positional sound in 2D space.
  11. .. rst-class:: classref-introduction-group
  12. Description
  13. -----------
  14. Plays audio that dampens with distance from a given position.
  15. By default, audio is heard from the screen center. This can be changed by adding a :ref:`Listener2D<class_Listener2D>` node to the scene and enabling it by calling :ref:`Listener2D.make_current<class_Listener2D_method_make_current>` on it.
  16. See also :ref:`AudioStreamPlayer<class_AudioStreamPlayer>` to play a sound non-positionally.
  17. \ **Note:** Hiding an **AudioStreamPlayer2D** node does not disable its audio output. To temporarily disable an **AudioStreamPlayer2D**'s audio output, set :ref:`volume_db<class_AudioStreamPlayer2D_property_volume_db>` to a very low value like ``-100`` (which isn't audible to human hearing).
  18. .. rst-class:: classref-introduction-group
  19. Tutorials
  20. ---------
  21. - :doc:`../tutorials/audio/audio_streams`
  22. .. rst-class:: classref-reftable-group
  23. Properties
  24. ----------
  25. .. table::
  26. :widths: auto
  27. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  28. | :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer2D_property_area_mask>` | ``1`` |
  29. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  30. | :ref:`float<class_float>` | :ref:`attenuation<class_AudioStreamPlayer2D_property_attenuation>` | ``1.0`` |
  31. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  32. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer2D_property_autoplay>` | ``false`` |
  33. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  34. | :ref:`String<class_String>` | :ref:`bus<class_AudioStreamPlayer2D_property_bus>` | ``"Master"`` |
  35. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  36. | :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer2D_property_max_distance>` | ``2000.0`` |
  37. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  38. | :ref:`float<class_float>` | :ref:`panning_strength<class_AudioStreamPlayer2D_property_panning_strength>` | ``1.0`` |
  39. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  40. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer2D_property_pitch_scale>` | ``1.0`` |
  41. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  42. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer2D_property_playing>` | ``false`` |
  43. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  44. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer2D_property_stream>` | |
  45. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  46. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer2D_property_stream_paused>` | ``false`` |
  47. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  48. | :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer2D_property_volume_db>` | ``0.0`` |
  49. +---------------------------------------+------------------------------------------------------------------------------+--------------+
  50. .. rst-class:: classref-reftable-group
  51. Methods
  52. -------
  53. .. table::
  54. :widths: auto
  55. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  56. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer2D_method_get_playback_position>` **(** **)** |
  57. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  58. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer2D_method_get_stream_playback>` **(** **)** |
  59. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  60. | void | :ref:`play<class_AudioStreamPlayer2D_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  61. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  62. | void | :ref:`seek<class_AudioStreamPlayer2D_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  63. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  64. | void | :ref:`stop<class_AudioStreamPlayer2D_method_stop>` **(** **)** |
  65. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  66. .. rst-class:: classref-section-separator
  67. ----
  68. .. rst-class:: classref-descriptions-group
  69. Signals
  70. -------
  71. .. _class_AudioStreamPlayer2D_signal_finished:
  72. .. rst-class:: classref-signal
  73. **finished** **(** **)**
  74. Emitted when the audio stops playing.
  75. .. rst-class:: classref-section-separator
  76. ----
  77. .. rst-class:: classref-descriptions-group
  78. Property Descriptions
  79. ---------------------
  80. .. _class_AudioStreamPlayer2D_property_area_mask:
  81. .. rst-class:: classref-property
  82. :ref:`int<class_int>` **area_mask** = ``1``
  83. .. rst-class:: classref-property-setget
  84. - void **set_area_mask** **(** :ref:`int<class_int>` value **)**
  85. - :ref:`int<class_int>` **get_area_mask** **(** **)**
  86. Determines which :ref:`Area2D<class_Area2D>` layers affect the sound for reverb and audio bus effects. Areas can be used to redirect :ref:`AudioStream<class_AudioStream>`\ s so that they play in a certain audio bus. An example of how you might use this is making a "water" area so that sounds played in the water are redirected through an audio bus to make them sound like they are being played underwater.
  87. .. rst-class:: classref-item-separator
  88. ----
  89. .. _class_AudioStreamPlayer2D_property_attenuation:
  90. .. rst-class:: classref-property
  91. :ref:`float<class_float>` **attenuation** = ``1.0``
  92. .. rst-class:: classref-property-setget
  93. - void **set_attenuation** **(** :ref:`float<class_float>` value **)**
  94. - :ref:`float<class_float>` **get_attenuation** **(** **)**
  95. Dampens audio over distance with this as an exponent.
  96. .. rst-class:: classref-item-separator
  97. ----
  98. .. _class_AudioStreamPlayer2D_property_autoplay:
  99. .. rst-class:: classref-property
  100. :ref:`bool<class_bool>` **autoplay** = ``false``
  101. .. rst-class:: classref-property-setget
  102. - void **set_autoplay** **(** :ref:`bool<class_bool>` value **)**
  103. - :ref:`bool<class_bool>` **is_autoplay_enabled** **(** **)**
  104. If ``true``, audio plays when added to scene tree.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_AudioStreamPlayer2D_property_bus:
  108. .. rst-class:: classref-property
  109. :ref:`String<class_String>` **bus** = ``"Master"``
  110. .. rst-class:: classref-property-setget
  111. - void **set_bus** **(** :ref:`String<class_String>` value **)**
  112. - :ref:`String<class_String>` **get_bus** **(** **)**
  113. Bus on which this audio is playing.
  114. \ **Note:** When setting this property, keep in mind that no validation is performed to see if the given name matches an existing bus. This is because audio bus layouts might be loaded after this property is set. If this given name can't be resolved at runtime, it will fall back to ``"Master"``.
  115. .. rst-class:: classref-item-separator
  116. ----
  117. .. _class_AudioStreamPlayer2D_property_max_distance:
  118. .. rst-class:: classref-property
  119. :ref:`float<class_float>` **max_distance** = ``2000.0``
  120. .. rst-class:: classref-property-setget
  121. - void **set_max_distance** **(** :ref:`float<class_float>` value **)**
  122. - :ref:`float<class_float>` **get_max_distance** **(** **)**
  123. Maximum distance from which audio is still hearable.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_AudioStreamPlayer2D_property_panning_strength:
  127. .. rst-class:: classref-property
  128. :ref:`float<class_float>` **panning_strength** = ``1.0``
  129. .. rst-class:: classref-property-setget
  130. - void **set_panning_strength** **(** :ref:`float<class_float>` value **)**
  131. - :ref:`float<class_float>` **get_panning_strength** **(** **)**
  132. Scales the panning strength for this node by multiplying the base :ref:`ProjectSettings.audio/2d_panning_strength<class_ProjectSettings_property_audio/2d_panning_strength>` with this factor. Higher values will pan audio from left to right more dramatically than lower values.
  133. .. rst-class:: classref-item-separator
  134. ----
  135. .. _class_AudioStreamPlayer2D_property_pitch_scale:
  136. .. rst-class:: classref-property
  137. :ref:`float<class_float>` **pitch_scale** = ``1.0``
  138. .. rst-class:: classref-property-setget
  139. - void **set_pitch_scale** **(** :ref:`float<class_float>` value **)**
  140. - :ref:`float<class_float>` **get_pitch_scale** **(** **)**
  141. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  142. .. rst-class:: classref-item-separator
  143. ----
  144. .. _class_AudioStreamPlayer2D_property_playing:
  145. .. rst-class:: classref-property
  146. :ref:`bool<class_bool>` **playing** = ``false``
  147. .. rst-class:: classref-property-setget
  148. - :ref:`bool<class_bool>` **is_playing** **(** **)**
  149. If ``true``, audio is playing.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_AudioStreamPlayer2D_property_stream:
  153. .. rst-class:: classref-property
  154. :ref:`AudioStream<class_AudioStream>` **stream**
  155. .. rst-class:: classref-property-setget
  156. - void **set_stream** **(** :ref:`AudioStream<class_AudioStream>` value **)**
  157. - :ref:`AudioStream<class_AudioStream>` **get_stream** **(** **)**
  158. The :ref:`AudioStream<class_AudioStream>` object to be played.
  159. .. rst-class:: classref-item-separator
  160. ----
  161. .. _class_AudioStreamPlayer2D_property_stream_paused:
  162. .. rst-class:: classref-property
  163. :ref:`bool<class_bool>` **stream_paused** = ``false``
  164. .. rst-class:: classref-property-setget
  165. - void **set_stream_paused** **(** :ref:`bool<class_bool>` value **)**
  166. - :ref:`bool<class_bool>` **get_stream_paused** **(** **)**
  167. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_AudioStreamPlayer2D_property_volume_db:
  171. .. rst-class:: classref-property
  172. :ref:`float<class_float>` **volume_db** = ``0.0``
  173. .. rst-class:: classref-property-setget
  174. - void **set_volume_db** **(** :ref:`float<class_float>` value **)**
  175. - :ref:`float<class_float>` **get_volume_db** **(** **)**
  176. Base volume without dampening.
  177. .. rst-class:: classref-section-separator
  178. ----
  179. .. rst-class:: classref-descriptions-group
  180. Method Descriptions
  181. -------------------
  182. .. _class_AudioStreamPlayer2D_method_get_playback_position:
  183. .. rst-class:: classref-method
  184. :ref:`float<class_float>` **get_playback_position** **(** **)**
  185. Returns the position in the :ref:`AudioStream<class_AudioStream>`.
  186. .. rst-class:: classref-item-separator
  187. ----
  188. .. _class_AudioStreamPlayer2D_method_get_stream_playback:
  189. .. rst-class:: classref-method
  190. :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  191. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this **AudioStreamPlayer2D**.
  192. .. rst-class:: classref-item-separator
  193. ----
  194. .. _class_AudioStreamPlayer2D_method_play:
  195. .. rst-class:: classref-method
  196. void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  197. Plays the audio from the given position ``from_position``, in seconds.
  198. .. rst-class:: classref-item-separator
  199. ----
  200. .. _class_AudioStreamPlayer2D_method_seek:
  201. .. rst-class:: classref-method
  202. void **seek** **(** :ref:`float<class_float>` to_position **)**
  203. Sets the position from which audio will be played, in seconds.
  204. .. rst-class:: classref-item-separator
  205. ----
  206. .. _class_AudioStreamPlayer2D_method_stop:
  207. .. rst-class:: classref-method
  208. void **stop** **(** **)**
  209. Stops the audio.
  210. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  211. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  212. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  213. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`