Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
diff options
authorVictor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 19:41:06 (GMT)
committer Victor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 19:41:06 (GMT)
commit071fc9b4a2589643658f9ca78a63d65b97d26e9a (patch)
parent8e3e83ff6d90d05bef8750d2eb98faf68733bbcf (diff)
Added a basic tutorial for writing activities
1 files changed, 78 insertions, 0 deletions
diff --git a/writing-activities.txt b/writing-activities.txt
new file mode 100644
index 0000000..fc1e3b0
--- /dev/null
+++ b/writing-activities.txt
@@ -0,0 +1,78 @@
+Writing activities using csndsugui
+1. Import the relevant modules
+import csndsugui
+from sugar.activity import activity
+2. Create an empty activity class, such as
+class MyCsoundActivity(activity.Activity):
+ def __init__(self, handle):
+ activity.Activity.__init__(self, handle)
+3. Instantiate a CsoudGUI object, passing the
+activity instance as an argument:
+ win = csndsugui.CsoundGUI(self)
+4. Set and compile Csound code:
+ win.CSD("mycode.csd")
+It is CRUCIAL that Csound compiles successfully before
+the widgets below are created. Otherwise they will not
+be assigned channels in the software bus and thus will
+not communicate with Csound. This method returns 0 if
+5. Use boxes to format and contain widgets, child boxes can be
+contained within parent boxes. The top-level box does not have
+any parents.
+ box = win.box()
+See the documentation on PyGTK on how boxes are used to
+set the formatting. CsoundGUI will take care of all the
+packing for you.
+6. You can then add widgets to it, ie:
+ win.button(box,"oscil")
+ win.slider(1.0,0.25,4.0,90,250,box,"pitch", linear=False)
+7. In your Csound code, you can retrieve the value
+of each of the controls in channels of the software bus:
+kosc chnget "oscil"
+kpit chnget "pitch"
+Channel names will be linked to widget labels ("oscil" and
+"pitch" in the example above)
+8. Most widgets will work within the principle outlined
+above. Important exceptions are:
+8.1 Message button: mbutton(self,box,mess,title="")
+where mess is a RT score event or message to
+be sent to Csound (in most cases an i-statement,
+but f-statements are also possibilities).
+8.2 Callback button: cbbutton(self,box,callback,title="")
+where callback is a Python function that will
+be invoked when the button is clicked.
+8.3 Special button names: "play", "pause" and
+"reset". These are assigned special messages that are
+not captured by the software bus. Instead, they
+can control Csound performance, starting, pausing
+and reset Csound performance (they are linked
+to CsoundGUI.play(), CsoundGUI.pause() and
+CsoundGUI.reset() methods.)
+On-line help can be obtained by importing the
+csndsugui module and involking help(csndsugui).
+Victor Lazzarini, 2008