Page 1 of 1
Absolute file paths
Posted: Sun Aug 26, 2012 12:36 pm
by opatut
Hey guys,
I am making a
framework where people can build custom audio visualizers in Löve. I want them to be able to load up their own audio file, i.e. run
Code: Select all
love visualove.love /path/to/audio/file.mp3
and have it played. It seems like love.filesystem does not support absolute paths, neither did I find a way to wrap a userdata object (from io.open) into a Love File Object, which I need to decode the audio. Is there any workaround for this, or do I have to request something similar to be implemented in Löve? I just want to bypass the PhysFS.
Thanks
- opatut
Re: Absolute file paths
Posted: Sun Aug 26, 2012 2:13 pm
by Boolsheet
opatut wrote:It seems like love.filesystem does not support absolute paths
That is correct.
opatut wrote:neither did I find a way to wrap a userdata object (from io.open) into a Love File Object
You can do that with
love.filesystem.newFileData.
Code: Select all
love.filesystem.newFileData(myData, "myAudio.mp3", "file")
The mp3 extension in the file name is important in this case.
Re: Absolute file paths
Posted: Sun Aug 26, 2012 4:44 pm
by opatut
Thanks. Problem is, who do I get that FileData through the Decoder and SoundData into the SoundSource? The Decoder won't accept userdata, only filenames or Löve files. And love's FileData is not a 'File' object.
I thought I could do this:
io.open -> love.FileData -> love.File -> love.audio.Decoder -> love.audio.SoundData -> love.sound.Source
but apparently I cannot create a love.File from memory.
Re: Absolute file paths
Posted: Sun Aug 26, 2012 4:54 pm
by opatut
I even tried copying the metatable from a love.File to my file userdata - but well, that is not allowed from Lua:
http://lua-users.org/lists/lua-l/2004-06/msg00647.html
I will try to solve it by copying the file to my ~/.local/share/love/ directory via io, then loading it via PhysFS... hope that works.
Re: Absolute file paths
Posted: Sun Aug 26, 2012 4:57 pm
by Boolsheet
Ah. I thought one of the functions takes Data objects. It looks like they don't, sorry.