introduction
installing
importing
help()
csd perform
|
(under construction)
Introduction to using csnd: the
Python wrapper for csound
Getting
help using Python's help() function
In the Python interpreter,
calling help(thing) on a Python
object prints the documentation of the object thing .
There is another form of documentation available as a shell command,
called pydoc .
We can use help() to obtain
quick access to
the csnd classes and their methods
included in the csnd
library,
especially when external documentation is not available. The
documentation on help() itself tells
you how
to use it from within Python itself:
>>> help (help)
Welcome to Python 2.4! This is the online help utility.
If this is your first time using Python, you should definitely check
out the tutorial on the Internet at http://www.python.org/doc/tut/.
Enter the name of any module, keyword, or topic to get help on writing
Python programs and using Python modules. To quit this help utility and
return to the interpreter, just type "quit".
To get a list of available modules, keywords, or topics, type
"modules","keywords", or "topics". Each module also comes with a
one-line summary of what it does; to list the modules whose summaries
contain a given word such as "spam", type "modules spam".
help> quit
You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)". Executing "help('string')"
has the same effect as typing a particular string at the help>
prompt.
>>>
Basic
help for csnd
Once csnd
is imported, pydoc can be used to extract
information about it's basic features:
>>>import csnd
>>>help (csnd)
Help on module csnd:
NAME
csnd
FILE
/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/csnd.py
MODULE DOCS
http://www.python.org/doc/current/lib/module-csnd.html
DESCRIPTION
# This file was automatically
generated by SWIG (http://www.swig.org).
# Version 1.3.31
#
# Don't modify this file,
modify the SWIG interface instead.
# This file is compatible with
both classic and new-style classes.
CLASSES
__builtin__.object
Csound
CppSound
CsoundArgVList
CsoundCallbackWrapper
CsoundChannelList
CsoundChannelListEntry
CsoundMYFLTArray
CsoundMidiInputBuffer
CsoundMidiInputStream
CsoundMidiOutputBuffer
CsoundMidiOutputStream
CsoundMutex
CsoundOpcodeList
CsoundPerformanceThread
CsoundRandMT
CsoundRandMTState
CsoundThreadLock
CsoundTimer
CsoundUtilityList
MyfltVector
PVSDATEXT
PySwigIterator
RTCLOCK
csCfgVariableBoolean_t
and so on.... (functions are listed at the end)
Take a moment to examine the help()
output on your own machine.
Notice that the CppSound class is indented
under the
Csound class. This indicates that the CppSound
class inherits the characteristics of the Csound
class.
The Same applies to
CsoundMidiInputStream and
CsoundMidiOutputStream.
Now let's have a look at the documentation
on the Csound class.
>>>help(csnd.Csound)
Help on class Csound in module csnd:
class Csound(__builtin__.object)
| Proxy of C++ Csound class
|
|
Methods defined here:
|
| AppendOpcode(*args)
| AppendOpcode(self, char
opname, int dsblksiz, int thread, char outypes,
|
char intypes, int iopadr, int kopadr, int aopadr) ->
int
|
| ChanIASet(*args)
| ChanIASet(self, float value,
int n) -> int
|
| ChanIKSet(*args)
| ChanIKSet(self, double
value, int n) -> int
|
| ChanOAGet(*args)
| ChanOAGet(self, float
value, int n) -> int
|
| ChanOKGet(*args)
| ChanOKGet(self, float
value, int n) -> int
|
| Cleanup(*args)
| Cleanup(self) -> int
|
| Compile(*args)
| Compile(self, int argc, char argv)
-> int
| Compile(self, char csdName) ->
int
| Compile(self, char orcName, char
scoName) -> int
| Compile(self, char arg1, char arg2,
char arg3) -> int
| Compile(self, char arg1, char arg2,
char arg3, char arg4) -> int
| Compile(self, char arg1, char arg2,
char arg3, char arg4, char arg5) -> int
|
| CreateConfigurationVariable(*args)
| CreateConfigurationVariable(self, char
name, void p, int type, int
flags, void min, void max,
| char
shortDesc, char longDesc) -> int
|
| CreateGlobalVariable(*args)
| CreateGlobalVariable(self, char name,
size_t nbytes) -> int
|
| DeleteChannelList(*args)
| DeleteChannelList(self, lst)
|
| DeleteConfigurationVariable(*args)
| DeleteConfigurationVariable(self, char
name) -> int
|
| DeleteUtilityList(*args)
| DeleteUtilityList(self, char lst)
and so on....
Let's examine a couple of methods of the Csound
class and to show how we can use this documentation to determine its
arguments.
The stuff between the "(" and ")".
Firstly, let's look at Cleanup()
Cleanup(self) -> int
Cleanup and all methods, have a
self
argument and, for the sake of this commentary, we'll
just ignore it, in ALL cases.
So the Cleanup method of the Csound
class takes no argument and returns an integer.
Displaying the
document string in methods, functions etc
If there was a document string in the Cleanup()
method, typing
>>>help (csnd.Csound.Cleanup)
would give you more information.
If you define a function with a document string immediately after the
def statement:
def cubed(a):
""" Returns the cube of a.
a:= any single number"""
return a * a * a
You can use help() to read the
document string:
>>> help (cubed)
Help on function cubed in module __main__:
cubed(a)
Returns the cube of a.
a:= any single number
>>>
And of course it can be used on Python builtin
functions:
>>> help (len)
Help on built-in function len in module __builtin__:
len(...)
len(object) -> integer
Return the number of items of a sequence
or mapping.
Using
pydoc
pydoc is Python's
native help module.
It can be run either as a separate shell process (enabling such things
as % pydoc -k <keyword> )
or run as a HTTP server on a specified port. You can find out
more information by importing the pydoc module and "helping" it.
>>> import pydoc
>>> help (pydoc)
-
- -
F I N - - -
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 |
|