Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Playmidi.activity/playmidi.py
blob: e0180ab735fecc9ab4708b2d654dcf0840af6a9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

# (c) Victor Lazzarini, 2006
#  Free software, licensed by GNU General Public License
import csndsugui
import csnd
from sugar.activity import activity
import gtk, gobject

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 MIDI",colour=white)
   hbox = win.box(False, padding=400)
   vbox = win.box(True, hbox, padding=400)
   self.ndisp = win.numdisplay(vbox,"time",0.0)
   bbox = win.box(False,vbox)
   win.filechooser(bbox,"midifile")
   self.p = None
   self.but = win.cbbutton(bbox, self.fcall, "load")
   self.w = win
   self.b = bbox
   

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

 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")
      self.time = self.w.score_time()
      self.w.set_timer(100, self.time_callback, self)
     else: 
      self.w.reset()
      self.w.compile("gm.csd", ["-F%s" % self.w.filenames["midifile"]])
      self.time = self.w.score_time()