# (c) Victor Lazzarini, 2006 # Free software, licensed by GNU General Public License import csndsugui import csnd from sugar.activity import activity import gtk class Playmidi(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) # colour bg = (0x0000, 0x7000, 0xA000) white = (0xFFFF, 0xFFFF, 0xFFFF) win = csndsugui.CsoundGUI(self, bg) win.text("Playing Sounds",colour=white) bbox = win.box(False) win.filechooser(bbox,"midifile") self.p = None self.but = win.cbbutton(bbox, self.fcall, "load") self.w = win self.b = bbox def fcall(self, widget): if self.p == None: self.w.compile("gm.csd", ["-F%s" % self.w.filenames["midifile"]]) self.p = self.w.button(self.b,"play") self.w.button(self.b,"pause") self.but.set_label("rewind/reload") else: self.w.reset() self.w.compile("gm.csd", ["-F%s" % self.w.filenames["midifile"]])