- 1. Add the new C functions to the Love2D code itself (and have recompile it for each platform I plan to release on - which will be at least a few).
2. Compile the new C functions into a DLL, and call them using something like LuaJIT FFI. (I expect this would still require compiling the DLL on each platform.)
3. Write the new C functions as video shaders. This makes some sense as it would do away with having to recompile anything, and should be platform-independent, and I also like the idea of unloading some processing to the video card. But I wonder how efficient it would be to have to send all the incoming data to the video card.
Crunching Numbers
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Crunching Numbers
Hi! I'm looking for recommendations from more experienced Love2D users than I. My project requires processing a fairly large amount of incoming data in real-time (audio signal processing, to be specific). I've already written the core processing functions in C/C++, and I don't think rewriting them in Lua would be a great idea, performance-wise. So, three options have occured to me:
Last edited by Dr. Peeps on Mon Oct 17, 2016 4:44 am, edited 1 time in total.
Re: Crunching Numbers
I mean, my inclination is toward 4. Rewrite them in Lua, using FFI data structures. The performance impact will likely be less than you think.
Alternatively, I would lean toward 2. Encoding data into into a texture to mimic GPGPU just tends to be slightly more of a pain in the ass than cross platform C++ compilation is. Assuming you have no dependencies besides Lua, it should even be relatively straightforward. Here's a project I made that I know works on OSX, Linux and Windows and links against Lua. https://github.com/TannerRogalsky/lua-p ... eLists.txt
Alternatively, I would lean toward 2. Encoding data into into a texture to mimic GPGPU just tends to be slightly more of a pain in the ass than cross platform C++ compilation is. Assuming you have no dependencies besides Lua, it should even be relatively straightforward. Here's a project I made that I know works on OSX, Linux and Windows and links against Lua. https://github.com/TannerRogalsky/lua-p ... eLists.txt
Re: Crunching Numbers
You're forgetting LÖVE uses LuaJIT which compiles code to native instructions, and using FFI data structures eliminates much of the overhead associated with table lookups and weakly typed variables management.
Re: Crunching Numbers
Not so much forgetting ... I didn't even know that LuaJIT was now the default. And I haven't tried using FFI data structures yet.raidho36 wrote:You're forgetting LÖVE uses LuaJIT which compiles code to native instructions, and using FFI data structures eliminates much of the overhead associated with table lookups and weakly typed variables management.
Thanks guys - this is exactly the sort of answer I was looking for.
EXCEPT ... I just read that JIT compilation is disabled on iOS and Android (and consoles), meaning the code would run much slower on mobile devices - the devices where the optimization would be the most critical. I'm not sure this solution will be ideal for me, but I'll try it before I knock it.
- zorg
- Party member
- Posts: 3444
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Crunching Numbers
Then again, raidho forgets to mention that the next version will include his awesome contribution of queueable source objects, that can be used for realtime audio processing purposes... i should know, i've been previously using the FFI "version" of it for just that purpose.
You can already get minor builds, for windows at least.
That said, you didn't really detail just how much crunching you want to do, so it still might be too slow if you wrote it in lua, but who knows.
You can already get minor builds, for windows at least.
That said, you didn't really detail just how much crunching you want to do, so it still might be too slow if you wrote it in lua, but who knows.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Who is online
Users browsing this forum: No registered users and 120 guests