Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Playmidi.activity/playmidi.py
blob: ccbbea2b07d907c69536f8b19e7b27f3a4b7aead (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

# (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"]])