How to encode and send a remote wav file to Godot

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

I want to send a wav file to my project. I tried encoding the wav using base64_encode(file_get_contents()) which created a base64 string that I can pass successfully to Godot I tried to decode and create a new stream

var buffer = PoolByteArray() # Array that will hold the data.
var file = base64String
buffer = Marshalls.base64_to_raw(file)
var stream =
stream.format = AudioStreamSample.FORMAT_16_BITS = buffer
stream.stereo = true = stream

But sadly that doesn’t produce the audio that is being sent. Does anyone knows how to implement this?

did you set stream.mix_rate (for example 44100)?

you can also skip the first 44 bytes of the wav file as that contains the wav headers = buffer.subarray(44,buffer.size()-44)

I haven’t tried with base64 encoded data but got it working with pure binary

pm101 | 2020-09-25 02:42