audio_buses.rst 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. .. _doc_audio-buses:
  2. Audio Buses
  3. ===========
  4. Introduction
  5. ------------
  6. Beginning Godot 3.0, the audio engine has been rewritten from scratch.
  7. The aim now is to present an interface much friendlier to sound design
  8. professionals. To achieve this, the audio engine contains a virtual rack
  9. where unlimited audio buses can be created and, on each of it, unlimited
  10. amount of effect processors can be added (or more like, as long as your
  11. CPU holds up!)
  12. The implementation in Godot is pretty efficient and has been written
  13. entirely from the ground up, without relying on any existing audio libraries.
  14. Even the effect processors were written exclusively for Godot (save for
  15. the pitch shifting library), with games in mind. This allows
  16. a efficient tradeoff between performance and sound quality.
  17. Decibel Scale
  18. -------------
  19. The new audio engine works primarily using the decibel scale. We have
  20. chosen this over linear representation of amplitude because it's
  21. more intuitive for audio professionals.
  22. For those unfamiliar with it, it can be explained with a few facts:
  23. * The decibel (dB) scale is a relative scale. It represents the ratio of sound power by using 10 times the base 10 logarithm of the ratio (10×log\ :sub:`10`\ (P/P\ :sub:`0`\ )).
  24. * For every 3dB, sound doubles or halves. 6dB represents a factor 4, 9dB a factor 8, 10dB a factor 10, 20dB a factor 100, etc.
  25. * Since the scale is logarithmic, true zero (no audio) can't be represented.
  26. * 0dB is considered the maximum audible volume without *clipping*. This limit is not the human limit but a limit from the sound hardware. Your sound output simply can't output any sound louder than 0dB without distorting it (clipping it).
  27. * Because of the above, your sound mix should work in a way where the sound output of the *Master Bus* (more on that later), should never be above 0dB.
  28. * Every 3dB below the 0dB limit, sound energy is *halved*. It means the sound volume at -3dB is half as loud as 0dB. -6dB is half as loud as -3dB and so on.
  29. * When working with decibels, sound is considered no longer audible between -60dB and -80dB. This makes your working range generally between -60dB and 0dB.
  30. This can take a bit getting used to, but it's friendlier in the end and will allow you to communicate better with audio professionals.
  31. Audio Buses
  32. -----------
  33. Audio buses can be found in the bottom panel of Godot Editor:
  34. .. image:: img/audio_buses1.png
  35. An *Audio Bus* bus (often called "Audio Channels" too) is a device where audio is channeled. Audio data passes through it and can be *modified* and *re-routed*. A VU-Meter (the bars that go up and down when sound is played) can measure the loudness of the sound in Decibel scale.
  36. The leftmost bus is the *Master Bus*. This bus outputs the mix to your speakers so, as mentioned in the item above (Decibel Scale), make sure that your mix rarely or never goes above 0dB in this bus.
  37. The rest of the audio buses are used for *routing*. This means that, after modifying the sound, they must send it to another bus to the left. Routing is always from right to left without exception as this
  38. avoids creating infinite routing loops!
  39. .. image:: img/audio_buses2.png
  40. In the above image, *Bus 2* is routing its output to *Master* bus.
  41. Playback of Audio to a Bus
  42. --------------------------
  43. To test playback to a bus, create an AudioStreamPlayer node, load an AudioStream and select a target bus for playback:
  44. .. image:: img/audio_buses3.png
  45. Finally toggle the "playing" property to on and sound will flow.
  46. To learn more about *Audio Streams*, please read the related tutorial later! (@TODO link to audio streams tute)
  47. Adding Effects
  48. --------------
  49. Audio buses can contain all sorts of effects. These effects modify the sound in one way or another and are applied in order.
  50. .. image:: img/audio_buses4.png
  51. Following is a short description of available effects:
  52. Amplify
  53. ~~~~~~~
  54. It's the most basic effect. It changes the sound volume. Amplifying too much can make the sound clip, so be wary of that.
  55. BandLimit and BandPass
  56. ~~~~~~~~~~~~~~~~~~~~~~
  57. These are resonant filters which block frequencies around the *Cutoff* point. BandPass is resonant, while BandLimit stretches to the sides.
  58. Chorus
  59. ~~~~~~
  60. This effect adds extra voices, detuned by LFO and with a small delay, to add more richness to the sound harmonics and stereo width.
  61. Compressor
  62. ~~~~~~~~~~
  63. The aim of a dynamic range compressor is to reduce the level of the sound when the amplitude goes over a certain threshold in Decibels.
  64. One of the main uses of a compressor is to increase the dynamic range while clipping the least possible (when sound goes over 0dB).
  65. Compressor has may uses in the mix, for example:
  66. * It can be used in the Master bus to compress the whole output (Although a Limiter is probably better)
  67. * It can be used in voice channels to ensure they sound as even as possible.
  68. * It can be *Sidechained*. This means, it can reduce the sound level using another audio bus for threshold detection. This technique is
  69. very common in video game mixing to download the level of Music/SFX while voices are being heard.
  70. * It can accentuate transients by using a bit wider attack, meaning it can make sound effects sound more punchy.
  71. There is a lot of bibliography written about compressors, and Godot implementation is rather standard.
  72. Delay
  73. ~~~~~
  74. Adds an "Echo" effect with a feedback loop. It can be used, together with Reverb, to simulate wide rooms, canyons, etc. where sound bounces are far apart.
  75. Distortion
  76. ~~~~~~~~~~
  77. Adds classical effects to modify the sound and make it dirty. Godot supports effects like overdrive, tan, or bit crushing.
  78. For games, it can simulate sound coming from some saturated device or speaker efficiently.
  79. EQ6, EQ10, EQ21
  80. ~~~~~~~~~~~~~~~
  81. Godot provides three model of equalizers with different band counts. Equalizers are useful on the Master Bus to completely master a mix and give it character. They are
  82. also useful when a game is run on a mobile device, to adjust the mix to that kind of speakers (it can be added but disabled when headphones are plugged).
  83. HighPassFilter, HighShelfFilter
  84. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  85. These are filters that cut frequencies below a specific *Cutoff*. A common use of high pass filters is to add it to effects (or voice) that were recorded too close too a mic and need
  86. to sound more realistic. It is commonly used for some types of environment like space.
  87. Limiter
  88. ~~~~~~~
  89. A limiter is similar to a compressor, but it's less flexible and designed to disallow sound going over a given dB threshold. Adding one in the *Master Bus* is always recommended
  90. to reduce the effects of clipping.
  91. LowPassFilter, LowShelfFilter
  92. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. These are the most common filters, they cut frequencies above a specific *Cutoff* and can also resonate. They can be used for a wide amount of effects, from underwater sound to simulating
  94. a sound coming from far away.
  95. NotchFilter
  96. ~~~~~~~~~~~
  97. The opposite to the BandPassFilter, it removes a band of sound from the frequency spectrum at a given *Cutoff*.
  98. Panner
  99. ~~~~~~
  100. This is a simple helper to pan sound left or right.
  101. Phaser
  102. ~~~~~~
  103. It probably does not make much sense to explain that this effect is formed by two signals being dephased and cancelling each other out.
  104. It will be sufficient to note that you can make a Darth Vader voice with it, or jet-like sounds.
  105. PitchShift
  106. ~~~~~~~~~~
  107. This effect allows for modulating pitch independently of tempo. All frequencies can be increased/decreased with minimal effect on transients. Can be used for effects such as voice modulation.
  108. Reverb
  109. ~~~~~~
  110. Reverb simulates rooms of different sizes. It has adjustable parameters that can be tweaked to obtain the sound of a specific room. Reverb is commonly outputted from Areas (@TODO LINK TO TUTORIAL WHEN DONE), or
  111. to apply chamber feel to all sounds.
  112. StereoEnhance
  113. ~~~~~~~~~~~~~
  114. This effect has a few algorithms available to enhance the stereo spectrum, in case this is needed.
  115. Automatic Bus Disabling
  116. -----------------------
  117. There is no need to disable buses manually when not in use, Godot detects that the bus has been silent for a few seconds and disable it (including all effects).
  118. .. image:: img/audio_buses5.png
  119. Bus Rearrangement
  120. -----------------
  121. Stream Players use bus names to identify a bus, which allows adding, removing and moving buses around while the reference to them is kept.
  122. If a bus is renamed, however, the reference will be lost and the Stream Player will output to Master. This system was chosen because rearranging buses is a more common process than renaming them.
  123. Default Bus Layout
  124. ------------------
  125. The default bus layout is automatically saved to the "res://default_bus_layout.res" file. Other bus layouts can be saved/retrieved from files in case of having
  126. to change snapshots, but in most cases this is not necessary.