audio_streams.rst 3.6 KB

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