How to compile a lua library that is compatible with SV?
I have a .c
code and I’m trying to compile it into a .dll
library, then require
it in my lua scripts for SV.
Currently there’s no difficulty in requir
ing. Simply put any .lua
or .dll
under the same directory where your synthv-studio.exe
is located, and scripts will be able to require them. (See this post for reference.)
I can compile the code using pre-compiled dev packs from lua’s official download, but the result is not compatible with SV, giving an “error loading module
” error. I suspect it’s due to the mismatch of compiler versions between my compiled dll and SV’s lua core. I just tried one among the 4 different compiler versions provided by the official download. But I don’t really want to mess more with multiple compiler versions on my laptop, and I’m not even sure if SV’s lua core is compiled by one of these compilers.
So does anybody have any clue about this? And it will be very nice if you’d like to test out those 4 compilers. Of course, it would be the best if SV developers pop up and reveal some information or improve their scripting system (there’re so many feature requests about scripting but sadly none of them are answered), but I can hardly expect that to happen.
Also I may have missed something since I’m quite new to lua. Do you have any related experience?
How to support utf-8 filenames?
In particular, I’m trying to patch @hataori’s Real Voice scripts to support utf-8 filenames (which is really an important QoL issue when making Japanese or Chinese songs etc., and does have been requested by a few people). (Also a shout-out to Real Voice scripts!)
It’s a rather intrinsic issue because lua doesn’t care about encoding (because of lua’s philosophy of simplicity) and that lua sticks to ANSI C APIs, among which functions like fopen
are very poor with utf-8. Solutions I found are either modifying lua core like lua-unicode (obviously not a viable way for us), or writing a C module like luawinfile. So I choose the latter and use something like
if package.config:sub(1,1) ~= '/' then -- check if it's Windows
local winfile = require("winfile")
io.open = winfile.open
end
So here I am, trying to compile this winfile.c
into winfile.dll
to use in SV scripts.
If you have any ideas on how to support utf-8 filenames, it would be very very nice and can solve all these problems!
And I’m also happy to discuss anything related to scripting in this thread.