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 i want the user to be able to load his own audio files, i cannot ask the user to run the terminal
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 ?
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: