How to fix the bug #17848 or bypass it, to be able to load resources from any folder other than res://

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By uriel

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 ?

:bust_in_silhouette: Reply From: guba-odudkin

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

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

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 ?

uriel | 2019-09-11 21:22

:bust_in_silhouette: Reply From: Adam_S

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.

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

uriel | 2019-09-12 15:31