class_audiostreamplayback.rst 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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/AudioStreamPlayback.xml.
  6. .. _class_AudioStreamPlayback:
  7. AudioStreamPlayback
  8. ===================
  9. **Inherits:** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`AudioStreamPlaybackInteractive<class_AudioStreamPlaybackInteractive>`, :ref:`AudioStreamPlaybackPlaylist<class_AudioStreamPlaybackPlaylist>`, :ref:`AudioStreamPlaybackPolyphonic<class_AudioStreamPlaybackPolyphonic>`, :ref:`AudioStreamPlaybackResampled<class_AudioStreamPlaybackResampled>`, :ref:`AudioStreamPlaybackSynchronized<class_AudioStreamPlaybackSynchronized>`
  11. Meta class for playing back audio.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Can play, loop, pause a scroll through audio. See :ref:`AudioStream<class_AudioStream>` and :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>` for usage.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - `Audio Generator Demo <https://godotengine.org/asset-library/asset/2759>`__
  20. .. rst-class:: classref-reftable-group
  21. Methods
  22. -------
  23. .. table::
  24. :widths: auto
  25. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`int<class_int>` | :ref:`_get_loop_count<class_AudioStreamPlayback_private_method__get_loop_count>`\ (\ ) |virtual| |const| |
  27. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`Variant<class_Variant>` | :ref:`_get_parameter<class_AudioStreamPlayback_private_method__get_parameter>`\ (\ name\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| |
  29. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  30. | :ref:`float<class_float>` | :ref:`_get_playback_position<class_AudioStreamPlayback_private_method__get_playback_position>`\ (\ ) |virtual| |const| |
  31. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  32. | :ref:`bool<class_bool>` | :ref:`_is_playing<class_AudioStreamPlayback_private_method__is_playing>`\ (\ ) |virtual| |const| |
  33. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  34. | :ref:`int<class_int>` | :ref:`_mix<class_AudioStreamPlayback_private_method__mix>`\ (\ buffer\: ``AudioFrame*``, rate_scale\: :ref:`float<class_float>`, frames\: :ref:`int<class_int>`\ ) |virtual| |
  35. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | |void| | :ref:`_seek<class_AudioStreamPlayback_private_method__seek>`\ (\ position\: :ref:`float<class_float>`\ ) |virtual| |
  37. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`_set_parameter<class_AudioStreamPlayback_private_method__set_parameter>`\ (\ name\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) |virtual| |
  39. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | |void| | :ref:`_start<class_AudioStreamPlayback_private_method__start>`\ (\ from_pos\: :ref:`float<class_float>`\ ) |virtual| |
  41. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`_stop<class_AudioStreamPlayback_private_method__stop>`\ (\ ) |virtual| |
  43. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | |void| | :ref:`_tag_used_streams<class_AudioStreamPlayback_private_method__tag_used_streams>`\ (\ ) |virtual| |
  45. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`get_loop_count<class_AudioStreamPlayback_method_get_loop_count>`\ (\ ) |const| |
  47. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`get_playback_position<class_AudioStreamPlayback_method_get_playback_position>`\ (\ ) |const| |
  49. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`AudioSamplePlayback<class_AudioSamplePlayback>` | :ref:`get_sample_playback<class_AudioStreamPlayback_method_get_sample_playback>`\ (\ ) |const| |
  51. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`bool<class_bool>` | :ref:`is_playing<class_AudioStreamPlayback_method_is_playing>`\ (\ ) |const| |
  53. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`PackedVector2Array<class_PackedVector2Array>` | :ref:`mix_audio<class_AudioStreamPlayback_method_mix_audio>`\ (\ rate_scale\: :ref:`float<class_float>`, frames\: :ref:`int<class_int>`\ ) |
  55. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | |void| | :ref:`seek<class_AudioStreamPlayback_method_seek>`\ (\ time\: :ref:`float<class_float>` = 0.0\ ) |
  57. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | |void| | :ref:`set_sample_playback<class_AudioStreamPlayback_method_set_sample_playback>`\ (\ playback_sample\: :ref:`AudioSamplePlayback<class_AudioSamplePlayback>`\ ) |
  59. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | |void| | :ref:`start<class_AudioStreamPlayback_method_start>`\ (\ from_pos\: :ref:`float<class_float>` = 0.0\ ) |
  61. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | |void| | :ref:`stop<class_AudioStreamPlayback_method_stop>`\ (\ ) |
  63. +-------------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. .. rst-class:: classref-section-separator
  65. ----
  66. .. rst-class:: classref-descriptions-group
  67. Method Descriptions
  68. -------------------
  69. .. _class_AudioStreamPlayback_private_method__get_loop_count:
  70. .. rst-class:: classref-method
  71. :ref:`int<class_int>` **_get_loop_count**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStreamPlayback_private_method__get_loop_count>`
  72. Overridable method. Should return how many times this audio stream has looped. Most built-in playbacks always return ``0``.
  73. .. rst-class:: classref-item-separator
  74. ----
  75. .. _class_AudioStreamPlayback_private_method__get_parameter:
  76. .. rst-class:: classref-method
  77. :ref:`Variant<class_Variant>` **_get_parameter**\ (\ name\: :ref:`StringName<class_StringName>`\ ) |virtual| |const| :ref:`🔗<class_AudioStreamPlayback_private_method__get_parameter>`
  78. Return the current value of a playback parameter by name (see :ref:`AudioStream._get_parameter_list<class_AudioStream_private_method__get_parameter_list>`).
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_AudioStreamPlayback_private_method__get_playback_position:
  82. .. rst-class:: classref-method
  83. :ref:`float<class_float>` **_get_playback_position**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStreamPlayback_private_method__get_playback_position>`
  84. Overridable method. Should return the current progress along the audio stream, in seconds.
  85. .. rst-class:: classref-item-separator
  86. ----
  87. .. _class_AudioStreamPlayback_private_method__is_playing:
  88. .. rst-class:: classref-method
  89. :ref:`bool<class_bool>` **_is_playing**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStreamPlayback_private_method__is_playing>`
  90. Overridable method. Should return ``true`` if this playback is active and playing its audio stream.
  91. .. rst-class:: classref-item-separator
  92. ----
  93. .. _class_AudioStreamPlayback_private_method__mix:
  94. .. rst-class:: classref-method
  95. :ref:`int<class_int>` **_mix**\ (\ buffer\: ``AudioFrame*``, rate_scale\: :ref:`float<class_float>`, frames\: :ref:`int<class_int>`\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__mix>`
  96. Override this method to customize how the audio stream is mixed. This method is called even if the playback is not active.
  97. \ **Note:** It is not useful to override this method in GDScript or C#. Only GDExtension can take advantage of it.
  98. .. rst-class:: classref-item-separator
  99. ----
  100. .. _class_AudioStreamPlayback_private_method__seek:
  101. .. rst-class:: classref-method
  102. |void| **_seek**\ (\ position\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__seek>`
  103. Override this method to customize what happens when seeking this audio stream at the given ``position``, such as by calling :ref:`AudioStreamPlayer.seek<class_AudioStreamPlayer_method_seek>`.
  104. .. rst-class:: classref-item-separator
  105. ----
  106. .. _class_AudioStreamPlayback_private_method__set_parameter:
  107. .. rst-class:: classref-method
  108. |void| **_set_parameter**\ (\ name\: :ref:`StringName<class_StringName>`, value\: :ref:`Variant<class_Variant>`\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__set_parameter>`
  109. Set the current value of a playback parameter by name (see :ref:`AudioStream._get_parameter_list<class_AudioStream_private_method__get_parameter_list>`).
  110. .. rst-class:: classref-item-separator
  111. ----
  112. .. _class_AudioStreamPlayback_private_method__start:
  113. .. rst-class:: classref-method
  114. |void| **_start**\ (\ from_pos\: :ref:`float<class_float>`\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__start>`
  115. Override this method to customize what happens when the playback starts at the given position, such as by calling :ref:`AudioStreamPlayer.play<class_AudioStreamPlayer_method_play>`.
  116. .. rst-class:: classref-item-separator
  117. ----
  118. .. _class_AudioStreamPlayback_private_method__stop:
  119. .. rst-class:: classref-method
  120. |void| **_stop**\ (\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__stop>`
  121. Override this method to customize what happens when the playback is stopped, such as by calling :ref:`AudioStreamPlayer.stop<class_AudioStreamPlayer_method_stop>`.
  122. .. rst-class:: classref-item-separator
  123. ----
  124. .. _class_AudioStreamPlayback_private_method__tag_used_streams:
  125. .. rst-class:: classref-method
  126. |void| **_tag_used_streams**\ (\ ) |virtual| :ref:`🔗<class_AudioStreamPlayback_private_method__tag_used_streams>`
  127. Overridable method. Called whenever the audio stream is mixed if the playback is active and :ref:`AudioServer.set_enable_tagging_used_audio_streams<class_AudioServer_method_set_enable_tagging_used_audio_streams>` has been set to ``true``. Editor plugins may use this method to "tag" the current position along the audio stream and display it in a preview.
  128. .. rst-class:: classref-item-separator
  129. ----
  130. .. _class_AudioStreamPlayback_method_get_loop_count:
  131. .. rst-class:: classref-method
  132. :ref:`int<class_int>` **get_loop_count**\ (\ ) |const| :ref:`🔗<class_AudioStreamPlayback_method_get_loop_count>`
  133. Returns the number of times the stream has looped.
  134. .. rst-class:: classref-item-separator
  135. ----
  136. .. _class_AudioStreamPlayback_method_get_playback_position:
  137. .. rst-class:: classref-method
  138. :ref:`float<class_float>` **get_playback_position**\ (\ ) |const| :ref:`🔗<class_AudioStreamPlayback_method_get_playback_position>`
  139. Returns the current position in the stream, in seconds.
  140. .. rst-class:: classref-item-separator
  141. ----
  142. .. _class_AudioStreamPlayback_method_get_sample_playback:
  143. .. rst-class:: classref-method
  144. :ref:`AudioSamplePlayback<class_AudioSamplePlayback>` **get_sample_playback**\ (\ ) |const| :ref:`🔗<class_AudioStreamPlayback_method_get_sample_playback>`
  145. **Experimental:** This method may be changed or removed in future versions.
  146. Returns the :ref:`AudioSamplePlayback<class_AudioSamplePlayback>` associated with this **AudioStreamPlayback** for playing back the audio sample of this stream.
  147. .. rst-class:: classref-item-separator
  148. ----
  149. .. _class_AudioStreamPlayback_method_is_playing:
  150. .. rst-class:: classref-method
  151. :ref:`bool<class_bool>` **is_playing**\ (\ ) |const| :ref:`🔗<class_AudioStreamPlayback_method_is_playing>`
  152. Returns ``true`` if the stream is playing.
  153. .. rst-class:: classref-item-separator
  154. ----
  155. .. _class_AudioStreamPlayback_method_mix_audio:
  156. .. rst-class:: classref-method
  157. :ref:`PackedVector2Array<class_PackedVector2Array>` **mix_audio**\ (\ rate_scale\: :ref:`float<class_float>`, frames\: :ref:`int<class_int>`\ ) :ref:`🔗<class_AudioStreamPlayback_method_mix_audio>`
  158. Mixes up to ``frames`` of audio from the stream from the current position, at a rate of ``rate_scale``, advancing the stream.
  159. Returns a :ref:`PackedVector2Array<class_PackedVector2Array>` where each element holds the left and right channel volume levels of each frame.
  160. \ **Note:** Can return fewer frames than requested, make sure to use the size of the return value.
  161. .. rst-class:: classref-item-separator
  162. ----
  163. .. _class_AudioStreamPlayback_method_seek:
  164. .. rst-class:: classref-method
  165. |void| **seek**\ (\ time\: :ref:`float<class_float>` = 0.0\ ) :ref:`🔗<class_AudioStreamPlayback_method_seek>`
  166. Seeks the stream at the given ``time``, in seconds.
  167. .. rst-class:: classref-item-separator
  168. ----
  169. .. _class_AudioStreamPlayback_method_set_sample_playback:
  170. .. rst-class:: classref-method
  171. |void| **set_sample_playback**\ (\ playback_sample\: :ref:`AudioSamplePlayback<class_AudioSamplePlayback>`\ ) :ref:`🔗<class_AudioStreamPlayback_method_set_sample_playback>`
  172. **Experimental:** This method may be changed or removed in future versions.
  173. Associates :ref:`AudioSamplePlayback<class_AudioSamplePlayback>` to this **AudioStreamPlayback** for playing back the audio sample of this stream.
  174. .. rst-class:: classref-item-separator
  175. ----
  176. .. _class_AudioStreamPlayback_method_start:
  177. .. rst-class:: classref-method
  178. |void| **start**\ (\ from_pos\: :ref:`float<class_float>` = 0.0\ ) :ref:`🔗<class_AudioStreamPlayback_method_start>`
  179. Starts the stream from the given ``from_pos``, in seconds.
  180. .. rst-class:: classref-item-separator
  181. ----
  182. .. _class_AudioStreamPlayback_method_stop:
  183. .. rst-class:: classref-method
  184. |void| **stop**\ (\ ) :ref:`🔗<class_AudioStreamPlayback_method_stop>`
  185. Stops the stream.
  186. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  187. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  188. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  189. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  190. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  191. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  192. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  193. .. |void| replace:: :abbr:`void (No return value.)`