audio_streams.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 AudioStreamRandomPitch.
  17. This one makes a random adjustment to the sound's pitch every time it's
  18. played back. This can be helpful for adding variation to sounds that are
  19. played back often.
  20. AudioStreamPlayer
  21. -----------------
  22. .. image:: img/audio_stream_player.png
  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. AudioStreamPlayer2D
  26. -------------------
  27. .. image:: img/audio_stream_2d.png
  28. This is a variant of AudioStreamPlayer, but emits sound in a 2D positional
  29. environment. When close to the left of the screen, the panning will go left.
  30. When close to the right side, it will go right.
  31. .. note::
  32. Area2Ds can be used to divert sound from any AudioStreamPlayer2Ds they
  33. contain to specific buses. This makes it possible to create buses with
  34. different reverb or sound qualities to handle action happening in a
  35. particular parts of your game world.
  36. .. image:: img/audio_stream_2d_area.png
  37. AudioStreamPlayer3D
  38. -------------------
  39. .. image:: img/audio_stream_3d.png
  40. This is a variant of AudioStreamPlayer, but emits sound in a 3D positional
  41. environment. Depending on the location of the player relative to the screen,
  42. it can position sound in stereo, 5.1 or 7.1 depending on the chosen audio setup.
  43. Similar to AudioStreamPlayer2D, an Area can divert the sound to an audio bus.
  44. .. image:: img/audio_stream_3d_area.png
  45. Unlike for 2D, the 3D version of AudioStreamPlayer has a few more advanced options:
  46. .. _doc_audio_streams_reverb_buses:
  47. Reverb buses
  48. ~~~~~~~~~~~~
  49. Godot allows for 3D audio streams that enter a specific Area node to send dry
  50. and wet audio to separate buses. This is useful when you have several reverb
  51. configurations for different types of rooms. This is done by enabling this type
  52. of reverb in the **Reverb Bus** section of the Area's properties:
  53. .. image:: img/audio_stream_reverb_bus.png
  54. At the same time, a special bus layout is created where each area receives the
  55. reverb info from each area. A Reverb effect needs to be created and configured
  56. in each reverb bus to complete the setup for the desired effect:
  57. .. image:: img/audio_stream_reverb_bus2.png
  58. The Area's **Reverb Bus** section also has a parameter named **Uniformity**.
  59. Some types of rooms bounce sounds more than others (like a warehouse), so
  60. reverberation can be heard almost uniformly across the room even though the
  61. source may be far away. Playing around with this parameter can simulate
  62. that effect.
  63. Doppler
  64. ~~~~~~~
  65. When the relative velocity between an emitter and listener changes, this is
  66. perceived as an increase or decrease in the pitch of the emitted sound.
  67. Godot can track velocity changes in the AudioStreamPlayer3D and Camera nodes.
  68. Both nodes have this property, which must be enabled manually:
  69. .. image:: img/audio_stream_doppler.png
  70. Enable it by setting it depending on how objects will be moved:
  71. use **Idle** for objects moved using ``_process``, or **Physics**
  72. for objects moved using ``_physics_process``. The tracking will
  73. happen automatically.