class_audiostream.rst 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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/4.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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:`AudioStreamMicrophone<class_AudioStreamMicrophone>`, :ref:`AudioStreamMP3<class_AudioStreamMP3>`, :ref:`AudioStreamOggVorbis<class_AudioStreamOggVorbis>`, :ref:`AudioStreamPolyphonic<class_AudioStreamPolyphonic>`, :ref:`AudioStreamRandomizer<class_AudioStreamRandomizer>`, :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/526>`__
  21. - `Audio Mic Record Demo <https://godotengine.org/asset-library/asset/527>`__
  22. - `Audio Spectrum Demo <https://godotengine.org/asset-library/asset/528>`__
  23. .. rst-class:: classref-reftable-group
  24. Methods
  25. -------
  26. .. table::
  27. :widths: auto
  28. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  29. | :ref:`int<class_int>` | :ref:`_get_beat_count<class_AudioStream_private_method__get_beat_count>` **(** **)** |virtual| |const| |
  30. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  31. | :ref:`float<class_float>` | :ref:`_get_bpm<class_AudioStream_private_method__get_bpm>` **(** **)** |virtual| |const| |
  32. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  33. | :ref:`float<class_float>` | :ref:`_get_length<class_AudioStream_private_method__get_length>` **(** **)** |virtual| |const| |
  34. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`String<class_String>` | :ref:`_get_stream_name<class_AudioStream_private_method__get_stream_name>` **(** **)** |virtual| |const| |
  36. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  37. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`_instantiate_playback<class_AudioStream_private_method__instantiate_playback>` **(** **)** |virtual| |const| |
  38. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`bool<class_bool>` | :ref:`_is_monophonic<class_AudioStream_private_method__is_monophonic>` **(** **)** |virtual| |const| |
  40. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  41. | :ref:`float<class_float>` | :ref:`get_length<class_AudioStream_method_get_length>` **(** **)** |const| |
  42. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` | :ref:`instantiate_playback<class_AudioStream_method_instantiate_playback>` **(** **)** |
  44. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`bool<class_bool>` | :ref:`is_monophonic<class_AudioStream_method_is_monophonic>` **(** **)** |const| |
  46. +-------------------------------------------------------+--------------------------------------------------------------------------------------------------------------------+
  47. .. rst-class:: classref-section-separator
  48. ----
  49. .. rst-class:: classref-descriptions-group
  50. Method Descriptions
  51. -------------------
  52. .. _class_AudioStream_private_method__get_beat_count:
  53. .. rst-class:: classref-method
  54. :ref:`int<class_int>` **_get_beat_count** **(** **)** |virtual| |const|
  55. Overridable method. Should return the total number of beats of this audio stream. Used by the engine to determine the position of every beat.
  56. Ideally, the returned value should be based off the stream's sample rate (:ref:`AudioStreamWAV.mix_rate<class_AudioStreamWAV_property_mix_rate>`, for example).
  57. .. rst-class:: classref-item-separator
  58. ----
  59. .. _class_AudioStream_private_method__get_bpm:
  60. .. rst-class:: classref-method
  61. :ref:`float<class_float>` **_get_bpm** **(** **)** |virtual| |const|
  62. 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.
  63. Ideally, the returned value should be based off the stream's sample rate (:ref:`AudioStreamWAV.mix_rate<class_AudioStreamWAV_property_mix_rate>`, for example).
  64. .. rst-class:: classref-item-separator
  65. ----
  66. .. _class_AudioStream_private_method__get_length:
  67. .. rst-class:: classref-method
  68. :ref:`float<class_float>` **_get_length** **(** **)** |virtual| |const|
  69. 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.
  70. .. rst-class:: classref-item-separator
  71. ----
  72. .. _class_AudioStream_private_method__get_stream_name:
  73. .. rst-class:: classref-method
  74. :ref:`String<class_String>` **_get_stream_name** **(** **)** |virtual| |const|
  75. Override this method to customize the name assigned to this audio stream. Unused by the engine.
  76. .. rst-class:: classref-item-separator
  77. ----
  78. .. _class_AudioStream_private_method__instantiate_playback:
  79. .. rst-class:: classref-method
  80. :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **_instantiate_playback** **(** **)** |virtual| |const|
  81. Override this method to customize the returned value of :ref:`instantiate_playback<class_AudioStream_method_instantiate_playback>`. Should returned a new :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` created when the stream is played (such as by an :ref:`AudioStreamPlayer<class_AudioStreamPlayer>`)..
  82. .. rst-class:: classref-item-separator
  83. ----
  84. .. _class_AudioStream_private_method__is_monophonic:
  85. .. rst-class:: classref-method
  86. :ref:`bool<class_bool>` **_is_monophonic** **(** **)** |virtual| |const|
  87. 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.
  88. .. rst-class:: classref-item-separator
  89. ----
  90. .. _class_AudioStream_method_get_length:
  91. .. rst-class:: classref-method
  92. :ref:`float<class_float>` **get_length** **(** **)** |const|
  93. Returns the length of the audio stream in seconds.
  94. .. rst-class:: classref-item-separator
  95. ----
  96. .. _class_AudioStream_method_instantiate_playback:
  97. .. rst-class:: classref-method
  98. :ref:`AudioStreamPlayback<class_AudioStreamPlayback>` **instantiate_playback** **(** **)**
  99. 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``.
  100. .. rst-class:: classref-item-separator
  101. ----
  102. .. _class_AudioStream_method_is_monophonic:
  103. .. rst-class:: classref-method
  104. :ref:`bool<class_bool>` **is_monophonic** **(** **)** |const|
  105. Returns ``true`` if this audio stream only supports one channel (*monophony*), or ``false`` if the audio stream supports two or more channels (*polyphony*).
  106. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  107. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  108. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  109. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  110. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  111. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  112. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`