Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Synth.activity/synth.py
blob: 8ff18bd28cfbca1002b9b62fd6181a5b8ce75a00 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# (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()