PSYCLE's home     
     since may 2000
  news / home  files songs boards links all registered members about psycledelics Statistics    
Welcome to -psycledelics-. If this is your 1st visit please read the FAQ - Frequently Asked Questions You must register before you can post here: Please click above on Registration to register yourself. You do not need to register if you only want to read Threads.
Login with Username & Password:

Remember me on this PC.
-psycledelics- Discussions TECH BOARD LuaScript questions
« Previous Thread Next Thread » Show a Printable Version  Send this to a Friend  Add to Favorites
Thread closed
Author
Post [  «    1  2  ]
luadev
Psycler



Date Registered:
12.2014
Location:
Germany
Posts: 11


luadev ist offline
         Go on top to this Page

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

29.12.2014, 07:28 Profile of luadev Add luadev to your Buddy-List Email to luadev
Angelus
Psycler



Date Registered:
09.2002
Location:
Santiago> Galicia> Spain> Europe> Earth
Posts: 415


Angelus ist offline
         Go on top to this Page

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!)

01.01.2015, 17:34 Profile of Angelus Add Angelus to your Buddy-List
luadev
Psycler



Date Registered:
12.2014
Location:
Germany
Posts: 11


luadev ist offline
         Go on top to this Page

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

02.01.2015, 14:36 Profile of luadev Add luadev to your Buddy-List Email to luadev
Angelus
Psycler



Date Registered:
09.2002
Location:
Santiago> Galicia> Spain> Europe> Earth
Posts: 415


Angelus ist offline
         Go on top to this Page

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!)

02.01.2015, 19:15 Profile of Angelus Add Angelus to your Buddy-List
luadev
Psycler



Date Registered:
12.2014
Location:
Germany
Posts: 11


luadev ist offline
         Go on top to this Page

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

05.01.2015, 01:32 Profile of luadev Add luadev to your Buddy-List Email to luadev
Angelus
Psycler



Date Registered:
09.2002
Location:
Santiago> Galicia> Spain> Europe> Earth
Posts: 415


Angelus ist offline
         Go on top to this Page


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!)

07.01.2015, 12:20 Profile of Angelus Add Angelus to your Buddy-List
Angelus
Psycler



Date Registered:
09.2002
Location:
Santiago> Galicia> Spain> Europe> Earth
Posts: 415


Angelus ist offline
         Go on top to this Page

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!)

18.01.2015, 14:53 Profile of Angelus Add Angelus to your Buddy-List
luadev
Psycler



Date Registered:
12.2014
Location:
Germany
Posts: 11


luadev ist offline
         Go on top to this Page

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

20.01.2015, 12:48 Profile of luadev Add luadev to your Buddy-List Email to luadev
[  «    1  2  ]   « Previous Thread Next Thread »
Thread closed
Jump to:

© 2002-2007 psycledelics | Powered by Woltlab Burning Board v1 Beta4.5e ©2001 Woltlab GbR|Setup & mod for psycledelics by: SAS