audio_streams.rst 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. .. _doc_audio_streams:
  2. Audio streams
  3. =============
  4. Introduction
  5. ------------
  6. As you might have already read in :ref:`doc_audio_buses`, sound is sent to
  7. each bus via an AudioStreamPlayer node. There are different kinds
  8. of AudioStreamPlayers. Each one loads an AudioStream and plays it back.
  9. AudioStream
  10. -----------
  11. An audio stream is an abstract object that emits sound. The sound can come from
  12. many places, but is most commonly loaded from the filesystem. Audio files can be
  13. loaded as AudioStreams and placed inside an AudioStreamPlayer. You can find
  14. information on supported formats and differences in :ref:`doc_importing_audio_samples`.
  15. There are other types of AudioStreams, such as AudioStreamRandomPitch.
  16. This one makes a random adjustment to the sound's pitch every time it's
  17. played back. This can be helpful for adding variation to sounds that are
  18. played back often.
  19. AudioStreamPlayer
  20. -----------------
  21. .. image:: img/audio_stream_player.png
  22. This is the standard, non-positional stream player. It can play to any bus.
  23. In 5.1 sound setups, it can send audio to stereo mix or front speakers.
  24. AudioStreamPlayer2D
  25. -------------------
  26. .. image:: img/audio_stream_2d.png
  27. This is a variant of AudioStreamPlayer, but emits sound in a 2D positional
  28. environment. When close to the left of the screen, the panning will go left.
  29. When close to the right side, it will go right.
  30. .. note::
  31. Area2Ds can be used to divert sound from any AudioStreamPlayer2Ds they
  32. contain to specific buses. This makes it possible to create buses with
  33. different reverb or sound qualities to handle action happening in a
  34. particular parts of your game world.
  35. .. image:: img/audio_stream_2d_area.png
  36. AudioStreamPlayer3D
  37. -------------------
  38. .. image:: img/audio_stream_3d.png
  39. This is a variant of AudioStreamPlayer, but emits sound in a 3D positional
  40. environment. Depending on the location of the player relative to the screen,
  41. it can position sound in stereo, 5.1 or 7.1 depending on the chosen audio setup.
  42. Similar to AudioStreamPlayer2D, an Area can divert the sound to an audio bus.
  43. .. image:: img/audio_stream_3d_area.png
  44. Unlike for 2D, the 3D version of AudioStreamPlayer has a few more advanced options:
  45. .. _doc_audio_streams_reverb_buses:
  46. Reverb buses
  47. ~~~~~~~~~~~~
  48. Godot allows for 3D audio streams that enter a specific Area node to send dry
  49. and wet audio to separate buses. This is useful when you have several reverb
  50. configurations for different types of rooms. This is done by enabling this type
  51. of reverb in the **Reverb Bus** section of the Area's properties:
  52. .. image:: img/audio_stream_reverb_bus.png
  53. At the same time, a special bus layout is created where each area receives the
  54. reverb info from each area. A Reverb effect needs to be created and configured
  55. in each reverb bus to complete the setup for the desired effect:
  56. .. image:: img/audio_stream_reverb_bus2.png
  57. The Area's **Reverb Bus** section also has a parameter named **Uniformity**.
  58. Some types of rooms bounce sounds more than others (like a warehouse), so
  59. reverberation can be heard almost uniformly across the room even though the
  60. source may be far away. Playing around with this parameter can simulate
  61. that effect.
  62. Doppler
  63. ~~~~~~~
  64. When the relative velocity between an emitter and listener changes, this is
  65. perceived as an increase or decrease in the pitch of the emitted sound.
  66. Godot can track velocity changes in the AudioStreamPlayer3D and Camera nodes.
  67. Both nodes have this property, which must be enabled manually:
  68. .. image:: img/audio_stream_doppler.png
  69. Enable it by setting it depending on how objects will be moved:
  70. use **Idle** for objects moved using ``_process``, or **Physics**
  71. for objects moved using ``_physics_process``. The tracking will
  72. happen automatically.