Repository: godot
Issue: Audio clipping / static / interference on rapid intervals of sound (fixed in `master`)
Labels: bug,confirmed,topic:audio

**Godot version:**
3.1 alpha


**OS/device including version:**
Kubuntu 18.04 and Windows 10


**Issue description:**
Creating a rapidly firing weapon, if sounds are played at intervals less than 0.5 or 0.6 seconds there is a clipping or static sound.

Demo: https://www.dropbox.com/s/q5tx4y6272lgdae/2018-09-12%2017-16-00.mp4?dl=0

Improvement can come from modifying sound files with fade in and fade out at either end, but the issue is still present.

Demo: https://www.dropbox.com/s/hnvlu161x1t62fl/secondtest.mp4?dl=0

In the case of testing with a sine wave sound file, instead of clipping / static there is a sort of interference or modulation sound instead.

Demo: https://www.dropbox.com/s/nd2rcsrdrqxo6sd/2018-09-12%2021-19-52.mp4?dl=0

The clipping / static sound can seemingly be eliminated by setting a LowPassFilter and LowShelfFilter on a sound bus, both with a cutoff of 1000Hz.

These filters don't eliminate the modulation type of sound that comes up when using a sine testing sound.


**Steps to reproduce:**
Create a timer with an interval of about 0.3 seconds and have either a single sound repeat at that interval, or rotate between two different sounds.

Issue present in the editor on Linux and Windows, in builds for Linux and Windows, on 2 PCs in my house, through 3 headphone sets and two speaker sets. Also verified by another user who tested on 2 of their headphone sets.

**Minimal reproduction project:**
[SoundTesting.zip](https://github.com/godotengine/godot/files/2377320/SoundTesting.zip)

**Tests and attempted solutions that didn't help**
Before trying the filters, I also tried:
* Having an AudioStreamPlayer2D as a child of each instantiated missile (this made the effect worse)
* Having the Player character scene play a sound from a child AudioStreamPlayer or AudioStreamPlayer2D
* Creating two child AudioStreamPlayers and alternating between playing one or the other, using the same sound
* Alternating between those two child nodes, but playing two different sounds
* Creating a stand alone scene with an AudioStreamPlayer in it, and instantiating it newly and adding it as a child each time
* Outputting the sound from the two child AudioStreamPlayers to different audio buses
* All three different mix target options
* Reducing volume - tested at -2Db, -4Db, -6Db
* Tested with 9 sound files
* Modified a sound effect with fade in and fade out processing to ensure no clicking in the file itself
* Tried reducing the duration of the sound file to 0.3 seconds, but still had the static effect at intervals of 0.5 seconds or less
* Trying with different sound playback hardware
* Tested on Linux and two installations of Windows
* Tested on 2 PCs
* Tested in editor and in Linux and Windows builds (Windows builds tested on two PCs)


**Extra information**

I spent a few hours with the helpful folks at the Godot discord last night going through various test to try and isolate the source of the clipping / interference sounds. Our tests did lead us to believe it wasn't an issue localized to my setup alone.

Different people heard different effects from the videos and test project above. Some heard clipping / static on every sound, some heard none at all. One other person heard it as clearly as I did, and confirmed the same on two of their headphone sets.

@starry-abyss had the theory it was something to do with too many high frequency sounds at once, hence we tried the low pass / shelf filters which eliminated the clipping / static sounds.

Given the effect of the filters I'm not sure this is actually an issue as opposed to a sound management technique being required. 

If we can confirm this is just about handling sound in a certain way, perhaps I can contribute to the docs with some information for people in the future who run into this problem.