|
|
|
|
Reply From: |
Bartosz |
Update:
It is possible to load ogg and wav files during runtime by setting data
format``stereo
properties of appropriate audiostream object demo for stereo wav:
var file = File.new()
var stream
if file.file_exists(audio_file):
file.open(audio_file, file.READ)
var buffer = file.get_buffer(file.get_len())
stream = AudioStreamSample.new()
stream.format = AudioStreamSample.FORMAT_16_BITS
stream.data = buffer
stream.stereo = true
file.close()
old answer:
It looks like this is not possible for now.I’ve created an issue at official repository, if it became resolved I’ll update answer.
I still get the same error.
However, thank you for your answers. So you think that this is the right way and it should be possible to load from user://…
Sorry, I misinformed you - check my updated answer.
Bartosz | 2018-03-24 22:23
Ok, thank you for your help.
I was hoping I could do most of the stuff from GDScript/GDNative, but I’ll anyway have to create a C++ module for my other required features.
I think I’ll create a custom AudioStream/AudioStreamPlayback that will directly supply mic input to the AudioStreamPlayer. The stream could already save/load audio data as raw pcm.
I’ve asked another question here - I would like to get the processed output once audio effects have been applied. Could you please look at that one too? I don’t think it will be possible from GDScript, but I at least would like to find strategies how to do it from C++ module.
I’ve started learning Godot only few weeks ago so unfortunately I’m not familiar enough with engine c++ implementation to help with yours outher question.
Bartosz | 2018-03-25 13:17
after all it is possible to load audio files at runtime using gdscript. check updated answer
Bartosz | 2018-03-26 22:13
Perfect, now it works. I just had to strip the wav header, and then it worked.
Thanks again
Hello, i´m struggling with your same problem, your code works great but i noticed that it only works with some kind of wav files (the ones with a bit rate of 1411 kbps). Other files (higher bit rate) are executed as white sound.
Do you know a way to set bit rate in the audiostreamsample?
Andrea | 2018-07-05 10:06
I am able to play the wav by doing this.
However, the result is very distorted and noisy (pitch and duration are correct), whereas the file that is imported using the editor is clean and clear.
The settings are the same, because I compared what they should be from .import file.
Any idea how I can still improve this?
GForce Productions | 2021-12-25 20:20