Using FFI array renders dysfunctional
Posted: Sat Nov 12, 2022 12:06 am
I'm making some sort of audio processing thing. I have an array containing the FFT transform. I'm trying to make this array an FFI array instead of a table for potential performance gains.
This is the code that declares the tables, starting from main.lua:26:
If you switch data_l and data_r to use the FFI array, the output signal becomes garbled. For the past hour, I've struggled to understand why this happens. I've made sure to treat the array as 0-indexed, and it processes the data the same way regardless of if it's an FFI pointer or a table, and yet it only works if it's a table.
I've attached the project zip. (Keep your volume down)
This is the code that declares the tables, starting from main.lua:26:
Code: Select all
-- using ffi arrays don't work, however using Lua tables does
--local data_l = ffi.new("lua_complex["..(RESOLUTION).."]")
--local data_r = ffi.new("lua_complex["..(RESOLUTION).."]")
local data_l = {}
local data_r = {}
I've attached the project zip. (Keep your volume down)