Absolute file paths

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
opatut
Prole
Posts: 7
Joined: Mon Feb 20, 2012 2:34 pm

Absolute file paths

Post 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
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Absolute file paths

Post 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.
Shallow indentations.
opatut
Prole
Posts: 7
Joined: Mon Feb 20, 2012 2:34 pm

Re: Absolute file paths

Post 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.
opatut
Prole
Posts: 7
Joined: Mon Feb 20, 2012 2:34 pm

Re: Absolute file paths

Post 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.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: Absolute file paths

Post by Boolsheet »

Ah. I thought one of the functions takes Data objects. It looks like they don't, sorry.
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 2 guests