Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Synth.activity
diff options
context:
space:
mode:
authorVictor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 16:29:54 (GMT)
committer Victor Lazzarini <Victor.Lazzarini@nuim.ie>2008-03-18 16:29:54 (GMT)
commit6ed432c2a6deaa3a26bf4907df7f0c1b0e8c41d1 (patch)
tree8f5d1a7efc30031c182b0aeedd0c2b66a68d1412 /Synth.activity
Initial import
Diffstat (limited to 'Synth.activity')
-rwxr-xr-xSynth.activity/activity/activity-synth.svg22
-rwxr-xr-xSynth.activity/activity/activity-synth.svg~22
-rwxr-xr-xSynth.activity/activity/activity.info7
-rwxr-xr-xSynth.activity/activity/activity.info~7
-rwxr-xr-xSynth.activity/activity/synth.info7
-rwxr-xr-xSynth.activity/csndsugui.py605
-rwxr-xr-xSynth.activity/csndsugui.pycbin0 -> 15841 bytes
-rwxr-xr-xSynth.activity/manifest7
-rwxr-xr-xSynth.activity/setup.py5
-rwxr-xr-xSynth.activity/synth.csd151
-rwxr-xr-xSynth.activity/synth.py66
-rwxr-xr-xSynth.activity/synth.pycbin0 -> 2044 bytes
12 files changed, 899 insertions, 0 deletions
diff --git a/Synth.activity/activity/activity-synth.svg b/Synth.activity/activity/activity-synth.svg
new file mode 100755
index 0000000..22cc935
--- /dev/null
+++ b/Synth.activity/activity/activity-synth.svg
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY fill_color "#FFFFFF">
+ <!ENTITY stroke_color "#000000">
+]>
+<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
+ <rect x="1" y="1" width="48" height="48"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2"/>
+<ellipse cx = "24" cy ="24"
+ rx="25" ry="10"
+ fill="white" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="30" ry="14"
+ fill="black" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="34" ry="18"
+ fill="white" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="38" ry="22"
+ fill="none" stroke="white" stroke-width="2" />
+</svg>
diff --git a/Synth.activity/activity/activity-synth.svg~ b/Synth.activity/activity/activity-synth.svg~
new file mode 100755
index 0000000..4348099
--- /dev/null
+++ b/Synth.activity/activity/activity-synth.svg~
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
+ <!ENTITY fill_color "#FFFFFF">
+ <!ENTITY stroke_color "#000000">
+]>
+<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">
+ <rect x="1" y="1" width="48" height="48"
+ style="fill:&fill_color;;stroke:&stroke_color;;stroke-width:2"/>
+<ellipse cx = "24" cy ="24"
+ rx="25" ry="10"
+ fill="white" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="30" ry="14"
+ fill="none" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="34" ry="18"
+ fill="none" stroke="white" stroke-width="2" />
+<ellipse cx = "24" cy ="24"
+ rx="38" ry="22"
+ fill="white" stroke="white" stroke-width="2" />
+</svg>
diff --git a/Synth.activity/activity/activity.info b/Synth.activity/activity/activity.info
new file mode 100755
index 0000000..06270c5
--- /dev/null
+++ b/Synth.activity/activity/activity.info
@@ -0,0 +1,7 @@
+[Activity]
+name = MiniSynth
+service_name = org.laptop.MSynth
+class = synth.Synth
+icon = activity-synth
+activity_version = 1
+show_launcher = yes
diff --git a/Synth.activity/activity/activity.info~ b/Synth.activity/activity/activity.info~
new file mode 100755
index 0000000..4a156ee
--- /dev/null
+++ b/Synth.activity/activity/activity.info~
@@ -0,0 +1,7 @@
+[Activity]
+name = MidiSynth
+service_name = org.laptop.MSynth
+class = synth.Synth
+icon = activity-synth
+activity_version = 1
+show_launcher = yes
diff --git a/Synth.activity/activity/synth.info b/Synth.activity/activity/synth.info
new file mode 100755
index 0000000..e3023d9
--- /dev/null
+++ b/Synth.activity/activity/synth.info
@@ -0,0 +1,7 @@
+[Activity]
+name = Synth
+service_name = org.laptop.Synth
+class = synth.Synth
+icon = activity-synth
+activity_version = 1
+show_launcher = yes
diff --git a/Synth.activity/csndsugui.py b/Synth.activity/csndsugui.py
new file mode 100755
index 0000000..f4c8b10
--- /dev/null
+++ b/Synth.activity/csndsugui.py
@@ -0,0 +1,605 @@
+# sugar-aware GUI classes
+# with boxes, sliders, spinbuttons, buttons, etc
+#
+# (c) Victor Lazzarini, 2006-08
+#
+# This library is free software; you can redistribute it
+# and/or modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# csndsugui is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with csndsugui; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA
+#
+# As a special exception, if other files instantiate templates or
+# use macros or inline functions from this file, this file does not
+# by itself cause the resulting executable or library to be covered
+# by the GNU Lesser General Public License. This exception does not
+# however invalidate any other reasons why the library or executable
+# file might be covered by the GNU Lesser General Public License.
+#
+#
+# version 0.1.1 14/03/08
+
+import pygtk
+pygtk.require('2.0')
+from sugar.activity import activity
+import gtk
+import sys
+import csnd
+import math
+import locale
+import os
+
+# Basic GUI with boxes, sliders, spins, buttons etc
+# using pygtk/sugar, from which GUI classes
+# can be derived for Csound use
+class BasicGUI:
+
+ # basic bus channel setting method,
+ # should be overriden for full-functionality
+ def set_channel(self,name, val):
+ print "channel:%s, value:%.1f" % (name,val)
+
+ # basic filename channel setting method
+ # should be overriden for full-functionality
+ def set_filechannel(self,chan,name):
+ print "channel:%s, filename:%s" % (chan,name)
+
+ # basic message setting method
+ # should be overriden for full-functionality
+ def set_message(self, mess):
+ print mess
+
+ # returns the slider value
+ #
+ # name: slider name (which should also be
+ # the attached bus channel name)
+ def get_slider_value(self,name):
+ for i in self.sliders:
+ if i[1] == name:
+ return i[2]
+ return 0
+
+ # returns the button value (0 or 1)
+ #
+ # name: button name (which should also be
+ # the attached bus channel name)
+ def get_button_value(self,name):
+ for i in self.buttons:
+ if i[1] == name:
+ return i[2]
+ return 0
+
+ # returns the slider widget instance
+ #
+ # name: slider name
+ def get_slider(self,name):
+ for i in self.sliders:
+ if i[1] == name:
+ return i[0]
+ return 0
+
+ # returns the button widget instance
+ #
+ # name: button name
+ def get_button(self,name):
+ for i in self.sliders:
+ if i[1] == name:
+ return i[0]
+ return 0
+
+ # internal button callback
+ def buttcallback(self, widget, data=None):
+ for i in self.buttons:
+ if i[0] == widget:
+ if i[2]:
+ i[2] = 0
+ i[0].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x0FFF,0,0x00FF, 2))
+ i[0].modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0xFFFF, 2))
+ else:
+ i[2] = 1
+ i[0].modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0xFFFF,0,0, 1))
+ i[0].modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0, 2))
+ self.set_channel(i[1], i[2])
+
+ # internal button callback
+ def mbuttcallback(self, widget, data=None):
+ for i in self.buttons:
+ if i[0] == widget:
+ self.set_message(i[2])
+
+ # internal slider callback
+ def slidcallback(self,adj,widget):
+ for i in self.sliders:
+ if i[0] == widget:
+ i[2] = adj.value
+ if i[4]:
+ self.set_channel(i[1],i[2])
+ i[3].set_text("%f" % i[2])
+ pass
+ else:
+ value = i[5]*pow(i[6]/i[5], i[2]/i[6])
+ self.set_channel(i[1], value)
+ i[3].set_text("%.3f" % value)
+ pass
+
+ # internal spin callback
+ def spincallback(self,adj,widget):
+ for i in self.spins:
+ if i[0] == widget:
+ i[2] = adj.value
+ self.set_channel(i[1],i[2])
+
+ # internal callback
+ def filecallback(self,widget):
+ name = self.curfile[0].get_filename()
+ self.set_filechannel(self.curfile[1], name)
+ self.filenames.update({self.curfile[1] : name})
+ self.curfile[0].destroy()
+
+ # internal callback
+ def fbuttcallback(self, widget, data=None):
+ for i in self.buttons:
+ if i[0] == widget:
+ chooser = gtk.FileSelection(i[1])
+ self.curfile = (chooser, i[1])
+ chooser.set_filename(self.data_path)
+ chooser.ok_button.connect("clicked", self.filecallback)
+ chooser.cancel_button.connect("clicked", lambda h: chooser.destroy())
+ chooser.show()
+
+ # creates a callbackbutton ()
+ #
+ # box: parent box
+ # callback: click callback
+ # title: if given, the button name
+ # in order of creation.
+ # returns the widget instance
+ def cbbutton(self,box,callback,title=""):
+ self.cbbutts = self.cbbutts + 1
+ butt = gtk.Button(" %s " % title)
+ box.pack_start(butt, False, False, 5)
+ self.cbbuttons.append([butt,title,0])
+ butt.connect("clicked", callback)
+ butt.show()
+ return butt
+
+ # creates a button (on/off)
+ #
+ # box: parent box
+ # title: if given, the button name,
+ # which will also be the bus channel
+ # name. Otherwise a default name is
+ # given, BN, where N is button number
+ # in order of creation.
+ # returns the widget instance
+ def button(self,box, title=""):
+ self.butts = self.butts + 1
+ if title == "":
+ title = "B%d" % self.butts
+ butt = gtk.Button(" %s " % title)
+ butt.modify_bg(gtk.STATE_ACTIVE, gtk.gdk.Color(0xFFFF,0,0, 1))
+ butt.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0xFFFF, 2))
+ box.pack_start(butt, False, False, 5)
+ self.buttons.append([butt,title,0])
+ butt.connect("clicked", self.buttcallback)
+ butt.show()
+ return butt
+
+ # creates a mbutton (sending a message)
+ #
+ # box: parent box
+ # title: if given, the button name,
+ # which will also be the bus channel
+ # name. Otherwise a default name is
+ # given, BN, where N is button number
+ # in order of creation.
+ # mess: message to be sent when button is clicked
+ # returns the widget instance
+ def mbutton(self,box,mess,title=""):
+ self.mbutts = self.mbutts + 1
+ if title == "":
+ title = "B%d" % self.mbutts
+ butt = gtk.Button(title)
+ butt.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x0FFF,0,0x00FF, 1))
+ butt.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0xFFFF,0x0000, 2))
+ box.pack_start(butt, False, False, 5)
+ self.buttons.append([butt,title,mess])
+ butt.connect("clicked", self.mbuttcallback)
+ butt.show()
+ return butt
+
+ # creates a box
+ #
+ # vert: True, creates a vertical box; horiz.
+ # otherwise
+ # parent: parent box, None if this is a toplevel box
+ # padding: box padding
+ # returns the widget instance
+ def box(self,vert=True, parent=None, padding=5):
+ if vert:
+ box = gtk.VBox()
+ else:
+ box = gtk.HBox()
+ if parent:
+ parent.pack_start(box, False, False, padding)
+ else:
+ self.outbox.pack_start(box, False, False, padding)
+ self.boxes.append(box)
+ box.show()
+ return box
+
+ # creates a filechooser button
+ # title: button name, also file bus channel name
+ # box: parent box
+ def filechooser(self,box,title):
+ butt = gtk.Button(title)
+ box.pack_start(butt, False, False, 5)
+ self.buttons.append([butt,title])
+ butt.connect("clicked", self.fbuttcallback)
+ self.set_filechannel(title,"0")
+ self.filenames.update({title:"0"})
+ butt.show()
+ return butt
+
+ # creates a slider
+ #
+ # init: initial value
+ # start, end: start and end of slider range
+ # x, y: x and y sizes of slider
+ # box: parent box
+ # title: if given, the slider name,
+ # which will also be the bus channel
+ # name. Otherwise a default name is
+ # given, SN, where N is slider number
+ # in order of creation.
+ # vert: vertical slider (True), else horiz.
+ # linear: linear response (True), else exponential (zero or negative
+ # ranges are not allowed)
+ # dwid: display width in pixels
+ # returns the widget instance
+ def slider(self,init, start, end, x, y, box, title="",vert=True,linear=True,dwid=100):
+ self.slids = self.slids + 1
+ if title == "":
+ title = "S%d" % self.slids
+ a = end - start
+ if vert:
+ step = a/y
+ adj = gtk.Adjustment(init,start,end,step,step,0)
+ slider = gtk.VScale(adj)
+ slider.set_inverted(True)
+ else:
+ step = a/x
+ adj = gtk.Adjustment(init,start,end,step,step,0)
+ slider = gtk.HScale(adj)
+
+ slider.set_draw_value(False)
+ if step < 1.0:
+ slider.set_digits(3)
+ elif step < 10:
+ slider.set_digits(2)
+ elif step < 100:
+ slider.set_digits(1)
+ else:
+ slider.set_digits(0)
+
+ entry = gtk.Entry(5)
+ if vert: entry.set_size_request(dwid,50)
+ else: entry.set_size_request(dwid,50)
+ entry.set_editable(False)
+
+ if not linear:
+ if (init <= 0) or (start <= 0) or (end <= 0):
+ linear = True
+
+ if not linear:
+ pos = end*math.log(1,end/start)
+ slider.set_range(pos, end)
+ pos = end*math.log(init/start,end/start)
+ slider.set_value(pos)
+
+ entry.set_text("%f" % init)
+ label = gtk.Label(title)
+ slider.set_size_request(x,y)
+ box.pack_start(slider, False, False, 5)
+ box.pack_start(entry, False, False, 2)
+ box.pack_start(label, False, False, 2)
+ self.sliders.append([slider,title,init,entry,linear,start,end])
+ adj.connect("value_changed", self.slidcallback, slider)
+ slider.show()
+ entry.show()
+ label.show()
+ self.set_channel(title, init)
+ return slider
+
+
+ # creates a spin button
+ #
+ # init: initial value
+ # start, end: start and end of slider range
+ # step, page: small and large step sizes
+ # box: parent box
+ # accel: acceleration or 'climb rate' (0.0-1.0)
+ # title: if given, the slider name,
+ # which will also be the bus channel
+ # name. Otherwise a default name is
+ # given, SPN, where N is spin number
+ # in order of creation.
+ # returns the widget instance
+ def spin(self,init, start, end, step, page, box, accel=0, title=""):
+ self.spinbs = self.spinbs + 1
+ if title == "":
+ title = "SP%d" % self.spinbs
+ adj = gtk.Adjustment(init,start,end,step,page,0)
+ spin = gtk.SpinButton(adj,accel)
+ if step < 1.0:
+ spin.set_digits(3)
+ elif step < 10:
+ spin.set_digits(2)
+ elif step < 100:
+ spin.set_digits(1)
+ else:
+ spin.set_digits(0)
+
+ label = gtk.Label(title)
+ box.pack_start(spin, False, False, 5)
+ box.pack_start(label, False, False, 2)
+ self.spins.append([spin,title,init])
+ adj.connect("value_changed", self.spincallback, spin)
+ spin.show()
+ label.show()
+ self.set_channel(title, init)
+ return spin
+
+
+ # creates a static text label
+ #
+ # name: text label
+ # box: parent box, None if text is to be placed toplevel
+ # colour: RGB values in a tuple (R,G,B)
+ # returns the widget instance
+ def text(self, name, box=None,colour=(0,0,0)):
+ label = gtk.Label(name)
+ label.modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(colour[0],colour[1],colour[2], 0))
+ if box:
+ box.pack_start(label, False, False, 5)
+ else:
+ self.outbox.pack_start(label, False, False, 5)
+ label.show()
+ return label
+
+ # creates a frame box
+ #
+ # name: text label
+ # vert: vertical (True) box, else horiz.
+ # parent: parent box, if None, this is a toplevel box
+ # colour: RGB values in a tuple (R,G,B)
+ # padding: padding space
+ # returns the box widget instance
+ def framebox(self, name, vert=True, parent=None, colour=(0,0,0), padding=5):
+ frame = gtk.Frame(name)
+ frame.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(colour[0],colour[1],colour[2], 0))
+ frame.get_label_widget().modify_fg(gtk.STATE_NORMAL, gtk.gdk.Color(colour[0],colour[1],colour[2], 0))
+ if parent:
+ parent.pack_start(frame, False, False, padding)
+ else:
+ self.outbox.pack_start(frame, False, False, padding)
+ if vert:
+ box = gtk.VBox()
+ else:
+ box = gtk.HBox()
+ frame.add(box)
+ frame.show()
+ box.show()
+ return box
+
+
+ # creates a vertical slider bank
+ #
+ # items: number of sliders
+ # init: initial value
+ # start, end: start and end of slider range
+ # x, y: x and y sizes of slider
+ # box: parent box
+ def vsliderbank(self,items,init, start, end, x, y, box):
+ slid = self.slids
+ for i in range(slid, slid+items):
+ cbox = self.box(parent=box)
+ self.slider(init,start,end,x,y,cbox)
+
+ # creates a horizontal slider bank
+ #
+ # items: number of sliders
+ # init: initial value
+ # start, end: start and end of slider range
+ # x, y: x and y sizes of slider
+ # box: parent box
+ def hsliderbank(self,items,init, start, end, x, y, box):
+ slid = self.slids
+ for i in range(slid, slid+items):
+ cbox = self.box(False,box)
+ self.slider(init,start,end,x,y,cbox,"",False)
+
+
+ # creates a button bank
+ #
+ # items: number of sliders
+ # box: parent box
+ def buttonbank(self,items, box):
+ start = self.butts
+ for i in range(start, start+items):
+ self.button(box)
+
+ # internal callback
+ def delete_event(self, widget, event, data=None):
+ return False
+
+ # get the toolbox
+ def get_toolbox(self):
+ return self.toolbox
+
+ # constructor
+ # act: activity object
+ # colour: bg colour RGB tuple (R,G, B)
+ # vert: True for vertical topmost arrangement, horiz. otherwise
+ # toolbox: activity toolbox object, if None (default) a
+ # standard toolbox will be supplied
+ def __init__(self,act,colour=(-1,-1,-1),vert=True,toolbox=None):
+ self.sliders = []
+ self.slids = 0
+ self.spins = []
+ self.spinbs = 0
+ self.buttons = []
+ self.butts = 0
+ self.cbbuttons = []
+ self.cbbutts = 0
+ self.mbuttons = []
+ self.mbutts = 0
+ self.boxes = []
+ self.filenames = dict()
+ self.window = act
+ if toolbox == None:
+ self.toolbox = activity.ActivityToolbox(self.window)
+ else: self.toolbox = toolbox
+ self.window.set_toolbox(self.toolbox)
+ self.toolbox.show()
+ if colour[0] >= 0:
+ self.window.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(colour[0],colour[1],colour[2], 0))
+
+
+ if vert: self.outbox = gtk.VBox()
+ else: self.outbox = gtk.HBox()
+
+ self.window.set_canvas(self.outbox)
+ self.data_path = os.path.join(act.get_activity_root(),"data/")
+ self.outbox.show()
+
+# A class inheriting from BasicGUI
+# containing a Csound instance and
+# a performance thread instance
+class CsoundGUI(BasicGUI):
+
+ # overrides the base method
+ # sets the bus channel value
+ # called by the widget callbacks
+ # channel names 'play', 'pause' and
+ # 'reset' are reserved for these
+ # respective uses
+ def set_channel(self,name,val):
+ if not self.ready:
+ if name == "play":
+ self.play()
+ elif name == "pause":
+ self.pause()
+ elif name == "reset":
+ self.reset()
+ self.csound.SetChannel(name,val)
+ else:
+ BasicGUI.set_channel(self,name,val)
+
+ # overrides the base method
+ # sets the file bus channel string
+ def set_filechannel(self,chan,name):
+ if not self.ready:
+ self.csound.SetChannel(chan,name)
+ else:
+ BasicGUI.set_filechannel(self,chan,name)
+
+
+ # overrides the base method
+ # sends a score message
+ def set_message(self, mess):
+ self.perf.InputMessage(mess)
+
+ # starts a performance
+ def play(self):
+ if not self.on:
+ if self.paused: return
+ self.on = True
+ self.perf.Play()
+ else:
+ self.on = False
+ self.perf.Pause()
+
+ # pauses a performance
+ def pause(self):
+ if self.on:
+ self.on = False
+ self.paused = True
+ self.perf.Pause()
+ elif self.paused:
+ self.on = True
+ self.paused = False
+ self.perf.Play()
+
+ # sets the source CSD and compiles it
+ #
+ # name: CSD filename
+ # extra: one extra parameter
+ # returns zero if successful
+ def csd(self, name, extra=None):
+ self.extra = extra
+ path = activity.get_bundle_path()
+ if self.ready:
+ if self.extra != None:
+ res = self.csound.Compile("%s/%s" % (path,name), extra)
+ else:
+ res = self.csound.Compile("%s/%s" % (path,name))
+ if not res: self.ready = False
+ self.path = path
+ self.name = name
+ return res
+
+ # recompiles csound with the set CSD
+ # returns zero if successful
+ def recompile(self):
+ if not self.ready and self.name != "0":
+ self.perf.Stop()
+ self.perf.Join()
+ self.on = False
+ self.paused = False
+ self.perf = csnd.CsoundPerformanceThread(self.csound)
+ if self.extra != None:
+ res = self.csound.Compile("%s/%s" % (self.path,self.name), self.extra)
+ else:
+ res = self.csound.Compile("%s/%s" % (self.path,self.name))
+ if(res): self.ready = True
+ return res
+
+ # resets Csound ready for a new CSD
+ def reset(self):
+ if not self.ready:
+ self.perf.Stop()
+ self.perf.Join()
+ self.on = False
+ self.pause = False
+ self.perf = csnd.CsoundPerformanceThread(self.csound)
+ self.ready = True
+
+ # internal callback
+ def close(self, event):
+ self.reset()
+ sys.exit(0)
+
+ # constructor
+ # act: activity object
+ # colour: bg colour RGB tuple (R,G, B)
+ # vert: True for vertical topmost arrangement, horiz. otherwise
+ def __init__(self,act,colour=(-1,-1,-1),vert=True):
+ locale.setlocale(locale.LC_NUMERIC, 'C')
+ self.csound = csnd.Csound()
+ self.perf = csnd.CsoundPerformanceThread(self.csound)
+ BasicGUI.__init__(self,act,colour,vert)
+ self.ready = True
+ self.on = False
+ self.paused = False
+ self.name = "0"
+
diff --git a/Synth.activity/csndsugui.pyc b/Synth.activity/csndsugui.pyc
new file mode 100755
index 0000000..356ed30
--- /dev/null
+++ b/Synth.activity/csndsugui.pyc
Binary files differ
diff --git a/Synth.activity/manifest b/Synth.activity/manifest
new file mode 100755
index 0000000..5f958c1
--- /dev/null
+++ b/Synth.activity/manifest
@@ -0,0 +1,7 @@
+setup.py
+synth.csd
+activity/synth.info
+activity/activity-synth.svg
+csndsugui.py
+synth.py
+MANIFEST
diff --git a/Synth.activity/setup.py b/Synth.activity/setup.py
new file mode 100755
index 0000000..b4cc89b
--- /dev/null
+++ b/Synth.activity/setup.py
@@ -0,0 +1,5 @@
+#!/usr/bin/env python
+from sugar.activity import bundlebuilder
+if __name__ == "__main__":
+ bundlebuilder.start("Synth")
+
diff --git a/Synth.activity/synth.csd b/Synth.activity/synth.csd
new file mode 100755
index 0000000..0794b6e
--- /dev/null
+++ b/Synth.activity/synth.csd
@@ -0,0 +1,151 @@
+<CsoundSynthesizer>
+<CsOptions>
+-odac -iadc -d -m0 -b2048 -B4096 -+rtaudio=alsa -+rtmidi=alsa
+</CsOptions>
+<CsInstruments>
+/* add -M0 if you have MIDI (possibly -+rtmidi=virtual) */
+sr=44100
+ksmps=64
+nchnls=2
+
+gamix init 0
+gkchk init 0
+gkfun init 400
+massign 1, 11
+
+
+instr 11
+
+gkchk = 1 /* activates MIDI input */
+gkfun cpsmidib /* gets the key freq */
+
+endin
+
+/* oscillator 1 */
+instr 1
+
+
+kon init 1 /* initially ON */
+if gkchk == 1 then /* if MIDI is present, checks for key press */
+kon active 11 /* checks for key press to control amp */
+endif
+
+iamp = p4
+kamp init 0
+
+kp chnget "pitch1"
+
+kfun tonek gkfun*kp, 10
+
+if kon == 0 then
+kamp = 0 /* amp = 0 if not ON */
+else
+kamp chnget "vol1" /* otherwise amp comes from mixer */
+endif
+kamp tonek kamp, 10
+
+asig oscili p4, kfun, 1
+gamix = gamix + asig*ampdb(kamp-100)
+
+endin
+
+instr 2
+
+kon init 1
+if gkchk == 1 then
+kon active 11
+endif
+
+iamp = p4
+kamp init 0
+
+kp chnget "pitch2"
+
+kfun tonek gkfun*kp, 10
+
+if kon == 0 then
+kamp = 0
+else
+kamp chnget "vol2"
+endif
+kamp tonek kamp, 10
+
+asig buzz p4, kfun, sr/(2*kfun), 2
+gamix = gamix + asig*ampdb(kamp-100)
+
+endin
+
+instr 10
+
+kon init 1 /* initially ON */
+if gkchk == 1 then /* if MIDI is present, checks for key press */
+kon active 11 /* checks for key press to control amp */
+endif
+
+if kon == 0 then
+k1 = 0 /* fr = 0 if not ON */
+else
+k1 chnget "frequency" /* otherwise amp comes from mixer */
+endif
+
+ain1,ain2 ins
+ain = (ain1+ain2)/2
+anoi rand 16000
+
+;k1 chnget "frequency"
+kcf port k1, 0.05
+k2 chnget "resonance"
+kres tonek k2, 10
+k3 chnget "noise"
+knoi tonek k3, 10
+k4 chnget "mic"
+kin tonek k4, 10
+asig = gamix + anoi*ampdb(knoi-100) + ain*ampdb(kin-100)
+afil moogvcf2 asig, kcf, kres
+ outs afil*10,afil*10
+
+gamix = 0
+endin
+
+instr 100
+k1 init 1
+kb1 chnget "osc1"
+
+if kb1 == 1 then
+if k1 == 1 then
+event "i", 1, 0, -1, 16000
+k1=0
+endif
+else
+if k1 == 0 then
+event "i", -1, 0, -1, 16000
+k1=1
+endif
+endif
+k2 init 1
+kb2 chnget "osc2"
+
+if kb2 == 1 then
+if k2 == 1 then
+event "i", 2, 0, -1, 16000
+k2=0
+endif
+else
+if k2 == 0 then
+event "i", -2, 0, -1, 16000
+k2=1
+endif
+endif
+
+endin
+
+</CsInstruments>
+<CsScore>
+f1 0 16384 10 1 .5 .4 .3 .2 .1 .05 .04 .03 .02 .01 .01 .01 .01
+f2 0 16384 10 1
+
+i10 0 60000
+i100 0 60000
+
+</CsScore>
+</CsoundSynthesizer> \ No newline at end of file
diff --git a/Synth.activity/synth.py b/Synth.activity/synth.py
new file mode 100755
index 0000000..a75d297
--- /dev/null
+++ b/Synth.activity/synth.py
@@ -0,0 +1,66 @@
+# (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
+ win = csndsugui.CsoundGUI(self,bg)
+ if win.csd("synth.csd","-Mhw:1,0"):
+ win.csd("synth.csd")
+ txt = win.text("Synthesizer Panel",colour=fr)
+ hbox = win.box(False)
+
+ # oscillator frames
+ box = win.box(parent=hbox)
+ box1 = win.box(False, box)
+ box2 = win.box(False, box)
+ frame1 = win.framebox("osc 1", False, box1, fr)
+ frame2 = win.framebox("osc 2", False, box2, fr)
+
+ # oscillator 1 controls
+ box = win.box(parent=frame1)
+ win.button(box,"osc1")
+ box = win.box(parent=frame1)
+ win.slider(1.0,0.25,4.0,90,250,box,"pitch1", linear=False)
+
+ # oscillator 2 controls
+ box = win.box(parent=frame2)
+ win.button(box,"osc2")
+ box = win.box(parent=frame2)
+ win.slider(1.0,0.25,4.0,90,250,box,"pitch2", linear=False)
+
+ # filter & mixer frames
+ box = win.box(parent=hbox)
+ box1 = win.box(False, box)
+ box2 = win.box(False, box)
+ frame1 = win.framebox("filter", True, box1, fr)
+ frame2 = win.framebox("mixer", False, box2, fr)
+
+ # filter controls
+ box = win.box(False, parent=frame1)
+ win.slider(1000.0,20.0,20000.0,250,40,box,"frequency", False,linear=False)
+ box = win.box(False, parent=frame1)
+ win.slider(0.9,0.0,1.0,250,40,box,"resonance", False)
+
+ # mixer controls
+ box = win.box(parent=frame2)
+ win.slider(0.0,0.0,100.0,90,360,box,"vol1")
+ box = win.box(parent=frame2)
+ win.slider(0.0,0.0,100.0,90,360,box,"vol2")
+ box = win.box(parent=frame2)
+ win.slider(0.0,0.0,100.0,90,360,box,"noise")
+ box = win.box(parent=frame2)
+ win.slider(0.0,0.0,100.0,90,360,box,"mic")
+
+ win.play()
diff --git a/Synth.activity/synth.pyc b/Synth.activity/synth.pyc
new file mode 100755
index 0000000..f530b74
--- /dev/null
+++ b/Synth.activity/synth.pyc
Binary files differ