[Csnd] Examples using the Csound6 API
Date | 2013-04-25 15:23 |
From | Jacob Joaquin |
Subject | [Csnd] Examples using the Csound6 API |
Can anyone point me to some examples that are using the Csound6 API? I prefer Python but anything will do. I want to take a look into the REPL project Steven mentioned this past weekend.
Thanks,
Jake |
Date | 2013-04-25 19:01 |
From | Rory Walsh |
Subject | Re: [Csnd] Examples using the Csound6 API |
Hi Jake. I'm not sure there are many examples just yet, but most of the examples for Csound 5 still work fine with Csound 6 (just drop csoundPreCompile()). I guess in order to create some kind of REPL interface(this is open to correction!) you should create a new instance of Csound, then call csoundCompileOrc() passing it any new instruments you create on the fly, followed by a quick call to csoundInputmessage() to send the score event that will start the instrument playing? assuming of course Csound is currently performing. I'm also interested in how to create this type of on-the-fly interface. Perhaps Steven can let us know how he worked his magic in that video. On 25 April 2013 15:23, Jacob Joaquin <jacobjoaquin@gmail.com> wrote:
|
Date | 2013-04-25 20:16 |
From | Jacob Joaquin |
Subject | Re: [Csnd] Examples using the Csound6 API |
Thanks. I just rebuilt C6 with the latest version in master, as I had to install swig so the Python interface was built. I'm not sure what's the next step. I'm guessing I'm supposed to import csnd6, and used it in this 3 line script: import sys sys.path.append("/usr/local/lib") import csnd6 Though running it gives me this error: Traceback (most recent call last):
File "repl_test.py", line 4, in <module> import csnd6 File "/usr/local/lib/csnd6.py", line 26, in <module> _csnd6 = swig_import_helper()
File "/usr/local/lib/csnd6.py", line 22, in swig_import_helper _mod = imp.load_module('_csnd6', fp, pathname, description) ImportError: dlopen(/usr/local/lib/_csnd6.so, 2): no suitable image found. Did find:
/usr/local/lib/_csnd6.so: mach-o, but wrong architecture Best, Jake On Thu, Apr 25, 2013 at 11:01 AM, Rory Walsh <rorywalsh@ear.ie> wrote:
codehop.com | #code #art #music |
Date | 2013-04-25 20:48 |
From | Steven Yi |
Subject | Re: [Csnd] Examples using the Csound6 API |
Hi Jake, That's odd about the mach-o message. How did you go about installing after you built csound6? Maybe an older version was installed that is causing issues? For testing, I'm using a terminal and cd'ing into the build folder, then starting python from that folder (using python or ipython). You *should* then be able to do: import csnd6 print csnd6.CS_VERSION and get "6" printed out. I think you should be able to symlink the csnd.py and _csnd6.so from the build folder over to /Library/Python/2.7/site-packages and then run the above from anywhere (assuming you're using 2.7). If you get the above working, then you should be able to run csound like: import csnd6 cs = csnd6.Csound() cs.Compile("/Users/stevenyi/excerpt.csd") while(cs.PerformKsmps() == 0): pass cs.Reset() For a REPL, we'd have to run csound in a thread. I'm not sure what people usually do in Python and Csound (I tend to use a Java Thread and wrap my Csound performance code, but maybe CsoundPerformanceThread is more popular for Python?). Once the thread runs, you can call: cs.CompileOrc("...some score code...") or: cs.ReadScore("i1 0 2") There is a folder in Csound6's git repo for python API examples (csound6/tests/python). It's empty at the moment, but the plan was to create a whole set of API demonstration examples using python that could also be used as a testing suite. I thought it might be nice to have a UI Browser, so you could select an example, see the code as well as press a run button. It'd be great to get API test writers to contribute Python examples to this folder that focus on highlighting a specific technique or API function. The goal was that this would be both a test but also a reference on how to use the API. Hope that helps! steven On Thu, Apr 25, 2013 at 8:16 PM, Jacob Joaquin |
Date | 2013-04-25 21:07 |
From | Jacob Joaquin |
Subject | Re: [Csnd] Examples using the Csound6 API |
I think the mach-o issue had to do with the version of Python I had installed up to about 30 minutes ago, which was the 32bit Enthought installed. I installed the latest with a 64bit build and I'm getting a new error: Fatal Python error: PyThreadState_Get: no current thread Abort trap: 6 To build, I'm basically running this: cmake ..
make sudo make install export OPCODE6DIR64=$PWD/CsoundLib64.framework/Resources/Opcodes My goal is to get this running so I can see whether or not IPython Notebook is a viable UI. As it stands now, I can run Csound in the notebook with "!csound foo.csd". Though using the IPython magic system, it'd be possible easily dynamically load instruments, and then play various score snippets, which I think would be great to have for tutorials. In theory at least.
Best, Jake On Thu, Apr 25, 2013 at 12:48 PM, Steven Yi <stevenyi@gmail.com> wrote: Hi Jake, codehop.com | #code #art #music |
Date | 2013-04-25 21:14 |
From | Rory Walsh |
Subject | Re: [Csnd] Examples using the Csound6 API |
That sounds like a great idea Jake. It might even encourage me to brush up on my Python skills! On 25 April 2013 21:07, Jacob Joaquin <jacobjoaquin@gmail.com> wrote:
|
Date | 2013-04-25 22:06 |
From | Steven Yi |
Subject | Re: [Csnd] Examples using the Csound6 API |
Hi Jake, Just FYI, the "make install" target for OSX hasn't been tested and may be problematic. I was chatting with Victor about what to do for both "make install" and for the installer; we've got some ideas but need time to test and sort it out. As for the PyThreadState_Get, that's odd. Was that just using "import csnd6" or were you using more than that? Also, I have "-+rtaudio=pa_bl -g -o dac -d -+ignore_csopts=true" in my .csoundrc. I'm not sure if that would change anything on your side. Another possibility, you could always try Csound5's python API to test out ipython notebooks. You'd still be able to send scores live, but won't be able to do additional orc compilation. I was able to use both: import csnd print csnd.CS_VERSION and: import csnd6 print csnd6.CS_VERSION in a notebook just now. steven On Thu, Apr 25, 2013 at 9:07 PM, Jacob Joaquin |