Recently I was developing a game on godot 3.5.2 and encountered a problem: on weak devices, when exporting a project, sound artifacts such as crackling or clicking were heard. After reading several discussions on the forum, I realized that this is a very common problem. I decided to write a simple plugin to fix this bug by using the external Howler.js library which ensures that all sounds work well on all platforms.
The plugin only works for building in HTML 5, add
audiofix in the custom properties when building.
AudioFix.playAudio(filePath, volumeDB, loop) launches an audio file (mp3, ogg, wav, etc.). Please note that you do not need to add sounds to the Godot project itself, add them after exporting the project, for example you can create an audio folder, then the call will look something like this AudioFix.playAudio("audio/MainOst.ogg", 0.0, true).
AudioFix.stopAllAudio() completely ends all running sounds.
AudioFix.IncrementGlobalVolume(volumeChangeDB, fade) function to increase the sound, please note that this is not setting the sound to a specific value, but simply increasing it. To turn off the sound, use AudioFix.IncrementGlobalVolume(-100.0, 10), to enable AudioFix.IncrementGlobalVolume(100.0, 10) here the argument is 10 (in milliseconds) controls the smoothness of the transition.
Also, this plugin has already been added with the function of turning off the audio stream when going to another page, this is required by moderators of some browser gaming platforms, if you don’t need it, you can remove it from the audio_fix.js file.