This material is by Wu-Hsi Li. (Courtesy of Wu-Hsi Li. Used with permission.)
# Start by downloading gtkexercise.py (PY)
# "cd /home/olpc/Activities/Musicpainter.activity"
# We're going to borrow the csound orchestra, sound samples and
# other python programs from Musicpainter, so please put gtkexercise.py
# under the same folder with Musicpainter.activity.
# "fget http://www.media.mit.edu/~wuhsi/csoundxo/gtkexercise.py"
# If fget doesn't work, make sure your green machine is connected to the Internet.
# When the machine is connected, the browser should allow you to browse any webpage.
# Also, if you open a terminal, you can get your IP by the command "ifconfig".
# If you don't have a Internet IP, your machine is not connected (yet).
# You can use text editor like vi to edit your py file ("vi gtkexercise.py")
# Please try to read the python program
# To run the program, do "python gtkexercise.py"
# This program will display the keyboard and mouse events it captures on the screen
# Press "Escape" key to leave the program
# In key_press_event(), you can find the following line
# self.sendCsoundEvt("write your own csound line event")
# You can try to rewrite the event string
csound1.sendLinevt("i8 0 2 1 0")
csound1.sendLinevt("i1 0 1 1 7.00") # format information see below
csound1.sendLinevt("i1 0 1 1 7.02") # these are a note event with finite duration
csound1.sendLinevt("i1 0 1 1 7.04")
csound1.sendLinevt("i1 0 1 2 7.04")
csound1.sendLinevt("i1 0 5 2 7.04")
# line event format
#
# field 1: instrument, 1: piano, 2: accordion, 3: string, 4: pizz, 5: clarinet, 6: guitar, 7: bass, 8: percussion
# field 2: start time (sec)
# field 3: duration (sec)
# field 4: volume, 1.0 = normal
# field 5: for percussion instrument, assign 0 ~ 17 for different sounds
# for pitch instrument, assign a.bb,
# for example 8.00 is a C5, 8.01 is C#5, 8.02 is D5, 7.00 is a C4
# If you rewrite both event strings in key_press_event and key_release_event
# the duration of note_on event should be assigned -1 (infinite)
# and the duration of note_off event should be assigned 0