[11.3] Decoding sound data from the byte string

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Shuriken255
Prole
Posts: 2
Joined: Tue Feb 27, 2018 12:48 am
Location: Kyiv, Ukraine
Contact:

[11.3] Decoding sound data from the byte string

Post 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)?
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

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

Post 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.
User avatar
Shuriken255
Prole
Posts: 2
Joined: Tue Feb 27, 2018 12:48 am
Location: Kyiv, Ukraine
Contact:

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

Post 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:
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 48 guests