| Should the following Python code recognize when a .csd has finished
performing?
self.timer = False
if self.w.score_time():
self.timer = True
else:
if self.timer == True:
self.timer = False
[now .csd finished; go do something]
w.score_time() is a function from csndsugui which does simply:
return self.csound.GetScoreTime()
The csound.GetScoreTime() function doesn't seem to be doing anything for me.
My assumption is that after csndsugui's play(self) function starts playing a
.csd, the above routine would start checking the score time and return to
zero when the score finishes. Am I mistaken?
Alternately, what are other ways in which Python can know when a .csd has
come to a normal conclusion?
Art Hunkins
----- Original Message -----
From: "Art Hunkins"
To:
Sent: Thursday, January 13, 2011 5:02 PM
Subject: 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
>
------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net |