Page 1 of 1

[11.3] Decoding sound data from the byte string

Posted: Thu Aug 26, 2021 12:29 pm
by Shuriken255
I was searching on the wiki on how to initialize the SoundData from the byte string that represents the OGG file but could not find any information about it. I am looking for something like this (but for OGG byte string):

Code: Select all

local data = love.data.newByteData(pngStr);
local img = love.graphics.newImage(data);

Is there a posible way to load SoundData like that?

Code: Select all

local data = love.data.newByteData(oggStr);
local sndData = love.sound.newSoundData(data); -- Crash (expected filename, File or FileData expected)
Is there any way to load sound data from string (easy or not)?

Re: [11.3] Decoding sound data from the byte string

Posted: Thu Aug 26, 2021 12:43 pm
by slime
You can put the string into a FileData via the love.filesystem.newFileData variant which accepts a string + (fake) filename combination. The filename can be anything as long as it has .ogg extension at the end.

Re: [11.3] Decoding sound data from the byte string

Posted: Thu Aug 26, 2021 12:54 pm
by Shuriken255
slime wrote: Thu Aug 26, 2021 12:43 pm You can put the string into a FileData via the love.filesystem.newFileData variant which accepts a string + (fake) filename combination. The filename can be anything as long as it has .ogg extension at the end.
OMG, it worked! Thank you very much, Slime! The solution is much more simple than i expected it to be. :awesome: