+1 vote

I want to send a wav file to my project. I tried encoding the wav using base64encode(fileget_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 = AudioStreamSample.new()

stream.format = AudioStreamSample.FORMAT_16_BITS
stream.data = buffer
stream.stereo = true

audioStreamPlayer.stream = stream

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

in Engine by (20 points)

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

stream.data = buffer.subarray(44,buffer.size()-44)

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

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.