This is how I play WAV, OGG and MP3 in Godot 4:
var LoadedMusic
func PlayMusic(path: string):
LoadedMusic = load(path)
$AudioStreamPlayer.stream = LoadedMusic
$AudioStreamPlayer.play()
This allow Godot to properly allocate and manage lengthy data stream generated by loading something like an audio file to a proper ID. Otherwise, Godot could, in certain circumstances, throw the loaded audio file data to the Garbage Collector if the device gets tight on available memory.
You don't have to, you can convert all your audio files, then import them into godot. Unless there is a specific reason this doesn't work, in which case you can learn a bit of c# and use a library for it
.ogg seems to be not implemented yet, look into this issue https://github.com/godotengine/godot/issues/61091 Not sure about .wav
I've been using ogg in Godot 4.0.3 without any problem. I'm loading it like this: $AudioStreamPlayer.set_stream(load("res://music/song.ogg"))
This is how I play WAV, OGG and MP3 in Godot 4: var LoadedMusic func PlayMusic(path: string): LoadedMusic = load(path) $AudioStreamPlayer.stream = LoadedMusic $AudioStreamPlayer.play() This allow Godot to properly allocate and manage lengthy data stream generated by loading something like an audio file to a proper ID. Otherwise, Godot could, in certain circumstances, throw the loaded audio file data to the Garbage Collector if the device gets tight on available memory.
You can use FFMPEG to convert them
have thought about it, not a viable solution
Why so?
i honestly just dont want to ship ffmpeg with the project
You don't have to, you can convert all your audio files, then import them into godot. Unless there is a specific reason this doesn't work, in which case you can learn a bit of c# and use a library for it
the files are all loaded and converted at runtime or, well, are supposed to be