Csound Csound-dev Csound-tekno Search About

[Cs-dev] csndsugui/python question

Date2011-01-13 22:02
From"Art Hunkins"
Subject[Cs-dev] csndsugui/python question
A question mostly for Victor - but any other help greatly appreciated:

The following Python/csndsugui code (for a Sugar-on-a-Stick project of mine)
works nicely: pressing the callback button  alternates between starting and
stopping an ongoing .csd performance.

For this particular project, however, the .csd - unlike previous projects - 
may well
run to completion, and I'd like to simulate a "callback-button-off press" 
when the .csd
ends. (This way the user doesn't need to press the button twice.)

Here's the original code that works:

 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))
   else:
     self.p = False
     self.w.recompile()
     self.w.channels_reinit()
     self.send_data()
     self.but.child.set_label("START !")
     self.but.child.set_use_markup(True)
     self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
     self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))

   self.p = False
   self.but = self.w.cbbutton(self.b7, self.playcsd, "START !")
   self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
   self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))


I've added the code below to try to call playcsd (with self.p == True) when
the .csd concludes, but it doesn't work. (The code follows immediately after 
the above snippet, and is loosely adapted from Victor's PlayMIDI activity.) 
Obviously I'm not working with the timer (from
csndsugui) correctly. Can someone correct the following? Many thanks.

   self.time = self.w.score_time()
   self.w.set_timer(100, self.time_callback, self)
   if self.w.stopcb == True:
     self.p == True
     self.playcsd(self.but)

 def time_callback(self, data):
   self.time = self.w.score_time()
   return True

Art Hunkins


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net