| I've got a Python/Sugar script for a new XO activity that should send ASCII
keystrokes to Csound. Csound then needs to process these keystrokes like
sensekey does, making use of the kkeydown parameter of sensekey, which
allows the ASCII value to be present (or counted) for a single k-cycle only.
This is important because the only function of the key-press-events is to
trigger the playing of an audio sample. (The ASCII value needs to return to
"zero" after a single k-cycle.)
I thought I could do this by simply using sensekey within Csound, but
apparently ASCII is not available to Csound when controlled by a Python
script (I tried this).
The Python snippets below send ASCII to my .csd fine, but the trouble is
that the ASCII values in the buffer remain unchanged until another key is
pressed - there is no returning to 0 or -1 in between. (For one thing,
*repeated* keypresses would seem not to work - and they need to.)
So I need either a modification of the code below to send only a
single-cycle's keystroke value to Csound, or something that will allow
sensekey to work in my .csd. Please send any and all ideas.
def onKeyPress(self, widget, event):
if self.p:
if self.ver > 1:
self.w.set_channel("ascii", event.keyval)
def playcsd(self, widget):
if self.p == False:
self.p = True
self.w.play()
self.but.child.set_label("STOP !")
self.but.child.set_use_markup(True)
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0xFFFF, 0, 0))
self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF, 0, 0))
if self.ver > 1:
self.connect("key-press-event", self.onKeyPress)
Art Hunkins
------------------------------------------------------------------------------
uberSVN's rich system and user administration capabilities and model
configuration take the hassle out of deploying and managing Subversion and
the tools developers use with it. Learn more about uberSVN and get a free
download at: http://p.sf.net/sfu/wandisco-dev2dev
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |