+1 vote

i try to make an app who does loading audio files (wav) from a folder located outside the res://... without success.

I imagine that is true for other types of files.

the error remains:

No loader found for resource: C:/..../.../... .wav(path)

How to fix this or bypass the bug ? anyone ?

in Engine by (111 points)

2 Answers

+2 votes
Best answer

You have to create an AudioStreamSample and set some properties that have to match your file.

var audio = "path to your file"

func load_audio_from_user_dir():
    var file = File.new()
    if file.file_exists(audio):
        file.open(audio, file.READ)
        var buffer = file.get_buffer(file.get_len())
        var stream = AudioStreamSample.new()
        for i in 200:
            buffer.remove(buffer.size()-1) # removes pop sound at the end
            buffer.remove(0)
        stream.data = buffer
        stream.format = 1 # 16 bit
        stream.mix_rate = 44100
        stream.stereo = true
        file.close()
        $AudioStreamPlayer.stream = stream

I'm not sure why but when loading a sample this way, it has a click/pop sound at the end. The for loop seems to fix that.

Edit: I noticed that some samples have the click/pop sound also at the start, so I added a second line to the for loop.

by (1,468 points)
selected by

Genial Adam_S ! this is exactly what i was looking.. desperately !
with this, dont need an import file, it just play the sound !

one more note, we can also add some more parameters to the sample, very useful:

stream.loop_mode (bool)
stream.loop_begin (int)
stream.loop_end (int)

AudioStreamSample doc (3.1.1): link

0 votes

The only thing that comes to my mind is creating a symlink.
On windows you need to go to terminal as admin
(WIN, search for "cmd" > "run as admin")
and create a symlink using "MKLINK" tool/command. basically you just need to provide a path of original file and where you want it to appear. so Godot can see it as if it was inside res:// folder

by (29 points)

hi, thanks for your answer.. but.. but :) i want the user to be able to load his own audio files, i cannot ask the user to run the terminal :D

how this can happend ? the import feature is in any app that works with audio or image... cannot we make this kind of app with godot ?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.