introduction
installing
importing
help()
csd perform
|
(under construction)
Introduction to using csnd: the Python wrapper for csound
Importing
csnd into Python
For the purpose of this
example, we'll work from the terminal command-line interface (CLI).
If you don't know if, or which version of, python is installed, type
% which
python
(the '%' is the symbol for the CLI prompt.
If which
can find a
python you can instantiate (run) it. Eg:
% python
Python 2.4.3 (#1, Mar 30 2006, 11:02:16)
[GCC 4.0.1 (Apple Computer, Inc. build 5250)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
(>>> is
the familiar python prompt)
To view the contents of
python's namespace, type:
>>>
dir()
['__builtins__', '__doc__', '__file__', '__name__']
>>>
Now import the
python csnd
module (a file named csnd.py )
>>> import csnd
>>>
If python returns its
prompt (>>> ), you've
succeeded in
importing the csnd
module. If you receive a error message like:
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ImportError: No module named csnd
It means python can't find the csnd.py
file. This is a python problem,
so seek python help.
(add more
detail here
about finding it using %find and $PYTHONPATH
or the .profile
file)
You can check what modules this instantiation of python has in it's
namespace now by typing
>>>
dir()
['__builtins__', '__doc__', '__file__', '__name__', 'csnd']
>>>
You can see what's
defined in the csnd namespace like this:
>>>dir(csnd)
['CSFTYPE_AIFC', 'CSFTYPE_AIFF', 'CSFTYPE_ATS', 'CSFTYPE_AU',
'CSFTYPE_AVR', 'CSFTYPE_CAF', 'CSFTYPE_CVANAL',
'CSFTYPE_EXTRACT_PARMS', 'CSFTYPE_FLAC', 'CSFTYPE_FLOATS_BINARY',
'CSFTYPE_FLOATS_TEXT', 'CSFTYPE_FTABLES_BINARY',
...
'CppSound', 'CppSound_swigregister', 'Csound',
'CsoundArgVList', 'CsoundArgVList_swigregister',
'CsoundCallbackWrapper', 'CsoundCallbackWrapper_CharPtrToString',
'CsoundCallbackWrapper_swigregister',
...
'intp_getitem', 'intp_setitem', 'new', 'new_doublep', 'new_floatp',
'new_instancemethod', 'new_intp', 'opcodeListEntry',
'opcodeListEntry_swigregister', 'pycallbackdata',
'pycallbackdata_swigregister', 'sigcpy']
>>>
(depending on csnd version
and installation options, this output may differ)
Check out SoniPy
our public domain data sonification software framework on Sourceforge
contact:
sonify 'at' avatar.com.au
last updated:
2007.11.03
|
tested on:
OSX with
Python 2.4 |