[Csnd] csound syntax limitations
Date | 2011-09-03 12:29 |
From | Tarmo Johannes |
Subject | [Csnd] csound syntax limitations |
Sometimes I miss so much arrays, proper loops and ability to use opcode return values in expressions It would be really great to be able to write something like for (icount=0; icount<4; icount++) do if (changed k1 || changed k2) then kamp[icount]= 1/icount a[icount] oscil kamp[icount],440,icount endif endfor ; or whatever outq a[0],a[1],a[2],a[3] I know it can be done with looplt and using tables as array substitution but still, it would be so much more clumsy and cost quite many extra lines. Have you ever had a feeling that the syntax of csound hinders you? Is there hope that the syntax will develop? Like once, I think, if-then came next to if-goto? Or do you have any experience with CsoundAC? Does this would be solution for coding problems? I know very little about supercollider but I have feeling that at least this side can be better there. greetings, tarmo Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-03 12:41 |
From | Victor Lazzarini |
Subject | Re: [Csnd] csound syntax limitations |
you can do something like this with recursive UDOs. Here is a related example: 0dbfs=1 opcode OscBank, a, kkipp kmin,kmax,ifn,ibnd,icnt xin if (icnt >= ibnd) goto bank abnd OscBank kmin,kmax,ifn,ibnd,icnt+1 bank: kfreq = kmin*(kmax/kmin)^((icnt-1)/(ibnd-1)) ao vco2 0.5/ibnd, kfreq amix = ao + abnd xout amix endop instr 1 kmin expseg 570,5,570, p3-10, 25, 5, 26 kmax expseg 560,5,560, p3-10, 12400, 5, 12400 a2 OscBank kmin,kmax, 1, 37 k2 expseg 0.001,0.01,1,p3-1.01,1,1,0.001 out a2*k2 endin On 3 Sep 2011, at 12:29, Tarmo Johannes wrote: > Sometimes I miss so much arrays, proper loops and ability to use > opcode return values in expressions > > It would be really great to be able to write something like > > for (icount=0; icount<4; icount++) do > if (changed k1 || changed k2) then > kamp[icount]= 1/icount > a[icount] oscil kamp[icount],440,icount > endif > endfor ; or whatever > outq a[0],a[1],a[2],a[3] > > I know it can be done with looplt and using tables as array > substitution but still, it would be so much more clumsy and cost > quite many extra lines. > > Have you ever had a feeling that the syntax of csound hinders you? > > Is there hope that the syntax will develop? Like once, I think, if- > then came next to if-goto? > Or do you have any experience with CsoundAC? Does this would be > solution for coding problems? > > I know very little about supercollider but I have feeling that at > least this side can be better there. > > greetings, > tarmo > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-03 13:42 |
From | Victor Lazzarini |
Subject | Re: [Csnd] csound syntax limitations |
Another alternative is to use a k-rate loop and event. Similarly, there are other score-based alternatives (loops etc and scripted events if you are using Python etc) instr 2 kcount init 0 start: kcount = kcount + 1 kamp = 1/kcount kfreq = 440*kcount event "i", 3, 0,p3/kcount, kamp*0.25, kfreq if kcount < 4 kgoto start turnoff endin instr 3 kenv expon p4, p3, p4*0.001 a1 oscili kenv, p5, 1 out a1 endin On 3 Sep 2011, at 12:41, Victor Lazzarini wrote: > you can do something like this with recursive UDOs. Here is a > related example: > > 0dbfs=1 > > opcode OscBank, a, kkipp > kmin,kmax,ifn,ibnd,icnt xin > > if (icnt >= ibnd) goto bank > > abnd OscBank kmin,kmax,ifn,ibnd,icnt+1 > > bank: > kfreq = kmin*(kmax/kmin)^((icnt-1)/(ibnd-1)) > ao vco2 0.5/ibnd, kfreq > amix = ao + abnd > xout amix > > endop > > instr 1 > > kmin expseg 570,5,570, p3-10, 25, 5, 26 > kmax expseg 560,5,560, p3-10, 12400, 5, 12400 > a2 OscBank kmin,kmax, 1, 37 > k2 expseg 0.001,0.01,1,p3-1.01,1,1,0.001 > out a2*k2 > > endin > > On 3 Sep 2011, at 12:29, Tarmo Johannes wrote: > >> Sometimes I miss so much arrays, proper loops and ability to use >> opcode return values in expressions >> >> It would be really great to be able to write something like >> >> for (icount=0; icount<4; icount++) do >> if (changed k1 || changed k2) then >> kamp[icount]= 1/icount >> a[icount] oscil kamp[icount],440,icount >> endif >> endfor ; or whatever >> outq a[0],a[1],a[2],a[3] >> >> I know it can be done with looplt and using tables as array >> substitution but still, it would be so much more clumsy and cost >> quite many extra lines. >> >> Have you ever had a feeling that the syntax of csound hinders you? >> >> Is there hope that the syntax will develop? Like once, I think, if- >> then came next to if-goto? >> Or do you have any experience with CsoundAC? Does this would be >> solution for coding problems? >> >> I know very little about supercollider but I have feeling that at >> least this side can be better there. >> >> greetings, >> tarmo >> >> >> >> Send bugs reports to the Sourceforge bug tracker >> https://sourceforge.net/tracker/?group_id=81968&atid=564599 >> Discussions of bugs and features can be posted here >> To unsubscribe, send email sympa@lists.bath.ac.uk with body >> "unsubscribe csound" >> > > Dr Victor Lazzarini > Senior Lecturer > Dept. of Music > NUI Maynooth Ireland > tel.: +353 1 708 3545 > Victor dot Lazzarini AT nuim dot ie > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Dr Victor Lazzarini Senior Lecturer Dept. of Music NUI Maynooth Ireland tel.: +353 1 708 3545 Victor dot Lazzarini AT nuim dot ie Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-03 13:59 |
From | Michael Gogins |
Subject | Re: [Csnd] csound syntax limitations |
What you are asking for is now all possible, and more besides, with the new Lua opcodes that I have just checked into Csound GIT. These will be available on Intel architecture only for now, with the ARM architecture in the works. They will be in the Windows installer for the next release of Csound and should also soon be in the Linux packages. In both cases there is a dependency on LuaJIT by Mike Pall, which is a just in time optimizing compiler for Lua. Preliminary tests show that audio processing opcodes defined in Lua outperform UDOs by 250% and perform only 25% slower than Csound's own native C opcodes. The Lua code is embedded directly in the Csound orchestra code. Lua provides full lexical scoping, modules, arrays and dictionaries, for and while loops, lambdas, and closures and also several ways of doing classes. I would say that writing audio DSP code in Lua is about as easy as doing it in C or C++ and it performs nearly as fast as C, but you can do it all in your own Csound orchestra without any external compilation. There are still a few rough edges in LuaJIT itself, but I expect these will be going away. A sample of Lua code running in Csound follows. Regards, Mike function moogladder_kontrol(csound, opcode, carguments) local p = ffi.cast(moogladder_ct, carguments) -- transistor thermal voltage p.thermal = 1.0 / 40000.0 if p.res[0] < 0.0 then p.res[0] = 0.0 end -- sr is half the actual filter sampling rate p.fc = p.freq[0] / p.sr p.f = p.fc / 2.0 p.fc2 = p.fc * p.fc p.fc3 = p.fc2 * p.fc -- frequency & amplitude correction p.fcr = 1.873 * p.fc3 + 0.4955 * p.fc2 - 0.6490 * p.fc + 0.9988 p.acr = -3.9364 * p.fc2 + 1.8409 * p.fc + 0.9968 -- filter tuning p.tune = (1.0 - math.exp(-(2.0 * math.pi * p.f * p.fcr))) / p.thermal p.res4 = 4.0 * p.res[0] * p.acr -- Nested 'for' loops crash, not sure why. -- Local loop variables also are problematic. -- Lower-level loop constructs don't crash. p.i = 0 while p.i < p.ksmps do p.j = 0 while p.j < 2 do p.k = 0 while p.k < 4 do if p.k == 0 then p.input = p.inp[p.i] - p.res4 * p.delay[5] p.stg[p.k] = p.delay[p.k] + p.tune * (math.tanh(p.input * p.thermal) - p.tanhstg[p.k]) else p.input = p.stg[p.k - 1] p.tanhstg[p.k - 1] = math.tanh(p.input * p.thermal) if p.k < 3 then p.kk = p.tanhstg[p.k] else p.kk = math.tanh(p.delay[p.k] * p.thermal) end p.stg[p.k] = p.delay[p.k] + p.tune * (p.tanhstg[p.k - 1] - p.kk) end p.delay[p.k] = p.stg[p.k] p.k = p.k + 1 end -- 1/2-sample delay for phase compensation p.delay[5] = (p.stg[3] + p.delay[4]) * 0.5 p.delay[4] = p.stg[3] p.j = p.j + 1 end p.out[p.i] = p.delay[5] p.i = p.i + 1 end return 0 end }} On Sat, Sep 3, 2011 at 8:42 AM, Victor Lazzarini |
Date | 2011-09-03 19:37 |
From | Brian Redfern |
Subject | Re: [Csnd] csound syntax limitations |
When I want to do something like this I use inline python within the actual csd file. On Sep 3, 2011 11:30 AM, "Tarmo Johannes" <tarmo@otsakool.edu.ee> wrote:
> Sometimes I miss so much arrays, proper loops and ability to use opcode return values in expressions > > It would be really great to be able to write something like > > for (icount=0; icount<4; icount++) do > if (changed k1 || changed k2) then > kamp[icount]= 1/icount > a[icount] oscil kamp[icount],440,icount > endif > endfor ; or whatever > outq a[0],a[1],a[2],a[3] > > I know it can be done with looplt and using tables as array substitution but still, it would be so much more clumsy and cost quite many extra lines. > > Have you ever had a feeling that the syntax of csound hinders you? > > Is there hope that the syntax will develop? Like once, I think, if-then came next to if-goto? > Or do you have any experience with CsoundAC? Does this would be solution for coding problems? > > I know very little about supercollider but I have feeling that at least this side can be better there. > > greetings, > tarmo > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > |
Date | 2011-09-03 20:16 |
From | Michael Gogins |
Subject | Re: [Csnd] csound syntax limitations |
Yes that works fine also, but LuJI is 10 to 30 times faster than Python, plus you can define opcodes directly in Lua. Regards, Mike On Sat, Sep 3, 2011 at 2:37 PM, Brian Redfern |
Date | 2011-09-03 20:34 |
From | Tarmo Johannes |
Subject | Re: [Csnd] csound syntax limitations |
thank you for the hint! indeed, it is one possibility. but still clumsy... tarmo On Saturday 03 September 2011 14:41:04 Victor Lazzarini wrote: > you can do something like this with recursive UDOs. Here is a related > example: > > 0dbfs=1 > > opcode OscBank, a, kkipp > kmin,kmax,ifn,ibnd,icnt xin > > if (icnt >= ibnd) goto bank > > abnd OscBank kmin,kmax,ifn,ibnd,icnt+1 > > bank: > kfreq = kmin*(kmax/kmin)^((icnt-1)/(ibnd-1)) > ao vco2 0.5/ibnd, kfreq > amix = ao + abnd > xout amix > > endop > > instr 1 > > kmin expseg 570,5,570, p3-10, 25, 5, 26 > kmax expseg 560,5,560, p3-10, 12400, 5, 12400 > a2 OscBank kmin,kmax, 1, 37 > k2 expseg 0.001,0.01,1,p3-1.01,1,1,0.001 > out a2*k2 > > endin > > On 3 Sep 2011, at 12:29, Tarmo Johannes wrote: > > > Sometimes I miss so much arrays, proper loops and ability to use > > opcode return values in expressions > > > > It would be really great to be able to write something like > > > > for (icount=0; icount<4; icount++) do > > if (changed k1 || changed k2) then > > kamp[icount]= 1/icount > > a[icount] oscil kamp[icount],440,icount > > endif > > endfor ; or whatever > > outq a[0],a[1],a[2],a[3] > > > > I know it can be done with looplt and using tables as array > > substitution but still, it would be so much more clumsy and cost > > quite many extra lines. > > > > Have you ever had a feeling that the syntax of csound hinders you? > > > > Is there hope that the syntax will develop? Like once, I think, if- > > then came next to if-goto? > > Or do you have any experience with CsoundAC? Does this would be > > solution for coding problems? > > > > I know very little about supercollider but I have feeling that at > > least this side can be better there. > > > > greetings, > > tarmo > > > > > > > > Send bugs reports to the Sourceforge bug tracker > > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > > Discussions of bugs and features can be posted here > > To unsubscribe, send email sympa@lists.bath.ac.uk with body > > "unsubscribe csound" > > > > Dr Victor Lazzarini > Senior Lecturer > Dept. of Music > NUI Maynooth Ireland > tel.: +353 1 708 3545 > Victor dot Lazzarini AT nuim dot ie > > > > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" > > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-04 14:14 |
From | Mark Van Peteghem |
Subject | Re: [Csnd] csound syntax limitations |
This is very impresive! You've come a long way since you mentioned this earlier this year. But I wonder how fast Javascript will become. All major browser makers are competing to make their Javascript engines run as fast as possible; they're not yet at the speed of C, but might get there because they use similar techniques. If I understand correctly, LuaJIT is a one-man project with some sponsoring. Mark Michael Gogins wrote: > What you are asking for is now all possible, and more besides, with > the new Lua opcodes that I have just checked into Csound GIT. These > will be available on Intel architecture only for now, with the ARM > architecture in the works. They will be in the Windows installer for > the next release of Csound and should also soon be in the Linux > packages. In both cases there is a dependency on LuaJIT by Mike Pall, > which is a just in time optimizing compiler for Lua. Preliminary tests > show that audio processing opcodes defined in Lua outperform UDOs by > 250% and perform only 25% slower than Csound's own native C opcodes. > The Lua code is embedded directly in the Csound orchestra code. > > Lua provides full lexical scoping, modules, arrays and dictionaries, > for and while loops, lambdas, and closures and also several ways of > doing classes. I would say that writing audio DSP code in Lua is about > as easy as doing it in C or C++ and it performs nearly as fast as C, > but you can do it all in your own Csound orchestra without any > external compilation. > > There are still a few rough edges in LuaJIT itself, but I expect these > will be going away. > > A sample of Lua code running in Csound follows. > > Regards, > Mike > > function moogladder_kontrol(csound, opcode, carguments) > local p = ffi.cast(moogladder_ct, carguments) > -- transistor thermal voltage > p.thermal = 1.0 / 40000.0 > if p.res[0] < 0.0 then > p.res[0] = 0.0 > end > -- sr is half the actual filter sampling rate > p.fc = p.freq[0] / p.sr > p.f = p.fc / 2.0 > p.fc2 = p.fc * p.fc > p.fc3 = p.fc2 * p.fc > -- frequency & amplitude correction > p.fcr = 1.873 * p.fc3 + 0.4955 * p.fc2 - 0.6490 * p.fc + 0.9988 > p.acr = -3.9364 * p.fc2 + 1.8409 * p.fc + 0.9968 > -- filter tuning > p.tune = (1.0 - math.exp(-(2.0 * math.pi * p.f * p.fcr))) / p.thermal > p.res4 = 4.0 * p.res[0] * p.acr > -- Nested 'for' loops crash, not sure why. > -- Local loop variables also are problematic. > -- Lower-level loop constructs don't crash. > p.i = 0 > while p.i < p.ksmps do > p.j = 0 > while p.j < 2 do > p.k = 0 > while p.k < 4 do > if p.k == 0 then > p.input = p.inp[p.i] - p.res4 * p.delay[5] > p.stg[p.k] = p.delay[p.k] + p.tune * > (math.tanh(p.input * p.thermal) - p.tanhstg[p.k]) > else > p.input = p.stg[p.k - 1] > p.tanhstg[p.k - 1] = math.tanh(p.input * p.thermal) > if p.k < 3 then > p.kk = p.tanhstg[p.k] > else > p.kk = math.tanh(p.delay[p.k] * p.thermal) > end > p.stg[p.k] = p.delay[p.k] + p.tune * > (p.tanhstg[p.k - 1] - p.kk) > end > p.delay[p.k] = p.stg[p.k] > p.k = p.k + 1 > end > -- 1/2-sample delay for phase compensation > p.delay[5] = (p.stg[3] + p.delay[4]) * 0.5 > p.delay[4] = p.stg[3] > p.j = p.j + 1 > end > p.out[p.i] = p.delay[5] > p.i = p.i + 1 > end > return 0 > end > }} > > > > > > On Sat, Sep 3, 2011 at 8:42 AM, Victor Lazzarini > |
Date | 2011-09-04 15:34 |
From | Michael Gogins |
Subject | Re: [Csnd] csound syntax limitations |
Well, Lua is a better designed language than Javascript, not that Javascript is bad, just that Lua is better. So we have both the designers of Lua and Mike Pall (who is some kind of super programmer) to thank for LuaJIT. A lot of the speed of LuaJIT actually comes from the FFI part, where you can declare and define structures that are faster than Lua collections and that are in a different memory management system. Still I expect you are correct. It should indeed be possible to make a JavascriptJIT that is more or less as fast as LuaJIT. Since it would be built into browsers, it would then become a universal programming platform, along with C/C++. So yes, I am looking forward to this. Very much. If that happens I will probably migrate all my work (again) to it. Of course this also would require a good, native FFI part. Security considerations in the minds of Javascript maintainers may militate against that, though. I hope I'm wrong about that. Regards, Mike On Sun, Sep 4, 2011 at 9:14 AM, Mark Van Peteghem |
Date | 2011-09-04 16:58 |
From | Jim Aikin |
Subject | [Csnd] Re: csound syntax limitations |
> Yes that works fine also, but LuJI is 10 to 30 times faster than > Python, plus you can define opcodes directly in Lua. I'm very curious about this. Is there a good introductory tutorial anywhere on how to use Lua in conjunction with Csound? Jim Hearon did a piece for the Csound Journal, but (a) it seems to be mostly about Linux systems, and (b) it's not introductory. I couldn't make heads or tails of it, to be honest. I will quote one sentence by way of illustration: "If the .lua file contains 'require luaCsnd', then the script should be able to access SWIG-generated Lua wrappers for the Csound API available through the luaCsnd library, however path issues may arise when using the 'require' statement." I'm sure that says something useful and important ... but I have no way of knowing what it says. I don't even know whether Lua code can be embedded in a .csd the way Python code can. It's not mentioned in the manual for 5.13, I know that much. Further discussion on this topic would be very welcome! --Jim Aikin -- View this message in context: http://csound.1045644.n5.nabble.com/csound-syntax-limitations-tp4765283p4767801.html Sent from the Csound - General mailing list archive at Nabble.com. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-04 18:52 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: csound syntax limitations |
The Lua opcodes have nothing to do with the Lua API for Csound aside from the use of Lua. The Lua opcodes do not use SWIG. The Lua opcodes are not yet in any release packages. If you are on WIndows and you want to play with them, I can send you some pre-built files and you can try them out. If you do not use any third party Lua code, you do not need to worry about 'require' paths, which are an initially annoying feature of Lua. Regards, Mike On Sun, Sep 4, 2011 at 11:58 AM, Jim Aikin |
Date | 2011-09-05 02:44 |
From | Jim Aikin |
Subject | [Csnd] Re: csound syntax limitations |
> The Lua opcodes have nothing to do with the Lua API for Csound aside > from the use of Lua. The Lua opcodes do not use SWIG. > > The Lua opcodes are not yet in any release packages. If you are on > WIndows and you want to play with them, I can send you some pre-built > files and you can try them out. Thanks for the offer, but at the moment I have plenty to do, corraling a lot of information for my book. In any case, I don't know Lua, so it would take me a certain amount of study to figure out how to use them. Can you help me understand, just briefly, whether Lua provides any features that are not available in Python? I gather Lua is faster. Are there other advantages? --JA -- View this message in context: http://csound.1045644.n5.nabble.com/csound-syntax-limitations-tp4765283p4768951.html Sent from the Csound - General mailing list archive at Nabble.com. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-05 03:51 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: csound syntax limitations |
Lua is slightly more concise than Python, but because of some minor quirks in loop constructions, array indexing, and the use of begin...end keywords to define blocks of code instead of indentation, Python is slightly easier to write. Python has many more third party libraries than Lua. But Lua has plenty, and will get more. Lua is a much smaller piece of software, much easier to build and install, much easier to use. Lua is more elegant than Python, which is saying a lot, because Python is already very elegant. Lua runs much faster than Python, and LuaJIT runs roughly as fast as C. It's much easier to call C functions from Lua than from Python. It's much easier to call Lua functions from C than from Python. Hope this helps, Mike Regards, Mike On Sun, Sep 4, 2011 at 9:44 PM, Jim Aikin |
Date | 2011-09-05 05:04 |
From | Jim Aikin |
Subject | [Csnd] Re: csound syntax limitations |
Thanks, Michael. I've taken the liberty of quoting this email, in a
slightly edited form, in a sidebar. Currently it reads as follows: By the time you read this, Csound will probably have been expanded to allow the use of embedded code in the Lua programming language. The chief advantage of Lua, according to Michael Gogins, is that Lua runs much faster than Python. He also commented, “Lua is slightly more concise than Python, but because of some minor quirks, Python is slightly easier to write. Python currently has many more third-party libraries than Lua, but Lua has plenty and will get more. Lua is more elegant than Python, which is saying a lot, because Python is already very elegant.” I'm quoting other people here or there in the book, so I'm not singling you out, but if you're not comfortable with this, let me know. I can put it all in my own voice -- I just want to give credit where due. This will be a sidebar in the section on Python. --JA On 9/4/2011 7:52 PM, Michael Gogins-2 [via Csound] wrote: Lua is slightly more concise than Python, but because of some minor View this message in context: Re: csound syntax limitations Sent from the Csound - General mailing list archive at Nabble.com. |
Date | 2011-09-05 15:19 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: csound syntax limitations |
That's fine, thanks. Regards, Mike On Mon, Sep 5, 2011 at 12:04 AM, Jim Aikin |
Date | 2011-09-05 16:28 |
From | Louis Cohen |
Subject | Re: [Csnd] Re: csound syntax limitations |
I'm very encouraged to see that development efforts may some day lead to an extended Csound language. I want to thank all the developers for taking seriously this thread and previous threads relating to extending the Csound language syntax. I just visited the Lua site. I thought that since eventually Lua would become available for the Mac version of Csound (is this correct?) that I might download a version of Lua that I could use to explore the language. This turns out to be a little harder than I expected. It seems that I can download source files and compile them, which means I'll have to install and learn to use a C compiler, I guess. As best I can tell, binaries are for "advanced" users, which I'm certainly not. Does this mean that Lua is not for unsophisticated users me? -Lou On Sep 5, 2011, at 10:19 AM, Michael Gogins wrote: > That's fine, thanks. > > Regards, > Mike > > On Mon, Sep 5, 2011 at 12:04 AM, Jim Aikin > |
Date | 2011-09-05 18:21 |
From | francesco |
Subject | [Csnd] Re: csound syntax limitations |
Hello Mr. Lou, maybe here You can find a distribution for Your system: http://lua-users.org/wiki/LuaBinaries i'm a Lua user but i'm not a real programmer (never studied it), anyway i have found Lua a really good language, and also, like Mr. Gogins said, really fast, especially using LuaJIT. For some unknown reason i feel more comfortable with Lua than Python. i'm sure that if i was able to understand the basic concept of Lua anyone could be. ciao, francesco. -- View this message in context: http://csound.1045644.n5.nabble.com/csound-syntax-limitations-tp4765283p4771263.html Sent from the Csound - General mailing list archive at Nabble.com. Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-05 19:20 |
From | Michael Gogins |
Subject | Re: [Csnd] Re: csound syntax limitations |
Compiling Lua or LuaJIT is easy on Windows and Linux and I think it probably is easy on OS X as well. For the Lua opodes, you need LuaJIT, not Lua. See http://luajit.org/ and http://luajit.org/install.html. Regards, Mike On Mon, Sep 5, 2011 at 11:28 AM, Louis Cohen |
Date | 2011-09-05 19:45 |
From | Louis Cohen |
Subject | Re: [Csnd] Re: csound syntax limitations |
It may be easy for people who routinely write, compile and build programs written in C, but I'm not one of those. -Lou On Sep 5, 2011, at 2:20 PM, Michael Gogins wrote: > Compiling Lua or LuaJIT is easy on Windows and Linux and I think it > probably is easy on OS X as well. > > For the Lua opodes, you need LuaJIT, not Lua. See http://luajit.org/ > and http://luajit.org/install.html. > > Regards, > Mike > > On Mon, Sep 5, 2011 at 11:28 AM, Louis Cohen |
Date | 2011-09-05 20:19 |
From | Tarmo Johannes |
Subject | [Csnd] Lua opcodes |
Hello, although I have not tried yet, thank you for developing the lua opcodes! I updated the source from git, installed luaJit but when compiling the source with scons I get lines: CONFIGURATION DECISION: Building Lua wrapper to Csound C++ interface library. LUA MODULE luaCsnd... CONFIGURATION DECISION: Not building Lua opcodes. I used scons with parameters: scons usePortMIDI=0 custom=custom-linux-mkg.py buildLuaWrapper=1 buildPythonWrapper=1 useJack=1 buildCsoundVST=0 buildvst4cs=0 buildInterfaces=1 buildCsoundAC=0 buildJavaWrapper=0 useOSC=1 buildPythonOpcodes=1 buildLoris=0 buildStkOpcodes=1 buildWinsound=0 noFLTKThreads=0 useLrint=1 usePortAudio=1 buildPDClass=1 buildVirtual=0 buildTclcsound=0 buildLua=1 useDouble=1 dynamicCsoundLibrary=1 buildRelease=0 buildDSSI=1 noDebug=0 buildNewParser=0 I guess I should add something like buildLuaOpcodes=1 but what is the correct option? OR: I have also lua from ofiicila package installed, perhaps the compiler did not find the correct header files form /usr/local/include/luajit-2.0 ? greetings, tarmo On Monday 05 September 2011 21:20:13 Michael Gogins wrote: > Compiling Lua or LuaJIT is easy on Windows and Linux and I think it > probably is easy on OS X as well. > > For the Lua opodes, you need LuaJIT, not Lua. See http://luajit.org/ > and http://luajit.org/install.html. > > Regards, > Mike > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-05 20:32 |
From | Steven Yi |
Subject | Re: [Csnd] Re: csound syntax limitations |
I'm working on compiling LuaJIT and Lua wrapper/opcodes on OSX now. I'll be updating the build instructions on the wiki once I work through compiling a universal build of LuaJIT. On Mon, Sep 5, 2011 at 2:20 PM, Michael Gogins |
Date | 2011-09-05 20:48 |
From | Victor Lazzarini |
Subject | Re: [Csnd] Re: csound syntax limitations |
Thanks for letting me know, so I don't need to duplicate the work. We'll also have to see what extras are needed in terms of packaging releases. Victor On 5 Sep 2011, at 20:32, Steven Yi wrote: > I'm working on compiling LuaJIT and Lua wrapper/opcodes on OSX now. > I'll be updating the build instructions on the wiki once I work > through compiling a universal build of LuaJIT. > > On Mon, Sep 5, 2011 at 2:20 PM, Michael Gogins |
Date | 2011-09-05 21:05 |
From | Louis Cohen |
Subject | Re: [Csnd] Lua opcodes |
This is a perfect example of why I would like to avoid building software from sources. I have seen many, many postings on this list like this one. The process of building from source implies an avenue of learning that would deeply slow down my composing progress. -Lou On Sep 5, 2011, at 3:19 PM, Tarmo Johannes wrote: > Hello, > > although I have not tried yet, thank you for developing the lua > opcodes! > > I updated the source from git, installed luaJit but when compiling > the source with scons I get lines: > > CONFIGURATION DECISION: Building Lua wrapper to Csound C++ interface > library. > LUA MODULE luaCsnd... > > CONFIGURATION DECISION: Not building Lua opcodes. > > > I used scons with parameters: > > scons usePortMIDI=0 custom=custom-linux-mkg.py buildLuaWrapper=1 > buildPythonWrapper=1 useJack=1 buildCsoundVST=0 buildvst4cs=0 > buildInterfaces=1 buildCsoundAC=0 buildJavaWrapper=0 useOSC=1 > buildPythonOpcodes=1 buildLoris=0 buildStkOpcodes=1 buildWinsound=0 > noFLTKThreads=0 useLrint=1 usePortAudio=1 buildPDClass=1 > buildVirtual=0 buildTclcsound=0 buildLua=1 useDouble=1 > dynamicCsoundLibrary=1 buildRelease=0 buildDSSI=1 noDebug=0 > buildNewParser=0 > > > I guess I should add something like buildLuaOpcodes=1 but what is > the correct option? > > OR: I have also lua from ofiicila package installed, perhaps the > compiler did not find the correct header files form /usr/local/ > include/luajit-2.0 ? > > greetings, > tarmo > > On Monday 05 September 2011 21:20:13 Michael Gogins wrote: > > > >> Compiling Lua or LuaJIT is easy on Windows and Linux and I think it >> probably is easy on OS X as well. >> >> For the Lua opodes, you need LuaJIT, not Lua. See http://luajit.org/ >> and http://luajit.org/install.html. >> >> Regards, >> Mike >> > > > Send bugs reports to the Sourceforge bug tracker > https://sourceforge.net/tracker/?group_id=81968&atid=564599 > Discussions of bugs and features can be posted here > To unsubscribe, send email sympa@lists.bath.ac.uk with body > "unsubscribe csound" > Send bugs reports to the Sourceforge bug tracker https://sourceforge.net/tracker/?group_id=81968&atid=564599 Discussions of bugs and features can be posted here To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound" |
Date | 2011-09-05 21:24 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
You are right, and you may possibly be wrong. You are right in that learning to write and compile code is a deep study and must and will subtract from composing time. This has happened to me, very much so. On the other hand, I have what to me seems little or no talent and certainly little education for conventional composition, but some sort of talent for algorithmic composition, and much study of it. That study would not be possible without knowing how to program. Also, both developing new compositional algorithms, and composing with the algorithms, requires writing, running, and in some cases building code. Regards, Mike On Mon, Sep 5, 2011 at 4:05 PM, Louis Cohen |
Date | 2011-09-05 22:31 |
From | Steven Yi |
Subject | Re: [Csnd] Lua opcodes |
You'll probably need both buildLuaOpcodes=1 when you build with Scons, as well as add /usr/local/include/luajit-2.0 to your custom.py as a search path. On Mon, Sep 5, 2011 at 3:19 PM, Tarmo Johannes |
Date | 2011-09-06 02:05 |
From | Louis Cohen |
Subject | Re: [Csnd] Lua opcodes |
There's one thing you undoubtedly have more of than I do: time. I began writing code in 1959, when C was probably called A or B if it existed at all, and I'm now 73. As a professional software engineer it just so happened that all the coding I did was in assembly language. But that was a LONG, LONG time ago. It's not that I CAN'T learn new techniques (although pretty soon that may become true), it's that if I spend the time to learn, I'll be using up precious - and rapidly diminishing - time to compose. I consider myself first a composer, and second lucky to have enough coding skills to use Csound, without which my music would be quite different, and there would be a lot less of it. If it's easy for the developers of Lua (or any other app) to build from sources, why wouldn't they just do it once so others, like me, don't have to? -Lou On Sep 5, 2011, at 4:24 PM, Michael Gogins wrote: > You are right, and you may possibly be wrong. > > You are right in that learning to write and compile code is a deep > study and must and will subtract from composing time. This has > happened to me, very much so. > > On the other hand, I have what to me seems little or no talent and > certainly little education for conventional composition, but some sort > of talent for algorithmic composition, and much study of it. That > study would not be possible without knowing how to program. Also, both > developing new compositional algorithms, and composing with the > algorithms, requires writing, running, and in some cases building > code. > > Regards, > Mike > > On Mon, Sep 5, 2011 at 4:05 PM, Louis Cohen |
Date | 2011-09-06 04:08 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
Again, I sympathize totally with your urgency of time for just composing. I increasingly feel this myself (born in 1950). The explanation for the source distribution of Lua and LuaJIT includes: (1) It saves the language developers and maintainers time they don't have to spend packaging their software. (2) Most people who do software development know how to build from sources. This has its legacy from Unix where source distribution of almost all software was the initial rule and still is the rule on some Linuxes. (3) Many people who use specifically Lua or LuaJIT do not even want a binary distribution, since they need to compile the sources and then link them together with their own source code into a single unified binary that is both their special application and a Lua runtime, thus embedding Lua into their application without requiring an external Lua library. I have considered doing this with Csound. This is the usual case with some computer games, for example, where part of the game is actually written in Lua and the Lua scripts are actually compiled into the game binary. Regards, Mike On Mon, Sep 5, 2011 at 9:05 PM, Louis Cohen |
Date | 2011-09-06 09:09 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Success! (partial) Thank you, Steven, adding buildLuaOpcodes=1 did the trick Mike, typing scons -h in the source catalogeu pulled form git gives error: scons: warning: The Options class is deprecated; use the Variables class instead. File "/home/tarmo/src/Csound5.13.0/csound5/SConstruct", line 75, in |
Date | 2011-09-06 14:44 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
I haven't tried it on Linux, myself, but I will do that soon. However, I think your build and installation are correct, and that the problem is with the example code. Try commenting out the offending line and see what happens. Regards, Mike On Tue, Sep 6, 2011 at 4:09 AM, Tarmo Johannes |
Date | 2011-09-06 19:13 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Hello, 1) success! (for a first very small step): I got working a very simple "Hello world" example: lua_opdef "hello", {{ function hello_init() print("Hello world") return 0 end }} instr 3 iresult = 0 lua_iopcall "hello", iresult print iresult endin output: new alloc for instr 3: Hello world instr 3: iresult = 0.000 2) failure: I could not get the example csd work yet. I tryed the lines of in luajit command line interpreter. First, for linux the library should be local csoundLibrary = ffi.load('libcsound64.so.5.2') But it gave error: stdin:1: attempt to index global 'ffi' (a nil value) stack traceback: stdin:1: in main chunk [C]: ? I removed keyword 'local', > csoundLibrary = ffi.load('libcsound64.so.5.2') woked. When I copied the whole ffi.cdef and function luatest_init to the interpreter int went well, but I could not make a successful luatest_init() call - I did not understand what must be the arguments. I could not make out of the other code much, since I don't know lua at all yet. 3) looking forward to your explanations and examples in the documentation! If you have five minutes, could you write a simple 440 Hz beep example to the mailing-list for the impatient persons? 4) I will have another look to the luamoog.csd example to try to undertand the business more. Anyway, looks extremely exciting an perhaps it is a real new door to new possibilities. greetings, tarmo On Tuesday 06 September 2011 16:44:42 Michael Gogins wrote: > I haven't tried it on Linux, myself, but I will do that soon. > > However, I think your build and installation are correct, and that the > problem is with the example code. Try commenting out the offending > line and see what happens. > > Regards, > Mike > > On Tue, Sep 6, 2011 at 4:09 AM, Tarmo Johannes |
Date | 2011-09-06 19:54 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
The following does, on WIndows, what you are trying to do: |
Date | 2011-09-06 21:05 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Thank you, unfortunately I always get error Lua error in "hello_init": attempt to call a nil value. with that code. It is logical, as there is output: Executing Lua code: local ffi = require("ffi") local string = require("string") csoundLibrary = ffi.load('libcsound64.so.5.2') etc Failed with: 1 Thus I guess hello_init object won't be prepared at all. And I cannot guess, what cuases it. I tried to comment out almost every line from the code but no change. Actually, how should I comment it? With ; or -- ? When I copyed the lines to a independent script file: #!/usr/local/bin/luajit local ffi = require("ffi") local string = require("string") local csoundLibrary = ffi.load('libcsound64.so.5.2') ffi.cdef[[ struct hello_arguments {double *out; }; ]] function hello_init(csound, opcode, carguments) local arguments = ffi.cast("struct hello_arguments *", carguments) print("Hello!") arguments.out[0] = 100 return 0 end hello_init() I will get no errors, the output is: Hello! Segmentation fault (since I could not give any sensble parameters t hello_init ) Can it be that in the csound parsers gets somehow confused in linux? ( I am using the old parser). Perhaps the ';' sine in lines like struct hello_arguments {double *out; }; drives it crazy? Just guesses: I don't know and understand the inner logic yet. I am sure, it comes. greetings, tarmo On Tuesday 06 September 2011 21:54:26 Michael Gogins wrote: > The following does, on WIndows, what you are trying to do: > > |
Date | 2011-09-09 00:10 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Hi, I found out that if I add the line local ffi = require("ffi") to my original "hello" opcode, I get the error message: Lua error in "hello_init": attempt to call a nil value. I tryes the smae line (without keyword locla) in command prompt of "normal" lua, it gave an error: stdin:1: module 'ffi' not found: If I try the same in luajit command prompt, it goes OK, and print(ffi) returns a value of a table. So I think it is OK. So I guess, in my build, somehow Csound is trying to use the normal lua library and not luajit. I try to uninstall lua, disable lua-wrapper in build and I will report the results, what happesn (maybe tomorrow, or later). tarmo Thus I assume there is a mistake in my build and somehow On Tuesday 06 September 2011 23:05:01 Tarmo Johannes wrote: > Thank you, > > unfortunately I always get error > > Lua error in "hello_init": attempt to call a nil value. > > with that code. > It is logical, as there is output: > > Executing Lua code: > > local ffi = require("ffi") > local string = require("string") > > csoundLibrary = ffi.load('libcsound64.so.5.2') > etc > > Failed with: 1 > > Thus I guess hello_init object won't be prepared at all. > > And I cannot guess, what cuases it. > I tried to comment out almost every line from the code but no change. Actually, how should I comment it? With ; or -- ? > > When I copyed the lines to a independent script file: > > #!/usr/local/bin/luajit > > local ffi = require("ffi") > local string = require("string") > > local csoundLibrary = ffi.load('libcsound64.so.5.2') > ffi.cdef[[ > struct hello_arguments {double *out; }; > ]] > function hello_init(csound, opcode, carguments) > local arguments = ffi.cast("struct hello_arguments *", carguments) > print("Hello!") > arguments.out[0] = 100 > return 0 > end > > hello_init() > > I will get no errors, the output is: > Hello! > Segmentation fault > (since I could not give any sensble parameters t hello_init ) > > Can it be that in the csound parsers gets somehow confused in linux? ( I am using the old parser). Perhaps the ';' sine in lines like > struct hello_arguments {double *out; }; > drives it crazy? > > Just guesses: I don't know and understand the inner logic yet. I am sure, it comes. > > greetings, > tarmo > > > > > On Tuesday 06 September 2011 21:54:26 Michael Gogins wrote: > > The following does, on WIndows, what you are trying to do: > > > > |
Date | 2011-09-09 00:21 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
OK, that went quickly. I removeed lua and rebuilt csound. Unfortunately no change. Still error on line local ffi = require("ffi") -- Lua error in "hello_init": attempt to call a nil value. I better wiat for instructions or tutorial from Mike. tarmo On Friday 09 September 2011 02:10:15 Tarmo Johannes wrote: > Hi, > > I found out that if I add the line > > local ffi = require("ffi") > > to my original "hello" opcode, I get the error message: > Lua error in "hello_init": attempt to call a nil value. > > I tryes the smae line (without keyword locla) in command prompt of "normal" lua, it gave an error: > stdin:1: module 'ffi' not found: > > If I try the same in luajit command prompt, it goes OK, and print(ffi) returns a value of a table. So I think it is OK. > > So I guess, in my build, somehow Csound is trying to use the normal lua library and not luajit. I try to uninstall lua, disable lua-wrapper in build and I will report the results, what happesn (maybe tomorrow, or later). > > tarmo > > > > Thus I assume there is a mistake in my build and somehow > > On Tuesday 06 September 2011 23:05:01 Tarmo Johannes wrote: > > Thank you, > > > > unfortunately I always get error > > > > Lua error in "hello_init": attempt to call a nil value. > > > > with that code. > > It is logical, as there is output: > > > > Executing Lua code: > > > > local ffi = require("ffi") > > local string = require("string") > > > > csoundLibrary = ffi.load('libcsound64.so.5.2') > > etc > > > > Failed with: 1 > > > > Thus I guess hello_init object won't be prepared at all. > > > > And I cannot guess, what cuases it. > > I tried to comment out almost every line from the code but no change. Actually, how should I comment it? With ; or -- ? > > > > When I copyed the lines to a independent script file: > > > > #!/usr/local/bin/luajit > > > > local ffi = require("ffi") > > local string = require("string") > > > > local csoundLibrary = ffi.load('libcsound64.so.5.2') > > ffi.cdef[[ > > struct hello_arguments {double *out; }; > > ]] > > function hello_init(csound, opcode, carguments) > > local arguments = ffi.cast("struct hello_arguments *", carguments) > > print("Hello!") > > arguments.out[0] = 100 > > return 0 > > end > > > > hello_init() > > > > I will get no errors, the output is: > > Hello! > > Segmentation fault > > (since I could not give any sensble parameters t hello_init ) > > > > Can it be that in the csound parsers gets somehow confused in linux? ( I am using the old parser). Perhaps the ';' sine in lines like > > struct hello_arguments {double *out; }; > > drives it crazy? > > > > Just guesses: I don't know and understand the inner logic yet. I am sure, it comes. > > > > greetings, > > tarmo > > > > > > > > > > On Tuesday 06 September 2011 21:54:26 Michael Gogins wrote: > > > The following does, on WIndows, what you are trying to do: > > > > > > |
Date | 2011-09-09 00:31 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Sorrym liblua was still left in my system. removing it would cost too many dependency error, so I better do not do it. So I think csound was linked against to the the normal liblua. I had set in my custom.py file line customLIBPATH.append('/home/tarmo/src/LuaJIT-2.0.0-beta8/src') but somehow I think liblua in my /usr/lib64 was used instead. tarmo On Friday 09 September 2011 02:21:38 Tarmo Johannes wrote: > OK, > > that went quickly. I removeed lua and rebuilt csound. Unfortunately no change. Still error on line > local ffi = require("ffi") -- Lua error in "hello_init": attempt to call a nil value. > > I better wiat for instructions or tutorial from Mike. > > tarmo > > On Friday 09 September 2011 02:10:15 Tarmo Johannes wrote: > > Hi, > > > > I found out that if I add the line > > > > local ffi = require("ffi") > > > > to my original "hello" opcode, I get the error message: > > Lua error in "hello_init": attempt to call a nil value. > > > > I tryes the smae line (without keyword locla) in command prompt of "normal" lua, it gave an error: > > stdin:1: module 'ffi' not found: > > > > If I try the same in luajit command prompt, it goes OK, and print(ffi) returns a value of a table. So I think it is OK. > > > > So I guess, in my build, somehow Csound is trying to use the normal lua library and not luajit. I try to uninstall lua, disable lua-wrapper in build and I will report the results, what happesn (maybe tomorrow, or later). > > > > tarmo > > > > > > > > Thus I assume there is a mistake in my build and somehow > > > > On Tuesday 06 September 2011 23:05:01 Tarmo Johannes wrote: > > > Thank you, > > > > > > unfortunately I always get error > > > > > > Lua error in "hello_init": attempt to call a nil value. > > > > > > with that code. > > > It is logical, as there is output: > > > > > > Executing Lua code: > > > > > > local ffi = require("ffi") > > > local string = require("string") > > > > > > csoundLibrary = ffi.load('libcsound64.so.5.2') > > > etc > > > > > > Failed with: 1 > > > > > > Thus I guess hello_init object won't be prepared at all. > > > > > > And I cannot guess, what cuases it. > > > I tried to comment out almost every line from the code but no change. Actually, how should I comment it? With ; or -- ? > > > > > > When I copyed the lines to a independent script file: > > > > > > #!/usr/local/bin/luajit > > > > > > local ffi = require("ffi") > > > local string = require("string") > > > > > > local csoundLibrary = ffi.load('libcsound64.so.5.2') > > > ffi.cdef[[ > > > struct hello_arguments {double *out; }; > > > ]] > > > function hello_init(csound, opcode, carguments) > > > local arguments = ffi.cast("struct hello_arguments *", carguments) > > > print("Hello!") > > > arguments.out[0] = 100 > > > return 0 > > > end > > > > > > hello_init() > > > > > > I will get no errors, the output is: > > > Hello! > > > Segmentation fault > > > (since I could not give any sensble parameters t hello_init ) > > > > > > Can it be that in the csound parsers gets somehow confused in linux? ( I am using the old parser). Perhaps the ';' sine in lines like > > > struct hello_arguments {double *out; }; > > > drives it crazy? > > > > > > Just guesses: I don't know and understand the inner logic yet. I am sure, it comes. > > > > > > greetings, > > > tarmo > > > > > > > > > > > > > > > On Tuesday 06 September 2011 21:54:26 Michael Gogins wrote: > > > > The following does, on WIndows, what you are trying to do: > > > > > > > > |
Date | 2011-09-09 00:57 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
OK! I got it work now: the "hello" lua opcode works now as Michael Gogins suggested: lua_opdef "hello", {{ local ffi = require("ffi") local string = require("string") local csoundLibrary = ffi.load('csound64.dll.5.2') ffi.cdef[[ struct hello_arguments {double *out; }; ]] function hello_init(csound, opcode, carguments) local arguments = ffi.cast("struct hello_arguments *", carguments) print("Hello!") arguments.out[0] = 100 return 0 end }} What I needed to do: 1) make a new link to the luajit library as I could not (dear not) remove the old lua llua package: sudo mv /usr/lib64/liblua51.so /usr/lib64/liblua51.so.linkold # preserve for any case sudo ln -s /usr/local/lib/libluajit-5.1.so.2.0.0 /usr/lib64/liblua51.so 2) make a link in my liblua in my local directory to build luaCsnd.so (maybe it is not necessary) sudo ln -s /usr/local/lib/libluajit-5.1.so.2.0.0 /usr/local/lib/liblua.so 3) rebuild csound, copy libLuaCsound.so to py plugins64 directory and IT WORKED! Maybe I am approaching in big circles and the straight way is much more simple but perhaps this report helps someone. greetings, tarmo make a link to On Friday 09 September 2011 02:31:32 Tarmo Johannes wrote: > Sorrym > > liblua was still left in my system. removing it would cost too many dependency error, so I better do not do it. So I think csound was linked against to the the normal liblua. I had set in my custom.py file line > > customLIBPATH.append('/home/tarmo/src/LuaJIT-2.0.0-beta8/src') > but somehow I think liblua in my /usr/lib64 was used instead. > > tarmo > > > On Friday 09 September 2011 02:21:38 Tarmo Johannes wrote: > > OK, > > > > that went quickly. I removeed lua and rebuilt csound. Unfortunately no change. Still error on line > > local ffi = require("ffi") -- Lua error in "hello_init": attempt to call a nil value. > > > > I better wiat for instructions or tutorial from Mike. > > > > tarmo > > > > On Friday 09 September 2011 02:10:15 Tarmo Johannes wrote: > > > Hi, > > > > > > I found out that if I add the line > > > > > > local ffi = require("ffi") > > > > > > to my original "hello" opcode, I get the error message: > > > Lua error in "hello_init": attempt to call a nil value. > > > > > > I tryes the smae line (without keyword locla) in command prompt of "normal" lua, it gave an error: > > > stdin:1: module 'ffi' not found: > > > > > > If I try the same in luajit command prompt, it goes OK, and print(ffi) returns a value of a table. So I think it is OK. > > > > > > So I guess, in my build, somehow Csound is trying to use the normal lua library and not luajit. I try to uninstall lua, disable lua-wrapper in build and I will report the results, what happesn (maybe tomorrow, or later). > > > > > > tarmo > > > > > > > > > > > > Thus I assume there is a mistake in my build and somehow > > > > > > On Tuesday 06 September 2011 23:05:01 Tarmo Johannes wrote: > > > > Thank you, > > > > > > > > unfortunately I always get error > > > > > > > > Lua error in "hello_init": attempt to call a nil value. > > > > > > > > with that code. > > > > It is logical, as there is output: > > > > > > > > Executing Lua code: > > > > > > > > local ffi = require("ffi") > > > > local string = require("string") > > > > > > > > csoundLibrary = ffi.load('libcsound64.so.5.2') > > > > etc > > > > > > > > Failed with: 1 > > > > > > > > Thus I guess hello_init object won't be prepared at all. > > > > > > > > And I cannot guess, what cuases it. > > > > I tried to comment out almost every line from the code but no change. Actually, how should I comment it? With ; or -- ? > > > > > > > > When I copyed the lines to a independent script file: > > > > > > > > #!/usr/local/bin/luajit > > > > > > > > local ffi = require("ffi") > > > > local string = require("string") > > > > > > > > local csoundLibrary = ffi.load('libcsound64.so.5.2') > > > > ffi.cdef[[ > > > > struct hello_arguments {double *out; }; > > > > ]] > > > > function hello_init(csound, opcode, carguments) > > > > local arguments = ffi.cast("struct hello_arguments *", carguments) > > > > print("Hello!") > > > > arguments.out[0] = 100 > > > > return 0 > > > > end > > > > > > > > hello_init() > > > > > > > > I will get no errors, the output is: > > > > Hello! > > > > Segmentation fault > > > > (since I could not give any sensble parameters t hello_init ) > > > > > > > > Can it be that in the csound parsers gets somehow confused in linux? ( I am using the old parser). Perhaps the ';' sine in lines like > > > > struct hello_arguments {double *out; }; > > > > drives it crazy? > > > > > > > > Just guesses: I don't know and understand the inner logic yet. I am sure, it comes. > > > > > > > > greetings, > > > > tarmo > > > > > > > > > > > > > > > > > > > > On Tuesday 06 September 2011 21:54:26 Michael Gogins wrote: > > > > > The following does, on WIndows, what you are trying to do: > > > > > > > > > > |
Date | 2011-09-09 02:05 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
What you did is exactly right, as far as I can tell. Thanks! It'll help me when I try to get this working on Linux myself. Could you try the luamoog.csd example? Regards, Mike On Thu, Sep 8, 2011 at 7:57 PM, Tarmo Johannes |
Date | 2011-09-09 06:52 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Hello, I replaced .dll. with .so. in the ffi.load('csound64.so.5.2') line and the opcode compiles fine: Opcode: moogladder Result: 0 But running the csd breaks csound: SECTION 1: ftable 1: new alloc for instr 5: instr 5: ielapsed = 0.069 B 0.000 .. 1.000 T 1.000 TT 1.000 M: 0.0 new alloc for instr 4: Lua moogladder. Csound tidy up: Segmentation fault inactive allocs returned to freespace end of score. overall amps: 0.0 overall samples out of range: 0 0 errors in performance Elapsed time at end of performance: real: 1.321s, CPU: 0.090s 188 512-byte soundblks of shorts written to dac Segmentation fault I am not in the level of undertanding to find out, why it happens. tarmo On Friday 09 September 2011 04:05:58 Michael Gogins wrote: > What you did is exactly right, as far as I can tell. Thanks! It'll > help me when I try to get this working on Linux myself. > > Could you try the luamoog.csd example? > > Regards, > Mike > > On Thu, Sep 8, 2011 at 7:57 PM, Tarmo Johannes |
Date | 2011-09-09 13:27 |
From | Michael Gogins |
Subject | Re: [Csnd] Lua opcodes |
Well, thanks for checking. That should have been all you needed to do if the other example ran in your environment. The example renders to audio out, try -o temp.wav at the end of the command line to see if it will render to a soundfile. If that doesn't work, remove the calls to the Csound API in the Lua code and hardcode sr and ksmps to match what Csound is running, and see if that works either to audio out or to soundfile. I will look into this when I try to get it working on Linux myself. In the meantime, you could tell me what sort of projects you might want to use the Lua opcodes for, and I'll see if I can come up with any pointers. Regards, Mike On Fri, Sep 9, 2011 at 1:52 AM, Tarmo Johannes |
Date | 2011-09-12 15:51 |
From | Tarmo Johannes |
Subject | Re: [Csnd] Lua opcodes |
Hi! I had now time to check the lua opcodes to again. Thank you, Francois, for the SConstruct hint, it is very good solution! I recompiled the libLuaCsound.so again and now the moogladder.csd example works well, both real time and rendering to file. With file rendering to file I get results: SECTION 1: ftable 1: new alloc for instr 5: instr 5: ielapsed = 0.019 B 0.000 .. 1.000 T 1.000 TT 1.000 M: 0.0 new alloc for instr 4: Lua moogladder. B 1.000 .. 21.000 T 21.000 TT 21.000 M: 2327.3 instr 5: ielapsed = 2.168 B 21.000 .. 22.000 T 22.000 TT 22.000 M: 0.0 Lua moogladder. B 22.000 .. 42.000 T 42.000 TT 42.000 M: 2327.3 instr 5: ielapsed = 1.507 B 42.000 .. 43.000 T 43.000 TT 43.000 M: 0.0 new alloc for instr 2: Native moogladder. B 43.000 .. 63.000 T 63.000 TT 63.000 M: 2327.3 instr 5: ielapsed = 1.633 B 63.000 .. 64.000 T 64.000 TT 64.000 M: 0.0 Native moogladder. B 64.000 .. 84.000 T 84.000 TT 84.000 M: 2327.3 instr 5: ielapsed = 1.682 B 84.000 .. 85.000 T 85.000 TT 85.000 M: 0.0 new alloc for instr 3: UDO moogladder. B 85.000 ..105.000 T105.000 TT105.000 M: 2327.3 instr 5: ielapsed = 7.989 B105.000 ..106.000 T106.000 TT106.000 M: 0.0 UDO moogladder. B106.000 ..126.000 T126.000 TT126.000 M: 2327.3 instr 5: ielapsed = 8.152 B126.000 ..127.000 T127.000 TT127.000 M: 0.0 new alloc for instr 1: No filter. B127.000 ..147.000 T147.000 TT147.000 M: 10000.0 instr 5: ielapsed = 0.170 B147.000 ..148.000 T148.000 TT148.000 M: 0.0 No filter. B148.000 ..168.000 T168.000 TT168.000 M: 10000.0 instr 5: ielapsed = 0.137 B168.000 ..169.000 T169.000 TT169.000 M: 0.0 Lua moogladder. B169.000 ..170.000 T170.000 TT170.000 M: 1037.2 new alloc for instr 4: Lua moogladder. Csound tidy up: Segmentation fault inactive allocs returned to freespace end of score. overall amps: 10000.0 overall samples out of range: 0 0 errors in performance Elapsed time at end of performance: real: 23.793s, CPU: 21.880s 31875 512-byte soundblks of shorts written to test.wav (WAV) Thus the lua opcode is here about 4 times (sic!) faster than the native UDO solution. Hope to find more time to investigate lua further and try to write some own opcodes. greetings, tarmo On Friday 09 September 2011 15:27:59 Michael Gogins wrote: > Well, thanks for checking. That should have been all you needed to do > if the other example ran in your environment. > > The example renders to audio out, try -o temp.wav at the end of the > command line to see if it will render to a soundfile. If that doesn't > work, remove the calls to the Csound API in the Lua code and hardcode > sr and ksmps to match what Csound is running, and see if that works > either to audio out or to soundfile. > > I will look into this when I try to get it working on Linux myself. > > In the meantime, you could tell me what sort of projects you might > want to use the Lua opcodes for, and I'll see if I can come up with > any pointers. > > Regards, > Mike > > On Fri, Sep 9, 2011 at 1:52 AM, Tarmo Johannes |