This is very nice. Thanks. Oeyvind 2007/1/31, Victor Lazzarini : > Following up a recent discussion on the other list, I have added > a mechanism for using callbacks in Python (as well as C++) > to the CsoundPerformanceThread class. > > Here's a trivial example (I have added this to the sources as well): > > import csnd > import time > > # create & compile instance > cs = csnd.Csound() > cs.Compile("cb.csd") > > # define callback > def callback(csound): > a = csound.GetChannel("freq") > if(a < 1000): a = a+0.1 > else: a = 100.0 > csound.SetChannel("freq", a) > > # set an initial value for freq > cs.SetChannel("freq", 100) > > # create the thread object > perf = csnd.CsoundPerformanceThread(cs) > > # set the callback > perf.SetProcessCallback(callback, cs) > > # play > perf.Play() > > # wait for 30 secs > time.sleep(30) > > ############### > Here's the CSD (cb.csd): > > > > -odac -d > > > > > ; bus channel > gkfreq chnexport "freq", 3 > > instr 1 > a1 oscil 10000, gkfreq, 1 > out a1 > endin > > > > > > f1 0 16384 10 1 > ; run for 30 secs > i1 0 30 > > > > > > > > NB: The callback is called *before* csoundPerformKsmps() by the > processing loop. > > > > Victor Lazzarini > Music Technology Laboratory > Music Department > National University of Ireland, Maynooth > > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share your > opinions on IT & business topics through brief surveys - and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Csound-devel mailing list > Csound-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/csound-devel > ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier. Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ Csound-devel mailing list Csound-devel@lists.sourceforge.net