class_audiostreamplayer2d.rst 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 AudioStreamPlayer2D.xml source instead.
  4. .. The source is found in doc/classes or modules/<name>/doc_classes.
  5. .. _class_AudioStreamPlayer2D:
  6. AudioStreamPlayer2D
  7. ===================
  8. **Inherits:** :ref:`Node2D<class_Node2D>` **<** :ref:`CanvasItem<class_CanvasItem>` **<** :ref:`Node<class_Node>` **<** :ref:`Object<class_Object>`
  9. Plays positional sound in 2D space.
  10. Description
  11. -----------
  12. Plays audio that dampens with distance from screen center.
  13. See also :ref:`AudioStreamPlayer<class_AudioStreamPlayer>` to play a sound non-positionally.
  14. **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).
  15. Tutorials
  16. ---------
  17. - :doc:`Audio streams <../tutorials/audio/audio_streams>`
  18. Properties
  19. ----------
  20. +---------------------------------------+------------------------------------------------------------------------+---------------+
  21. | :ref:`int<class_int>` | :ref:`area_mask<class_AudioStreamPlayer2D_property_area_mask>` | ``1`` |
  22. +---------------------------------------+------------------------------------------------------------------------+---------------+
  23. | :ref:`float<class_float>` | :ref:`attenuation<class_AudioStreamPlayer2D_property_attenuation>` | ``1.0`` |
  24. +---------------------------------------+------------------------------------------------------------------------+---------------+
  25. | :ref:`bool<class_bool>` | :ref:`autoplay<class_AudioStreamPlayer2D_property_autoplay>` | ``false`` |
  26. +---------------------------------------+------------------------------------------------------------------------+---------------+
  27. | :ref:`StringName<class_StringName>` | :ref:`bus<class_AudioStreamPlayer2D_property_bus>` | ``&"Master"`` |
  28. +---------------------------------------+------------------------------------------------------------------------+---------------+
  29. | :ref:`float<class_float>` | :ref:`max_distance<class_AudioStreamPlayer2D_property_max_distance>` | ``2000.0`` |
  30. +---------------------------------------+------------------------------------------------------------------------+---------------+
  31. | :ref:`int<class_int>` | :ref:`max_polyphony<class_AudioStreamPlayer2D_property_max_polyphony>` | ``1`` |
  32. +---------------------------------------+------------------------------------------------------------------------+---------------+
  33. | :ref:`float<class_float>` | :ref:`pitch_scale<class_AudioStreamPlayer2D_property_pitch_scale>` | ``1.0`` |
  34. +---------------------------------------+------------------------------------------------------------------------+---------------+
  35. | :ref:`bool<class_bool>` | :ref:`playing<class_AudioStreamPlayer2D_property_playing>` | ``false`` |
  36. +---------------------------------------+------------------------------------------------------------------------+---------------+
  37. | :ref:`AudioStream<class_AudioStream>` | :ref:`stream<class_AudioStreamPlayer2D_property_stream>` | |
  38. +---------------------------------------+------------------------------------------------------------------------+---------------+
  39. | :ref:`bool<class_bool>` | :ref:`stream_paused<class_AudioStreamPlayer2D_property_stream_paused>` | ``false`` |
  40. +---------------------------------------+------------------------------------------------------------------------+---------------+
  41. | :ref:`float<class_float>` | :ref:`volume_db<class_AudioStreamPlayer2D_property_volume_db>` | ``0.0`` |
  42. +---------------------------------------+------------------------------------------------------------------------+---------------+
  43. Methods
  44. -------
  45. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  46. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayer2D_method_get_playback_position>` **(** **)** |
  47. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  48. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`get_stream_playback<class_AudioStreamPlayer2D_method_get_stream_playback>` **(** **)** |
  49. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  50. | void | :ref:`play<class_AudioStreamPlayer2D_method_play>` **(** :ref:`float<class_float>` from_position=0.0 **)** |
  51. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  52. | void | :ref:`seek<class_AudioStreamPlayer2D_method_seek>` **(** :ref:`float<class_float>` to_position **)** |
  53. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  54. | void | :ref:`stop<class_AudioStreamPlayer2D_method_stop>` **(** **)** |
  55. +-------------------------------------------------------+------------------------------------------------------------------------------------------------------------+
  56. Signals
  57. -------
  58. .. _class_AudioStreamPlayer2D_signal_finished:
  59. - **finished** **(** **)**
  60. Emitted when the audio stops playing.
  61. Property Descriptions
  62. ---------------------
  63. .. _class_AudioStreamPlayer2D_property_area_mask:
  64. - :ref:`int<class_int>` **area_mask**
  65. +-----------+----------------------+
  66. | *Default* | ``1`` |
  67. +-----------+----------------------+
  68. | *Setter* | set_area_mask(value) |
  69. +-----------+----------------------+
  70. | *Getter* | get_area_mask() |
  71. +-----------+----------------------+
  72. Areas in which this sound plays.
  73. ----
  74. .. _class_AudioStreamPlayer2D_property_attenuation:
  75. - :ref:`float<class_float>` **attenuation**
  76. +-----------+------------------------+
  77. | *Default* | ``1.0`` |
  78. +-----------+------------------------+
  79. | *Setter* | set_attenuation(value) |
  80. +-----------+------------------------+
  81. | *Getter* | get_attenuation() |
  82. +-----------+------------------------+
  83. Dampens audio over distance with this as an exponent.
  84. ----
  85. .. _class_AudioStreamPlayer2D_property_autoplay:
  86. - :ref:`bool<class_bool>` **autoplay**
  87. +-----------+-----------------------+
  88. | *Default* | ``false`` |
  89. +-----------+-----------------------+
  90. | *Setter* | set_autoplay(value) |
  91. +-----------+-----------------------+
  92. | *Getter* | is_autoplay_enabled() |
  93. +-----------+-----------------------+
  94. If ``true``, audio plays when added to scene tree.
  95. ----
  96. .. _class_AudioStreamPlayer2D_property_bus:
  97. - :ref:`StringName<class_StringName>` **bus**
  98. +-----------+----------------+
  99. | *Default* | ``&"Master"`` |
  100. +-----------+----------------+
  101. | *Setter* | set_bus(value) |
  102. +-----------+----------------+
  103. | *Getter* | get_bus() |
  104. +-----------+----------------+
  105. Bus on which this audio is playing.
  106. ----
  107. .. _class_AudioStreamPlayer2D_property_max_distance:
  108. - :ref:`float<class_float>` **max_distance**
  109. +-----------+-------------------------+
  110. | *Default* | ``2000.0`` |
  111. +-----------+-------------------------+
  112. | *Setter* | set_max_distance(value) |
  113. +-----------+-------------------------+
  114. | *Getter* | get_max_distance() |
  115. +-----------+-------------------------+
  116. Maximum distance from which audio is still hearable.
  117. ----
  118. .. _class_AudioStreamPlayer2D_property_max_polyphony:
  119. - :ref:`int<class_int>` **max_polyphony**
  120. +-----------+--------------------------+
  121. | *Default* | ``1`` |
  122. +-----------+--------------------------+
  123. | *Setter* | set_max_polyphony(value) |
  124. +-----------+--------------------------+
  125. | *Getter* | get_max_polyphony() |
  126. +-----------+--------------------------+
  127. 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.
  128. ----
  129. .. _class_AudioStreamPlayer2D_property_pitch_scale:
  130. - :ref:`float<class_float>` **pitch_scale**
  131. +-----------+------------------------+
  132. | *Default* | ``1.0`` |
  133. +-----------+------------------------+
  134. | *Setter* | set_pitch_scale(value) |
  135. +-----------+------------------------+
  136. | *Getter* | get_pitch_scale() |
  137. +-----------+------------------------+
  138. The pitch and the tempo of the audio, as a multiplier of the audio sample's sample rate.
  139. ----
  140. .. _class_AudioStreamPlayer2D_property_playing:
  141. - :ref:`bool<class_bool>` **playing**
  142. +-----------+--------------+
  143. | *Default* | ``false`` |
  144. +-----------+--------------+
  145. | *Getter* | is_playing() |
  146. +-----------+--------------+
  147. If ``true``, audio is playing.
  148. ----
  149. .. _class_AudioStreamPlayer2D_property_stream:
  150. - :ref:`AudioStream<class_AudioStream>` **stream**
  151. +----------+-------------------+
  152. | *Setter* | set_stream(value) |
  153. +----------+-------------------+
  154. | *Getter* | get_stream() |
  155. +----------+-------------------+
  156. The :ref:`AudioStream<class_AudioStream>` object to be played.
  157. ----
  158. .. _class_AudioStreamPlayer2D_property_stream_paused:
  159. - :ref:`bool<class_bool>` **stream_paused**
  160. +-----------+--------------------------+
  161. | *Default* | ``false`` |
  162. +-----------+--------------------------+
  163. | *Setter* | set_stream_paused(value) |
  164. +-----------+--------------------------+
  165. | *Getter* | get_stream_paused() |
  166. +-----------+--------------------------+
  167. If ``true``, the playback is paused. You can resume it by setting ``stream_paused`` to ``false``.
  168. ----
  169. .. _class_AudioStreamPlayer2D_property_volume_db:
  170. - :ref:`float<class_float>` **volume_db**
  171. +-----------+----------------------+
  172. | *Default* | ``0.0`` |
  173. +-----------+----------------------+
  174. | *Setter* | set_volume_db(value) |
  175. +-----------+----------------------+
  176. | *Getter* | get_volume_db() |
  177. +-----------+----------------------+
  178. Base volume without dampening.
  179. Method Descriptions
  180. -------------------
  181. .. _class_AudioStreamPlayer2D_method_get_playback_position:
  182. - :ref:`float<class_float>` **get_playback_position** **(** **)**
  183. Returns the position in the :ref:`AudioStream<class_AudioStream>`.
  184. ----
  185. .. _class_AudioStreamPlayer2D_method_get_stream_playback:
  186. - :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **get_stream_playback** **(** **)**
  187. Returns the :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` object associated with this ``AudioStreamPlayer2D``.
  188. ----
  189. .. _class_AudioStreamPlayer2D_method_play:
  190. - void **play** **(** :ref:`float<class_float>` from_position=0.0 **)**
  191. Plays the audio from the given position ``from_position``, in seconds.
  192. ----
  193. .. _class_AudioStreamPlayer2D_method_seek:
  194. - void **seek** **(** :ref:`float<class_float>` to_position **)**
  195. Sets the position from which audio will be played, in seconds.
  196. ----
  197. .. _class_AudioStreamPlayer2D_method_stop:
  198. - void **stop** **(** **)**
  199. Stops the audio.
  200. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  201. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  202. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  203. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  204. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  205. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`