Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLive System User <liveuser@localhost.localdomain>2010-12-28 19:42:02 (GMT)
committer Live System User <liveuser@localhost.localdomain>2010-12-28 19:42:02 (GMT)
commitb18ffffe53806942ae2c5718dff9d881f29b51ae (patch)
treeb23a50ae3fd6febd540aa0247ad6532bf7e7f7c7
parent62d793ff7a6c4245768be6d2ddb863193423bd8e (diff)
Version 4 changes: ObjectChooser and Sugar-version ID reworked
-rwxr-xr-xFileMixReadMe.txt9
-rwxr-xr-xactivity/activity.info2
-rwxr-xr-xfilemix.py188
3 files changed, 113 insertions, 86 deletions
diff --git a/FileMixReadMe.txt b/FileMixReadMe.txt
index c8e9f49..46a52cc 100755
--- a/FileMixReadMe.txt
+++ b/FileMixReadMe.txt
@@ -35,10 +35,11 @@ This activity is fairly simple and straightforward; the only problem
is that many versions of it do not work with various incarnations of
Sugar. The following versions of Record seem to work well or fairly
well: v86 with the XO-1.5 and the XO-1 upgraded to Sugar 0.84; and
-v64 with Sugar-on-a-Stick Strawberry (0.84). No current Record
-versions work correctly with Sugar 0.86 and higher (as of 11/2010.)
-Please note that Record prior to v64 or so produce ogg *speex* files;
-these files are *not* compatible with FileMix.
+v64 with Sugar-on-a-Stick Strawberry (0.84). The XO-1.5 works *best*
+with v78 (strangely named the "Grabar" activity). No current Record
+versions work correctly with Sugar 0.86 and higher (as of 12/2010).
+Please note that Record prior to v74 (except for v61-64) produce ogg
+*speex* files; these files are *not* compatible with FileMix.
Soundfiles must be moved into the folder where this file resides,
and be renamed soundin.1 through soundin.4. Alternatively, and more
diff --git a/activity/activity.info b/activity/activity.info
index 6938985..26985a9 100755
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -5,7 +5,7 @@ name = FileMix
bundle_id = org.laptop.FileMix
icon = activity-filemix
-activity_version = 2
+activity_version = 4
host_version = 1
diff --git a/filemix.py b/filemix.py
index 0a85087..078ad76 100755
--- a/filemix.py
+++ b/filemix.py
@@ -11,80 +11,14 @@
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
-# version 2 Changes:
-# Tweak amplitudes of sound files.
-#
-# Notes:
-#
-# The four versions that comprise the FileMix utility series are:
-# FileMix4, FileMix4ASC, FileMix and FileMixASC. FileMix4 and
-# FileMix4ASC require 4 stereo soundfiles, while FileMix and
-# FileMixASC can handle 1-4 mono or stereo soundfiles. The files
-# can be of any sample rate and a variety of uncompressed formats
-# including WAV and AIFF; also Ogg/Vorbis, but not MP3. The Ogg/
-# Vorbis format is only possible when the Sugar version is later
-# than 0.84, which excludes the XO-1 and SoaS Strawberry. The XO-1.5
-# works fine with Ogg.
-#
-# Actually, the ogg vorbis format (which is written by the Record
-# activity) can be used by SoaS Strawberry (0.84) if libsndfile is
-# updated. This can be done while connected to the internet by
-# issuing the following commands in the Terminal:
-# su <Enter>
-# yum update libsndfile <Enter>
-#
-# Students are encouraged to create their own soundfiles, especially
-# to make their own nature soundscapes. (This is the primary intent
-# behind these utilities. The four short "nature" files included here
-# are abbreviated versions of those from the author's DUSK AT ST.
-# FRANCIS SPRINGS [www.arthunkins.com].)
-#
-# The natural vehicle for soundfile creation is the Record activity.
-# This activity is fairly simple and straightforward; the only problem
-# is that certain versions of it work poorly or not at all. The
-# following versions of Record seem to work well or fairly well: v59
-# (well) with the XO-1; v67 or v85/86 (fairly well) with XO-1.5; v64
-# (well) with SoaS Strawberry; v66 (fairly well) with SoaS Blueberry,
-# Mirabelle and later. (This is as of 9/2010.)
-#
-# Soundfiles must be moved into the folder where this file resides,
-# and be renamed soundin.1 through soundin.4.
-#
-# Important: The controller must be attached AFTER boot, and BEFORE
-# the version is selected. It is assumed that the controller is a USB
-# device. The inexpensive Korg nanoKontrol is one appropriate
-# controller choice; it can nicely handle either 8- or 9-slider
-# renditions (but not those requiring more than 9 sliders). Choose
-# Scene 4 on the Korg, and Channel "0" in the performance window.
-#
-# It is also important, with all versions, to wait 3 to 5 seconds
-# after pressing START, before moving any controls or pressing more
-# buttons/keys. The utilities will not respond to these actions until
-# after this time.
-#
-# To facilitate performance of FileMix on the Korg nanoKontrol, its STOP
-# button has been programmed as a Delay Start option (buttons on the
-# device, by default, are not set to MIDI notes). It is conceivable
-# that this feature could interfere with MIDI controller selection
-# (Continuous Controller numbers). Solutions to this possible issue
-# are discussed in the FileMix.txt document on the author's website.
-# Other relevent items of interest may also be found in this document.
-#
-# On a few systems, e.g. the Intel Classmate PC, the specified sr
-# (sample rate) of 44100 may not produce audio. Substitute a rate of
-# 48000 toward the beginning of each .csd file, using a text editor.
-#
-# If you get audio glitching, open Sugar's Control Panel, and turn off
-# Extreme power management (under Power) or Wireless radio (under
-# Network). Stereo headphones (an inexpensive set will work fine) or
-# external amplifier/speaker system are highly recommended.
-#
-# The font display of this activity can be resized in csndsugui.py,
-# using any text editor. Further instructions are found toward the
-# beginning of csndsugui.py.
+# version 4 Changes:
+# ObjectChooser and Sugar-version ID code reworked.
+
import csndsugui
from sugar.activity import activity
+from sugar.graphics.objectchooser import ObjectChooser
+from sugar import mime
import gtk
import os
@@ -97,6 +31,14 @@ class FileMix(activity.Activity):
red = (0xDDDD, 0, 0)
brown = (0x6600, 0, 0)
green = (0, 0x5500, 0)
+ self.path1 = "0"
+ self.path2 = "0"
+ self.path3 = "0"
+ self.path4 = "0"
+ self.jobject1 = None
+ self.jobject2 = None
+ self.jobject3 = None
+ self.jobject4 = None
win = csndsugui.CsoundGUI(self)
width = gtk.gdk.screen_width()
@@ -120,16 +62,16 @@ Utilities for Children (2010)</big></b>\n\
\t\t\t\t Art Hunkins (www.arthunkins.com)</big>", all)
win.text("\
-<b>FileMix4</b> and <b>FileMix4ASC</b> play 4 stereo files; any format except mp3 \
-(and no ogg on XO-1 and Sugar 0.84/Strawberry).\n\
+<b>FileMix4</b> and <b>FileMix4ASC</b> play 4 mono/stereo files; wav and \
+ogg vorbis formats only (no ogg vorbis on Sugar 0.84).\n\
<b>FileMix</b> and <b>FileMixASC</b> play 1-4 mono and/or stereo files; \
-any format as above.\n\
- Files must be named <i>soundin.1</i> to <i>soundin.4</i> \
-and be located in this folder.\n\
+formats as above. These versions include more options.\n\
+ User sound files must be placed in Journal (Record activity \
+does this). <b>No user files on Sugar 0.82</b> (original XO-1).\n\
The default files are abbreviated versions of those from the author's \
<b>DUSK AT ST. FRANCIS SPRINGS</b>.\n\
- You are urged to make your own, perhaps with the Record activity \
-(in ogg format) - especially nature soundscapes.", all, brown)
+ You are urged to create your own sound files, for example, with the Record \
+activity - especially nature soundscapes.", all, brown)
win.text("<b>FileMix4</b> and <b>FileMix</b> require MIDI controllers; \
the # of knobs/sliders depends on the # of files/parameters you control. \n\
All knobs/sliders are adjoining, and like parameters are grouped: \
@@ -164,20 +106,45 @@ to .5 after.\n<b>ALL VERSIONS</b>: IMPORTANT! \
Key presses &amp; controller motion prior to 3-5 seconds after hitting START \
are ignored.</i> ", all, brown)
nbox = win.box(False, all)
- win.text("", nbox)
+ self.b2box = win.box(False, all)
but1 = win.cbbutton(nbox, self.version1, " 1 FileMix4 ")
but1.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
but1.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
but2 = win.cbbutton(nbox, self.version2, "2 FileMix4ASC")
but2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
but2.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
- but3 = win.cbbutton(nbox, self.version3, " 3 FileMix ")
+ but3 = win.cbbutton(nbox, self.version3, " 3 FileMix ")
but3.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
but3.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
but4 = win.cbbutton(nbox, self.version4, " 4 FileMixASC ")
but4.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
but4.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
- win.text(" <b>MIDI DEVICE REQUIRED</b> for 1 &amp; 3", nbox, brown)
+ win.text("<b> MIDI DEVICE REQUIRED</b> for 1 and 3", nbox, green)
+
+ try:
+ from jarabe import config
+ version = [int(i) for i in config.version.split('.')][:2]
+ except ImportError:
+ version = [0, 82]
+ if version >= [0, 84]:
+ win.text(" Optionally, <b>before choosing version above</b>, \
+select your own <b>audio</b> file(s) from\n Journal. \
+Deselect by closing Journal. Record with Record v64/v78/v86 \
+or Audacity.", self.b2box, brown)
+ win.text(" Load File(s):", self.b2box, brown)
+ but5 = win.cbbutton(self.b2box, self.choose1, " 1 ")
+ but5.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x6600, 0, 0))
+ but5.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0x6600, 0, 0))
+ but6 = win.cbbutton(self.b2box, self.choose2, " 2 ")
+ but6.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x6600, 0, 0))
+ but6.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0x6600, 0, 0))
+ but7 = win.cbbutton(self.b2box, self.choose3, " 3 ")
+ but7.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x6600, 0, 0))
+ but7.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0x6600, 0, 0))
+ but8 = win.cbbutton(self.b2box, self.choose4, " 4 ")
+ but8.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0x6600, 0, 0))
+ but8.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0x6600, 0, 0))
+
bbox = win.box(False, all)
self.bb = bbox
self.w = win
@@ -186,6 +153,52 @@ are ignored.</i> ", all, brown)
self.br = brown
self.ver = 0
+ def choose1(self, widget):
+ chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO)
+ result = chooser.run()
+ if result == gtk.RESPONSE_ACCEPT:
+ self.jobject1 = chooser.get_selected_object()
+ self.path1 = str(self.jobject1.get_file_path())
+ else:
+ self.jobject1 = None
+ self.path1 = "0"
+
+ def choose2(self, widget):
+ chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO)
+ result = chooser.run()
+ if result == gtk.RESPONSE_ACCEPT:
+ self.jobject2 = chooser.get_selected_object()
+ self.path2 = str(self.jobject2.get_file_path())
+ else:
+ self.jobject2 = None
+ self.path2 = "0"
+
+ def choose3(self, widget):
+ chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO)
+ result = chooser.run()
+ if result == gtk.RESPONSE_ACCEPT:
+ self.jobject3 = chooser.get_selected_object()
+ self.path3 = str(self.jobject3.get_file_path())
+ else:
+ self.jobject3 = None
+ self.path3 = "0"
+
+ def choose4(self, widget):
+ chooser = ObjectChooser(parent=self, what_filter=mime.GENERIC_TYPE_AUDIO)
+ result = chooser.run()
+ if result == gtk.RESPONSE_ACCEPT:
+ self.jobject4 = chooser.get_selected_object()
+ self.path4 = str(self.jobject4.get_file_path())
+ else:
+ self.jobject4 = None
+ self.path4 = "0"
+
+ def send_data(self):
+ self.w.set_filechannel("file1", self.path1)
+ self.w.set_filechannel("file2", self.path2)
+ self.w.set_filechannel("file3", self.path3)
+ self.w.set_filechannel("file4", self.path4)
+
def onKeyPress(self, widget, event):
if self.p:
if self.ver > 1:
@@ -205,6 +218,7 @@ are ignored.</i> ", all, brown)
self.p = False
self.w.recompile()
self.w.channels_reinit()
+ self.send_data()
self.but.child.set_label("START !")
self.but.child.set_use_markup(True)
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
@@ -214,6 +228,8 @@ are ignored.</i> ", all, brown)
if self.ver != 0:
self.box1.destroy()
self.box2.destroy()
+ else:
+ self.b2box.destroy()
self.ver = 1
self.box1 = self.w.box(True, self.bb)
self.w.text("", self.box1)
@@ -235,6 +251,7 @@ channels 1-16]")
[1=amp 2=band-\n pass peak freq\n 3=peak gain\n 4=speed/freq]")
self.p = False
self.w.text("\n<i>Select options first </i>", self.b4, self.g)
+ self.send_data()
self.but = self.w.cbbutton(self.b4, self.playcsd, "START !")
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
@@ -243,6 +260,8 @@ channels 1-16]")
if self.ver != 0:
self.box1.destroy()
self.box2.destroy()
+ else:
+ self.b2box.destroy()
self.ver = 2
self.box1 = self.w.box(True, self.bb)
self.w.text("\t\t\t ", self.box1)
@@ -256,6 +275,7 @@ channels 1-16]")
[1=amp 2=band-\n pass peak freq\n 3=peak gain\n 4=speed/freq]")
self.p = False
self.w.text("\n<i>Select option first </i>", self.b2, self.g)
+ self.send_data()
self.but = self.w.cbbutton(self.b2, self.playcsd, "START !")
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
@@ -264,6 +284,8 @@ channels 1-16]")
if self.ver != 0:
self.box1.destroy()
self.box2.destroy()
+ else:
+ self.b2box.destroy()
self.ver = 3
self.box1 = self.w.box(True, self.bb)
self.w.text(" ", self.box1)
@@ -295,6 +317,7 @@ channels 1-16]")
[-3=.01/-2=.1/-1=.5]")
self.p = False
self.w.text("<i>Select options first </i>", self.b6, self.g)
+ self.send_data()
self.but = self.w.cbbutton(self.b6, self.playcsd, "START !")
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))
@@ -303,6 +326,8 @@ channels 1-16]")
if self.ver != 0:
self.box1.destroy()
self.box2.destroy()
+ else:
+ self.b2box.destroy()
self.ver = 4
self.box1 = self.w.box(True, self.bb)
self.w.text("\t\t\t\t\t\t\t\t ", self.box1)
@@ -327,6 +352,7 @@ self.r)
[-3=.01/-2=.1/-1=.5]")
self.p = False
self.w.text("<i>Select options first </i>", self.b4, self.g)
+ self.send_data()
self.but = self.w.cbbutton(self.b4, self.playcsd, "START !")
self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0))
self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0))