class_audiostream.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  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/AudioStream.xml.
  6. .. _class_AudioStream:
  7. AudioStream
  8. ===========
  9. **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
  10. **Inherited By:** :ref:`AudioStreamGenerator<class_AudioStreamGenerator>`, :ref:`AudioStreamInteractive<class_AudioStreamInteractive>`, :ref:`AudioStreamMicrophone<class_AudioStreamMicrophone>`, :ref:`AudioStreamMP3<class_AudioStreamMP3>`, :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>`, :ref:`AudioStreamPlaylist<class_AudioStreamPlaylist>`, :ref:`AudioStreamPolyphonic<class_AudioStreamPolyphonic>`, :ref:`AudioStreamRandomizer<class_AudioStreamRandomizer>`, :ref:`AudioStreamSynchronized<class_AudioStreamSynchronized>`, :ref:`AudioStreamWAV<class_AudioStreamWAV>`
  11. Base class for audio streams.
  12. .. rst-class:: classref-introduction-group
  13. Description
  14. -----------
  15. Base class for audio streams. Audio streams are used for sound effects and music playback, and support WAV (via :ref:`AudioStreamWAV<class_AudioStreamWAV>`) and Ogg (via :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>`) file formats.
  16. .. rst-class:: classref-introduction-group
  17. Tutorials
  18. ---------
  19. - :doc:`Audio streams <../tutorials/audio/audio_streams>`
  20. - `Audio Generator Demo <https://godotengine.org/asset-library/asset/2759>`__
  21. - `Audio Microphone Record Demo <https://godotengine.org/asset-library/asset/2760>`__
  22. - `Audio Spectrum Visualizer Demo <https://godotengine.org/asset-library/asset/2762>`__
  23. .. rst-class:: classref-reftable-group
  24. Methods
  25. -------
  26. .. table::
  27. :widths: auto
  28. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`_get_bar_beats<class_AudioStream_private_method__get_bar_beats>`\ (\ ) |virtual| |const| |
  30. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  31. | :ref:`int<class_int>` | :ref:`_get_beat_count<class_AudioStream_private_method__get_beat_count>`\ (\ ) |virtual| |const| |
  32. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`_get_bpm<class_AudioStream_private_method__get_bpm>`\ (\ ) |virtual| |const| |
  34. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  35. | :ref:`float<class_float>` | :ref:`_get_length<class_AudioStream_private_method__get_length>`\ (\ ) |virtual| |const| |
  36. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  37. | :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] | :ref:`_get_parameter_list<class_AudioStream_private_method__get_parameter_list>`\ (\ ) |virtual| |const| |
  38. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  39. | :ref:`String<class_String>` | :ref:`_get_stream_name<class_AudioStream_private_method__get_stream_name>`\ (\ ) |virtual| |const| |
  40. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  41. | :ref:`Dictionary<class_Dictionary>` | :ref:`_get_tags<class_AudioStream_private_method__get_tags>`\ (\ ) |virtual| |const| |
  42. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  43. | :ref:`bool<class_bool>` | :ref:`_has_loop<class_AudioStream_private_method__has_loop>`\ (\ ) |virtual| |const| |
  44. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  45. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`_instantiate_playback<class_AudioStream_private_method__instantiate_playback>`\ (\ ) |virtual| |const| |
  46. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  47. | :ref:`bool<class_bool>` | :ref:`_is_monophonic<class_AudioStream_private_method__is_monophonic>`\ (\ ) |virtual| |const| |
  48. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  49. | :ref:`bool<class_bool>` | :ref:`can_be_sampled<class_AudioStream_method_can_be_sampled>`\ (\ ) |const| |
  50. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  51. | :ref:`AudioSample<class_AudioSample>` | :ref:`generate_sample<class_AudioStream_method_generate_sample>`\ (\ ) |const| |
  52. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  53. | :ref:`float<class_float>` | :ref:`get_length<class_AudioStream_method_get_length>`\ (\ ) |const| |
  54. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  55. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`instantiate_playback<class_AudioStream_method_instantiate_playback>`\ (\ ) |
  56. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  57. | :ref:`bool<class_bool>` | :ref:`is_meta_stream<class_AudioStream_method_is_meta_stream>`\ (\ ) |const| |
  58. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  59. | :ref:`bool<class_bool>` | :ref:`is_monophonic<class_AudioStream_method_is_monophonic>`\ (\ ) |const| |
  60. +------------------------------------------------------------------+--------------------------------------------------------------------------------------------------------------+
  61. .. rst-class:: classref-section-separator
  62. ----
  63. .. rst-class:: classref-descriptions-group
  64. Signals
  65. -------
  66. .. _class_AudioStream_signal_parameter_list_changed:
  67. .. rst-class:: classref-signal
  68. **parameter_list_changed**\ (\ ) :ref:`🔗<class_AudioStream_signal_parameter_list_changed>`
  69. Signal to be emitted to notify when the parameter list changed.
  70. .. rst-class:: classref-section-separator
  71. ----
  72. .. rst-class:: classref-descriptions-group
  73. Method Descriptions
  74. -------------------
  75. .. _class_AudioStream_private_method__get_bar_beats:
  76. .. rst-class:: classref-method
  77. :ref:`int<class_int>` **_get_bar_beats**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_bar_beats>`
  78. Override this method to return the bar beats of this stream.
  79. .. rst-class:: classref-item-separator
  80. ----
  81. .. _class_AudioStream_private_method__get_beat_count:
  82. .. rst-class:: classref-method
  83. :ref:`int<class_int>` **_get_beat_count**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_beat_count>`
  84. Overridable method. Should return the total number of beats of this audio stream. Used by the engine to determine the position of every beat.
  85. Ideally, the returned value should be based off the stream's sample rate (:ref:`AudioStreamWAV.mix_rate<class_AudioStreamWAV_property_mix_rate>`, for example).
  86. .. rst-class:: classref-item-separator
  87. ----
  88. .. _class_AudioStream_private_method__get_bpm:
  89. .. rst-class:: classref-method
  90. :ref:`float<class_float>` **_get_bpm**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_bpm>`
  91. Overridable method. Should return the tempo of this audio stream, in beats per minute (BPM). Used by the engine to determine the position of every beat.
  92. Ideally, the returned value should be based off the stream's sample rate (:ref:`AudioStreamWAV.mix_rate<class_AudioStreamWAV_property_mix_rate>`, for example).
  93. .. rst-class:: classref-item-separator
  94. ----
  95. .. _class_AudioStream_private_method__get_length:
  96. .. rst-class:: classref-method
  97. :ref:`float<class_float>` **_get_length**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_length>`
  98. Override this method to customize the returned value of :ref:`get_length()<class_AudioStream_method_get_length>`. Should return the length of this audio stream, in seconds.
  99. .. rst-class:: classref-item-separator
  100. ----
  101. .. _class_AudioStream_private_method__get_parameter_list:
  102. .. rst-class:: classref-method
  103. :ref:`Array<class_Array>`\[:ref:`Dictionary<class_Dictionary>`\] **_get_parameter_list**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_parameter_list>`
  104. Return the controllable parameters of this stream. This array contains dictionaries with a property info description format (see :ref:`Object.get_property_list()<class_Object_method_get_property_list>`). Additionally, the default value for this parameter must be added tho each dictionary in "default_value" field.
  105. .. rst-class:: classref-item-separator
  106. ----
  107. .. _class_AudioStream_private_method__get_stream_name:
  108. .. rst-class:: classref-method
  109. :ref:`String<class_String>` **_get_stream_name**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_stream_name>`
  110. Override this method to customize the name assigned to this audio stream. Unused by the engine.
  111. .. rst-class:: classref-item-separator
  112. ----
  113. .. _class_AudioStream_private_method__get_tags:
  114. .. rst-class:: classref-method
  115. :ref:`Dictionary<class_Dictionary>` **_get_tags**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__get_tags>`
  116. Override this method to customize the tags for this audio stream. Should return a :ref:`Dictionary<class_Dictionary>` of strings with the tag as the key and its content as the value.
  117. Commonly used tags include ``title``, ``artist``, ``album``, ``tracknumber``, and ``date``.
  118. .. rst-class:: classref-item-separator
  119. ----
  120. .. _class_AudioStream_private_method__has_loop:
  121. .. rst-class:: classref-method
  122. :ref:`bool<class_bool>` **_has_loop**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__has_loop>`
  123. Override this method to return ``true`` if this stream has a loop.
  124. .. rst-class:: classref-item-separator
  125. ----
  126. .. _class_AudioStream_private_method__instantiate_playback:
  127. .. rst-class:: classref-method
  128. :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **_instantiate_playback**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__instantiate_playback>`
  129. Override this method to customize the returned value of :ref:`instantiate_playback()<class_AudioStream_method_instantiate_playback>`. Should return a new :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` created when the stream is played (such as by an :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`).
  130. .. rst-class:: classref-item-separator
  131. ----
  132. .. _class_AudioStream_private_method__is_monophonic:
  133. .. rst-class:: classref-method
  134. :ref:`bool<class_bool>` **_is_monophonic**\ (\ ) |virtual| |const| :ref:`🔗<class_AudioStream_private_method__is_monophonic>`
  135. Override this method to customize the returned value of :ref:`is_monophonic()<class_AudioStream_method_is_monophonic>`. Should return ``true`` if this audio stream only supports one channel.
  136. .. rst-class:: classref-item-separator
  137. ----
  138. .. _class_AudioStream_method_can_be_sampled:
  139. .. rst-class:: classref-method
  140. :ref:`bool<class_bool>` **can_be_sampled**\ (\ ) |const| :ref:`🔗<class_AudioStream_method_can_be_sampled>`
  141. **Experimental:** This method may be changed or removed in future versions.
  142. Returns if the current **AudioStream** can be used as a sample. Only static streams can be sampled.
  143. .. rst-class:: classref-item-separator
  144. ----
  145. .. _class_AudioStream_method_generate_sample:
  146. .. rst-class:: classref-method
  147. :ref:`AudioSample<class_AudioSample>` **generate_sample**\ (\ ) |const| :ref:`🔗<class_AudioStream_method_generate_sample>`
  148. **Experimental:** This method may be changed or removed in future versions.
  149. Generates an :ref:`AudioSample<class_AudioSample>` based on the current stream.
  150. .. rst-class:: classref-item-separator
  151. ----
  152. .. _class_AudioStream_method_get_length:
  153. .. rst-class:: classref-method
  154. :ref:`float<class_float>` **get_length**\ (\ ) |const| :ref:`🔗<class_AudioStream_method_get_length>`
  155. Returns the length of the audio stream in seconds. If this stream is an :ref:`AudioStreamRandomizer<class_AudioStreamRandomizer>`, returns the length of the last played stream. If this stream has an indefinite length (such as for :ref:`AudioStreamGenerator<class_AudioStreamGenerator>` and :ref:`AudioStreamMicrophone<class_AudioStreamMicrophone>`), returns ``0.0``.
  156. .. rst-class:: classref-item-separator
  157. ----
  158. .. _class_AudioStream_method_instantiate_playback:
  159. .. rst-class:: classref-method
  160. :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **instantiate_playback**\ (\ ) :ref:`🔗<class_AudioStream_method_instantiate_playback>`
  161. Returns a newly created :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` intended to play this audio stream. Useful for when you want to extend :ref:`_instantiate_playback()<class_AudioStream_private_method__instantiate_playback>` but call :ref:`instantiate_playback()<class_AudioStream_method_instantiate_playback>` from an internally held AudioStream subresource. An example of this can be found in the source code for ``AudioStreamRandomPitch::instantiate_playback``.
  162. .. rst-class:: classref-item-separator
  163. ----
  164. .. _class_AudioStream_method_is_meta_stream:
  165. .. rst-class:: classref-method
  166. :ref:`bool<class_bool>` **is_meta_stream**\ (\ ) |const| :ref:`🔗<class_AudioStream_method_is_meta_stream>`
  167. Returns ``true`` if the stream is a collection of other streams, ``false`` otherwise.
  168. .. rst-class:: classref-item-separator
  169. ----
  170. .. _class_AudioStream_method_is_monophonic:
  171. .. rst-class:: classref-method
  172. :ref:`bool<class_bool>` **is_monophonic**\ (\ ) |const| :ref:`🔗<class_AudioStream_method_is_monophonic>`
  173. Returns ``true`` if this audio stream only supports one channel (*monophony*), or ``false`` if the audio stream supports two or more channels (*polyphony*).
  174. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  175. .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
  176. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  177. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  178. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  179. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  180. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  181. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  182. .. |void| replace:: :abbr:`void (No return value.)`