Preloading an ogg audio that is muted

Godot Version

4.5.1

Question

I'm preloading an ogg audio by instancing it on the root of the scene with very low volume and stream_paused = true so that when the audio is played in the future, there will be no lag spikes. However, I hear a very short burst of audio even if the volume is very low and stream is paused. Anyone knows a solution to this?

I can’t seem to recreate it, this works for me:

Using v4.5.1.stable.official [f62fdbde1], Windows 11 WASAPI

Then it must be a Linux and HTM5 thing. I experience this on both Linux and HTML5.

While this is likely a bug, I’m sure there’s a way to work around it. do you mind sharing your code so we can see what the issue is? NoNormal recreated the code based on your description, but seeing your original code would be handy.

Here’s the code that I use to preload an ogg audio:

extends AudioStreamPlayer3D

var stream_path:String

func _ready() -> void:
	stream = load(stream_path)
	volume_db = -80.0
	stream_paused = true

And the AudioStreamPlayer3D’s “Autoplay” property is unchecked

Okay, your code doesn’t seem to have a point of failure. Only thing I can suggest is maybe setting stream_paused = true before stream = load(stream_path). This should make it so even if there’s a delay for some reason, the audio should load in while paused.

Almost a year ago I ran into an issue where some variables set in _ready() weren’t coming into effect until the frame after _ready() was called, and I’m wondering if this is the same issue. I never found a fix for this, and left the project. My issue also came down to loading in objects, albeit I was loading in scenes, and trying to change their position.

One possible fix for your case is to try my scene approach yourself. Set up the AudioStreamPlayer3D manually with the audio turned off in a separate scene, then instantiate that scene where you’d normally load an audio stream.

Thanks for your reply. I finally found the bug. It was nothing to do about this preload thing at all. I just had some non-preload function that got mixed up inside the function that’s supposed to be preload-only. Hence there is a popping sound.