# (c) Victor Lazzarini, 2008 # Free software, licensed by GNU General Public License import csndsugui from sugar.activity import activity class Synth(activity.Activity): def __init__(self, handle): activity.Activity.__init__(self, handle) # colours bg = (0x9000,0,0) fr = (0x1000, 0x0000, 0x7000) # GUI window self.win = csndsugui.CsoundGUI(self,bg) if self.win.compile("synth.csd",["-Mhw:1,0"]): self.win.csd("synth.csd") txt = self.win.text("Synthesizer Panel",colour=fr) hbox = self.win.box(False) # oscillator frames box = self.win.box(parent=hbox) box1 = self.win.box(False, box) box2 = self.win.box(False, box) frame1 = self.win.framebox("osc 1", False, box1, fr) frame2 = self.win.framebox("osc 2", False, box2, fr) # oscillator 1 controls box = self.win.box(parent=frame1) self.win.button(box,"osc1") box = self.win.box(parent=frame1) self.win.slider(1.0,0.25,4.0,90,250,box,"pitch1", linear=False) # oscillator 2 controls box = self.win.box(parent=frame2) self.win.button(box,"osc2") box = self.win.box(parent=frame2) self.win.slider(1.0,0.25,4.0,90,250,box,"pitch2", linear=False) # filter & mixer frames box = self.win.box(parent=hbox) box1 = self.win.box(False, box) box2 = self.win.box(False, box) frame1 = self.win.framebox("filter", True, box1, fr) frame2 = self.win.framebox("mixer", False, box2, fr) # filter controls box = self.win.box(False, parent=frame1) self.win.slider(1000.0,20.0,20000.0,250,40,box,"frequency", False,linear=False) box = self.win.box(False, parent=frame1) self.win.slider(0.9,0.0,1.0,250,40,box,"resonance", False) # mixer controls box = self.win.box(parent=frame2) self.win.slider(0.0,0.0,100.0,90,360,box,"vol1") box = self.win.box(parent=frame2) self.win.slider(0.0,0.0,100.0,90,360,box,"vol2") box = self.win.box(parent=frame2) self.win.slider(0.0,0.0,100.0,90,360,box,"noise") box = self.win.box(parent=frame2) self.win.slider(0.0,0.0,100.0,90,360,box,"mic") self.win.play() def write_file(self,filepath): self.win.logger.debug("write_file\n\n") self.win.set_channel_metadata() f = open(filepath, 'w') f.close() def read_file(self,filepath): self.win.logger.debug("read_file \n\n") self.win.get_channel_metadata()