Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Synth.activity
diff options
context:
space:
mode:
Diffstat (limited to 'Synth.activity')
-rwxr-xr-xSynth.activity/csndsugui.py91
-rw-r--r--[-rwxr-xr-x]Synth.activity/csndsugui.pycbin15841 -> 28745 bytes
-rwxr-xr-xSynth.activity/synth.py82
-rw-r--r--[-rwxr-xr-x]Synth.activity/synth.pycbin2044 -> 2783 bytes
4 files changed, 126 insertions, 47 deletions
diff --git a/Synth.activity/csndsugui.py b/Synth.activity/csndsugui.py
index 8281b19..621587c 100755
--- a/Synth.activity/csndsugui.py
+++ b/Synth.activity/csndsugui.py
@@ -26,7 +26,7 @@
# file might be covered by the GNU Lesser General Public License.
#
#
-# version 0.1.2 18/03/08
+# version 0.1.2 24/03/08
import pygtk
pygtk.require('2.0')
@@ -48,18 +48,18 @@ class BasicGUI:
def set_channel(self,name, val):
"""basic bus channel setting method,
should be overriden for full-functionality."""
- print "channel:%s, value:%.1f" % (name,val)
+ self.logger.debug("channel:%s, value:%.1f" % (name,val))
def set_filechannel(self,chan,name):
"""basic filename channel setting method
should be overriden for full-functionality."""
- print "channel:%s, filename:%s" % (chan,name)
+ self.logger.debug("channel:%s, filename:%s" % (chan,name))
def set_message(self, mess):
"""basic message setting method
should be overriden for full-functionality."""
- print mess
+ self.logger.debug(mess)
def get_slider_value(self,name):
"""returns the slider value
@@ -96,7 +96,7 @@ class BasicGUI:
def set_focus(self):
""" called whenever the focus changes """
- print self.focus
+ self.logger.debug(self.focus)
def focus_out(self, widget, event):
if(self.focus):
@@ -125,6 +125,14 @@ class BasicGUI:
i[0].modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0, 2))
self.set_channel(i[1], i[2])
+ def button_setvalue(self, widget, value):
+ if not value:
+ widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x0FFF,0,0x00FF, 2))
+ widget.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0xFFFF, 2))
+ else:
+ widget.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0xFFFF,0,0, 1))
+ widget.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF,0,0, 2))
+
def mbuttcallback(self, widget, data=None):
for i in self.mbuttons:
if i[0] == widget:
@@ -163,8 +171,6 @@ class BasicGUI:
def destroy_chooser(self,widget):
self.curfile[0].destroy()
-
- # internal callback
def fbuttcallback(self, widget, data=None):
self.focus_disconnect()
self.fback = self.window.connect('focus_in_event', self.focus_back)
@@ -466,14 +472,77 @@ class BasicGUI:
def channels_reinit(self):
""" resets channel to current widget values"""
- for i in self.channel_widgets:
- for j in i:
+ for j in self.buttons:
+ self.set_channel(j[1],j[2])
+ for j in self.sliders:
+ if j[4]:
+ self.set_channel(j[1],j[2])
+ pass
+ else:
+ value = j[5]*pow(j[6]/j[5], j[2]/j[6])
+ self.set_channel(j[1], value)
+ for j in self.spins:
+ self.set_channel(j[1],j[2])
+
+
+
+ def widgets_reset(self):
+ """ resets widget to channel values"""
+ for j in self.buttons:
+ self.button_setvalue(j[0], j[2])
+ self.set_channel(j[1],j[2])
+ for j in self.sliders:
+ j[0].set_value(j[2])
+ j[0].emit("value_changed")
+ for j in self.spins:
+ j[0].set_value(j[2])
+ j[0].emit("value_changed")
+
+ def channels_save(self):
+ """ Saves a list with channel names and current values.
+ Returns a list of tuples (channel_name, channel_value)"""
+ chan_list = []
+ for i in self.channel_widgets:
+ for j in i:
if(j[1] != "pause"):
if(j[1] != "play"):
if(j[1] != "reset"):
- self.set_channel(j[1],j[2])
- self.logger.debug(j[1])
+ chan_list.append((j[1],j[2]));
+ return chan_list
+ def channels_load(self, chan_list):
+ """ Loads a list with channel names and values into the
+ current channel list """
+ for i in self.channnel_widgets:
+ for j in i:
+ cnt = 0
+ while(j[1] == chan_list[cnt][0]):
+ j[1] = chann_list[cnt][0]
+ j[2] = chan_list[cnt][1]
+ cnt = cnt+1
+ self.widgets_reset()
+
+ def set_channel_metadata(self):
+ """ Saves channel data as metadata. Can be called in
+ write_file() to save channel/widget data """
+ mdata = self.channels_save()
+ for i in mdata:
+ self.window.metadata['channel-'+i[0]] = str(i[1])
+
+ def get_channel_metadata(self):
+ """ Retrieves channel data from metadata. Can be called after
+ widgets have been created to retrieve channel data and
+ reset widgets """
+ for i in self.channel_widgets:
+ for j in i:
+ mdata = self.window.metadata.get('channel-'+j[1],'0')
+ if mdata is None: continue
+ else:
+ try: j[2] = float(mdata)
+ except: j[2] = mdata
+ self.widgets_reset()
+
+
def nofocus(self):
pass
diff --git a/Synth.activity/csndsugui.pyc b/Synth.activity/csndsugui.pyc
index 356ed30..52d2f1e 100755..100644
--- a/Synth.activity/csndsugui.pyc
+++ b/Synth.activity/csndsugui.pyc
Binary files differ
diff --git a/Synth.activity/synth.py b/Synth.activity/synth.py
index f62a8d2..8ff18bd 100755
--- a/Synth.activity/synth.py
+++ b/Synth.activity/synth.py
@@ -15,52 +15,62 @@ class Synth(activity.Activity):
fr = (0x1000, 0x0000, 0x7000)
# GUI window
- win = csndsugui.CsoundGUI(self,bg)
- if win.compile("synth.csd",["-Mhw:1,0"]):
- win.csd("synth.csd")
- txt = win.text("Synthesizer Panel",colour=fr)
- hbox = win.box(False)
+ 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 = 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)
+ 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 = 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)
+ 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 = 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)
+ 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 = 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)
+ 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 = 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)
+ 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 = 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")
+ 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")
- win.play()
+ 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()
diff --git a/Synth.activity/synth.pyc b/Synth.activity/synth.pyc
index f530b74..b524ab8 100755..100644
--- a/Synth.activity/synth.pyc
+++ b/Synth.activity/synth.pyc
Binary files differ