Skip to content

How to load a ma_sound with raw bytes? #819

Answered by bovacu
bovacu asked this question in Q&A
Discussion options

You must be logged in to vote

For anyone with the same problem, I figured it out after a loooong day, this is how I fixed it. I was calculating wrongly the sizeInFrames and also sending a wrong formated bytes as the data for ma_audio_buffer_config_init .

I first needed to do:

ma_uint64 _size_in_frames = 0;
void* _frames_out = NULL; uint _channels = ma_engine_get_channels(&ENGINE.audio_engine); 
ma_format _format = ma_format_f32; 
ma_decoder_config _decoder_config = ma_decoder_config_init(_format, _channels, 48000); 
ma_result _decode_memory_res = ma_decode_memory(_bytes, _size, &_decoder_config, &_size_in_frames, &_frames_out);

Which eventually got me both correct sizeInFrames and the bytes correctly formatted.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bovacu
Comment options

Answer selected by bovacu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant