audio_streams.rst 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. :article_outdated: True
  2. .. _doc_audio_streams:
  3. Audio streams
  4. =============
  5. Introduction
  6. ------------
  7. As you might have already read in :ref:`doc_audio_buses`, sound is sent to
  8. each bus via an AudioStreamPlayer node. There are different kinds
  9. of AudioStreamPlayers. Each one loads an AudioStream and plays it back.
  10. AudioStream
  11. -----------
  12. An audio stream is an abstract object that emits sound. The sound can come from
  13. many places, but is most commonly loaded from the filesystem. Audio files can be
  14. loaded as AudioStreams and placed inside an AudioStreamPlayer. You can find
  15. information on supported formats and differences in :ref:`doc_importing_audio_samples`.
  16. There are other types of AudioStreams, such as :ref:`AudioStreamRandomizer<class_AudioStreamRandomizer>`.
  17. This one picks a different audio stream from a list of streams each time it's played
  18. back, and applies random pitch and volume shifting. This can be helpful for adding
  19. variation to sounds that are played back often.
  20. AudioStreamPlayer
  21. -----------------
  22. .. image:: img/audio_stream_player.webp
  23. This is the standard, non-positional stream player. It can play to any bus.
  24. In 5.1 sound setups, it can send audio to stereo mix or front speakers.
  25. .. UPDATE: Experimental. When Playback Type is no longer experimental, update
  26. .. this paragraph.
  27. Playback Type is an experimental setting, and could change in future versions
  28. of Godot. It exists so Web exports use Web Audio-API based samples instead of
  29. streaming all sounds to the browser, unlike most platforms. This prevents the
  30. audio from being garbled in single-threaded Web exports. By default, only the
  31. Web platform will use samples. Changing this setting is not recommended, unless
  32. you have an explicit reason to. You can change the default playback type
  33. for the web and other platforms in the project settings under **Audio > General**
  34. (advanced settings must be turned on to see the setting).
  35. AudioStreamPlayer2D
  36. -------------------
  37. .. image:: img/audio_stream_2d.webp
  38. This is a variant of AudioStreamPlayer, but emits sound in a 2D positional
  39. environment. When close to the left of the screen, the panning will go left.
  40. When close to the right side, it will go right.
  41. .. note::
  42. Area2Ds can be used to divert sound from any AudioStreamPlayer2Ds they
  43. contain to specific buses. This makes it possible to create buses with
  44. different reverb or sound qualities to handle action happening in a
  45. particular parts of your game world.
  46. .. image:: img/audio_stream_2d_area.webp
  47. AudioStreamPlayer3D
  48. -------------------
  49. .. image:: img/audio_stream_3d.webp
  50. This is a variant of AudioStreamPlayer, but emits sound in a 3D positional
  51. environment. Depending on the location of the player relative to the screen,
  52. it can position sound in stereo, 5.1 or 7.1 depending on the chosen audio setup.
  53. Similar to AudioStreamPlayer2D, an Area3D can divert the sound to an audio bus.
  54. .. image:: img/audio_stream_3d_area.webp
  55. Unlike for 2D, the 3D version of AudioStreamPlayer has a few more advanced options:
  56. .. _doc_audio_streams_reverb_buses:
  57. Reverb buses
  58. ~~~~~~~~~~~~
  59. .. warning::
  60. This feature is not supported on the web platform if the AudioStreamPlayer's
  61. playback mode is set to **Sample**, which is the default. It will only work if the
  62. playback mode is set to **Stream**, at the cost of increased latency if threads
  63. are not enabled.
  64. See :ref:`Audio playback in the Exporting for the Web documentation <doc_exporting_for_web_audio_playback>`
  65. for details.
  66. Godot allows for 3D audio streams that enter a specific Area3D node to send dry
  67. and wet audio to separate buses. This is useful when you have several reverb
  68. configurations for different types of rooms. This is done by enabling this type
  69. of reverb in the **Reverb Bus** section of the Area3D's properties:
  70. .. image:: img/audio_stream_reverb_bus.webp
  71. At the same time, a special bus layout is created where each Area3D receives the
  72. reverb info from each Area3D. A Reverb effect needs to be created and configured
  73. in each reverb bus to complete the setup for the desired effect:
  74. .. image:: img/audio_stream_reverb_bus2.webp
  75. The Area3D's **Reverb Bus** section also has a parameter named **Uniformity**.
  76. Some types of rooms bounce sounds more than others (like a warehouse), so
  77. reverberation can be heard almost uniformly across the room even though the
  78. source may be far away. Playing around with this parameter can simulate
  79. that effect.
  80. Doppler
  81. ~~~~~~~
  82. .. warning::
  83. This feature is not supported on the web platform if the AudioStreamPlayer's
  84. playback mode is set to **Sample**, which is the default. It will only work if the
  85. playback mode is set to **Stream**, at the cost of increased latency if threads
  86. are not enabled.
  87. See :ref:`Audio playback in the Exporting for the Web documentation <doc_exporting_for_web_audio_playback>`
  88. for details.
  89. When the relative velocity between an emitter and listener changes, this is
  90. perceived as an increase or decrease in the pitch of the emitted sound.
  91. Godot can track velocity changes in the AudioStreamPlayer3D and Camera nodes.
  92. Both nodes have this property, which must be enabled manually:
  93. .. image:: img/audio_stream_doppler.webp
  94. Enable it by setting it depending on how objects will be moved:
  95. use **Idle** for objects moved using ``_process``, or **Physics**
  96. for objects moved using ``_physics_process``. The tracking will
  97. happen automatically.