-psycledelics- (http://psycle.pastnotecut.org/index.php)
|- TECH BOARD (http://psycle.pastnotecut.org/board.php?boardid=2)
|-- LuaScript questions (http://psycle.pastnotecut.org/threadid.php?boardid=2&threadid=3039)


From luadev on 29.12.2014, 07:28:

 

sorry, the "carry method" must be:


code:

function machine:carry(num, input, output, outputprev)
-- work num samples and create carry
-- [{start, end}] creates a new sub array with a copy from start to end
local carry = outputprev[{num, outputprev:size()}]
outputprev:resize(num)
self:partwork(num, input, output, outputprev)
local outputprevnew = carry..outputprev
outputprev:resize(outputprevnew:size())
outputprev:copy(outputprevnew)
end



__________________
42 PRINT"42":REM A FOR ALL Q 43 GOTO 42:REM FIND Q FOR A


From Angelus on 01.01.2015, 17:34:

 

luadev: Thanks for your teachings. I'm learning a lot with your examples (I'm archiving all of them into my Lua tutorials folder). As a result, I'm using Lua to implement code from others instead of embedding native plugins to go further.

One example is a simply low pass filter I've found out there originally by apple.com AU tutorials. Please CLICK HERE TO DOWNLOAD the zipped file containing the script and a test psy song (just a whitenoise generator, don't expect any top-hit).

This script works as it should but it's a system resource-eating monster (85-110% CPU). It needs to process each sample instead the whole buffer because it's necessary to know the previous output sample.

As Lua is supposed to be (only) 1.7 times slower than C++, is there any way to do it for use in real-time?

Thanks in advance.


__________________

(???)Oo. X( :( :| :) :)) :D .cC(Psycle!)


From luadev on 02.01.2015, 14:36:

 

As described in chapter 3.1 of the lua scripting manual,
breaking the borders between c++ and the script by importing and exporting functions is quite expensive. That's why we try to offer many block and some prewritten modules in C, to minimize these calls. If you need a Lowpass filter, you can use the "psycle.dsp.filter" module.
This module allows you to use the internal psycle filter, which is used by sampulse and other internal machines.

filter = require("psycle.dsp.filter")
f1 = filter:new(filter.LOWPASS) -- or HIGHPASS, BANDPASS,
-- BANDREJECT, NONE, ITLOWPASS

f1:setcutoff(val) : 0 .. 127 sets the Frequency
f1:setresonance(val) : 0..127 sets the resonance

f1:work(buffer)

Jaz has recently implemented some new filter types, which will be available in the next release.


__________________
42 PRINT"42":REM A FOR ALL Q 43 GOTO 42:REM FIND Q FOR A


From Angelus on 02.01.2015, 19:15:

 

Thanks again luadev. I'd already read that chapter but I've wanted to know if there could be another way to perform this kind of process in Lua that I hadn't notice. Anyway it was interesting for educational purposes.


__________________

(???)Oo. X( :( :| :) :)) :D .cC(Psycle!)


From luadev on 05.01.2015, 01:32:

 

There's a speed bug in the current 1.12.0 version with indexing psycle arrays. Unfortunatley the array range check creates a string for the range error message even if the array range is valid. That leads to the bad speed behaviour. In my tests on a an amd quad core (2,4 ghz), your LPF Filter has around 7 percent cpu usage. Sorry for that! I'll fix it in the next release.


__________________
42 PRINT"42":REM A FOR ALL Q 43 GOTO 42:REM FIND Q FOR A


From Angelus on 07.01.2015, 12:20:

 


Nice to know that it works more efficiently. Thanks for your work.

I'm trying now to use lua to load dll's coded with its libraries through package.loadlib in VS C++ 2005. Right now I'm having problems with dependencies (depends.exe tells me that all is Ok). I'll keep you informed.


__________________

(???)Oo. X( :( :| :) :)) :D .cC(Psycle!)


From Angelus on 18.01.2015, 14:53:

 

Hi again.

I come back here as I've couldn't been able to get a working dll to be called by lua from Psycle.

I've coded an easy dll to perform 2 basic operations like add and subtract, and a test script to perform function calls. I've uploaded a zipped folder with the elements to perform a test (CLICK HERE TO DOWNLOAD. The pack contains a lua script (not Psycle compliant, just one to be executed by an editor like ZeroBrane -the one I'm using-) to perform dll function calls and show returns, the dll itself, the needed lua52.dll, and a folder with the dll c++ source file.

The dll module is loaded correctly but I've got problems when I call an internal function. ZeroBrane reports me a basic Lua error: ''attempt to index local 'cfunctions' (a function value)''.

I've googled and performed different approaches I've found out there without success. I've tried different IDE like VC2005 or CodeBlocks, too.

Is in my code something wrong that I'm not seeing?

Loading user dynamic libraries could break the limitations of Lua against C/C++. Thanks in advance.


__________________

(???)Oo. X( :( :| :) :)) :D .cC(Psycle!)


From luadev on 20.01.2015, 12:48:

 

I've never tried package.loadlib before, but i took a look at your dll. I removed "lua_setglobal(L, "luaDLL");" and opened it with tbl = cfunctions(). There's an error then : "multiple lua vms detected". The problem with this is, we have statically linked lua to psycle, but in the dll you try to link it against lua51.lib and the lua52.dll. This means, to get it work either you manage a link to psycle.exe (dunno if that's possible) or we have to change psycle's lua linking to dynamic libray, so you could use the same dll, psycle would use. But maybe you can find out more on this issue?
Another problem is, that soon we will upgrade to lua 5.3 and these c dlls may not be compatible anylonger.


__________________
42 PRINT"42":REM A FOR ALL Q 43 GOTO 42:REM FIND Q FOR A

Powered by: Burning Board 1.0 Beta 4.5eEnglish Translation by AnnaFan
Copyright © 2001 by WoltLab