class_audiostreamplayer.rst 14 KB

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