audio_streams.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. Playback Type is an experimental setting, and could change in future versions
  26. of Godot. It exists so Web exports use Web Audio-API based samples instead of
  27. streaming all sounds to the browser, unlike most platforms. This prevents the
  28. audio from being garbled in single-threaded Web exports. By default, only the
  29. Web platform will use samples. Changing this setting is not recommended, unless
  30. you have an explicit reason to. You can change the default playback type
  31. for the web and other platforms in the project settings under **Audio > General**
  32. (advanced settings must be turned on to see the setting).
  33. AudioStreamPlayer2D
  34. -------------------
  35. .. image:: img/audio_stream_2d.webp
  36. This is a variant of AudioStreamPlayer, but emits sound in a 2D positional
  37. environment. When close to the left of the screen, the panning will go left.
  38. When close to the right side, it will go right.
  39. .. note::
  40. Area2Ds can be used to divert sound from any AudioStreamPlayer2Ds they
  41. contain to specific buses. This makes it possible to create buses with
  42. different reverb or sound qualities to handle action happening in a
  43. particular parts of your game world.
  44. .. image:: img/audio_stream_2d_area.webp
  45. AudioStreamPlayer3D
  46. -------------------
  47. .. image:: img/audio_stream_3d.webp
  48. This is a variant of AudioStreamPlayer, but emits sound in a 3D positional
  49. environment. Depending on the location of the player relative to the screen,
  50. it can position sound in stereo, 5.1 or 7.1 depending on the chosen audio setup.
  51. Similar to AudioStreamPlayer2D, an Area3D can divert the sound to an audio bus.
  52. .. image:: img/audio_stream_3d_area.webp
  53. Unlike for 2D, the 3D version of AudioStreamPlayer has a few more advanced options:
  54. .. _doc_audio_streams_reverb_buses:
  55. Reverb buses
  56. ~~~~~~~~~~~~
  57. .. warning::
  58. This feature is not supported on the web platform if the AudioStreamPlayer's
  59. playback mode is set to **Sample**, which is the default. It will only work if the
  60. playback mode is set to **Stream**, at the cost of increased latency if threads
  61. are not enabled.
  62. See :ref:`Audio playback in the Exporting for the Web documentation <doc_exporting_for_web_audio_playback>`
  63. for details.
  64. Godot allows for 3D audio streams that enter a specific Area3D node to send dry
  65. and wet audio to separate buses. This is useful when you have several reverb
  66. configurations for different types of rooms. This is done by enabling this type
  67. of reverb in the **Reverb Bus** section of the Area3D's properties:
  68. .. image:: img/audio_stream_reverb_bus.webp
  69. At the same time, a special bus layout is created where each Area3D receives the
  70. reverb info from each Area3D. A Reverb effect needs to be created and configured
  71. in each reverb bus to complete the setup for the desired effect:
  72. .. image:: img/audio_stream_reverb_bus2.webp
  73. The Area3D's **Reverb Bus** section also has a parameter named **Uniformity**.
  74. Some types of rooms bounce sounds more than others (like a warehouse), so
  75. reverberation can be heard almost uniformly across the room even though the
  76. source may be far away. Playing around with this parameter can simulate
  77. that effect.
  78. Doppler
  79. ~~~~~~~
  80. .. warning::
  81. This feature is not supported on the web platform if the AudioStreamPlayer's
  82. playback mode is set to **Sample**, which is the default. It will only work if the
  83. playback mode is set to **Stream**, at the cost of increased latency if threads
  84. are not enabled.
  85. See :ref:`Audio playback in the Exporting for the Web documentation <doc_exporting_for_web_audio_playback>`
  86. for details.
  87. When the relative velocity between an emitter and listener changes, this is
  88. perceived as an increase or decrease in the pitch of the emitted sound.
  89. Godot can track velocity changes in the AudioStreamPlayer3D and Camera nodes.
  90. Both nodes have this property, which must be enabled manually:
  91. .. image:: img/audio_stream_doppler.webp
  92. Enable it by setting it depending on how objects will be moved:
  93. use **Idle** for objects moved using ``_process``, or **Physics**
  94. for objects moved using ``_physics_process``. The tracking will
  95. happen automatically.