diff options
author | SoaS user <liveuser@localhost.localdomain> | 2010-06-07 02:07:28 (GMT) |
---|---|---|
committer | SoaS user <liveuser@localhost.localdomain> | 2010-06-07 02:07:28 (GMT) |
commit | 230f863f55c337c750a7a14f63b6f8242cc9e1df (patch) | |
tree | c411d5d8168dbc49be3c45a249eacd7be2bfb5f6 /sunmoonmusic.py |
Initial commit
Diffstat (limited to 'sunmoonmusic.py')
-rwxr-xr-x | sunmoonmusic.py | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/sunmoonmusic.py b/sunmoonmusic.py new file mode 100755 index 0000000..b8ccd7a --- /dev/null +++ b/sunmoonmusic.py @@ -0,0 +1,182 @@ +# SUN-MOON MUSIC - Sonic Environments for Children (2009) +# Art Hunkins (www.arthunkins.com) +# +# SunMoonMusic is licensed under the Creative Commons Attribution-Share +# Alike 3.0 Unported License. To view a copy of this license, visit +# http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to +# Creative Commons, 171 Second Street, Suite 300, San Francisco, +# California, 94105, USA. +# +# It 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. +# +# Notes: +# +# Both "Brother Sun Music" and "Sister Moon Music" require a USB MIDI +# controller with 8-9 knobs (the 9th controller is only used with the +# Pan option). The 8 knobs/sliders must have *contiguous* controller +# #'s, or all be continuous controller 7 on channels 1-8(9). +# +# The first 7 controllers in "Sister Moon" vary volume for the 7 tones +# (or tone pairs), while #8 is a MASTER volume control. The same is true +# for "Brother Sun" except that there are only 6 tones; controller 7 +# varies overall pitch slightly. +# +# Important: The MIDI 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. Choose Scene 4 on the Korg, and Channel "0" in the +# performance window. Preset all controllers to zero prior to start; +# then, when using Pan, change controller 9 to its opening position +# following start. +# +# 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 audio +# level will sound higher for "Brother Sun" than for "Sister Moon." +# +# 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. + +import csndsugui +from sugar.activity import activity +import gtk +import os + +class SunMoonMusic(activity.Activity): + + def __init__(self, handle): + + activity.Activity.__init__(self, handle) + + red = (0xDDDD, 0, 0) + brown = (0x6600, 0, 0) + green = (0, 0x5500, 0) + + win = csndsugui.CsoundGUI(self) + width = gtk.gdk.screen_width() + height = gtk.gdk.screen_height() + if os.path.exists("/etc/olpc-release"): + adjust = 78 + else: + adjust = 57 + screen = win.box() + screen.set_size_request(width, height - adjust) + scrolled = gtk.ScrolledWindow() + scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + screen.pack_start(scrolled) + all = gtk.VBox() + all.show() + scrolled.add_with_viewport(all) + scrolled.show() + + win.text("<big><big><b><u>BROTHER SUN & SISTER MOON MUSIC</u> -\n\ + Sonic Environments for Children (2010)</b></big>\n\ +\t Art Hunkins (www.arthunkins.com)</big>", all) + + win.text("from <u>The Canticle of the Sun</u> by Francis of Assisi:\n\ +<i>\tBe praised, my Lord, through all your creatures,\n\ +\t\tespecially through my lord Brother Sun, who brings the day;\n\ +\t\tand you give light through him. \ +And he is beautiful and radiant in all his splendor!\n\ +\t\tOf you, Most High, he bears the likeness.\n\ +\tBe praised, my Lord, through Sister Moon and the stars;\n\ +\t\tin the heavens you have made them, precious and beautiful.</i>", all, green) + + win.text("\ +A MIDI controller with 8-9 knobs/sliders is required; \ +the ninth control is only used to vary pan position.\n\ +Plug in MIDI controller AFTER boot & BEFORE selecting Sun/Moon; \ +zero all controls before start.\n\ +Move Pan into position AFTER start. \ +Channel '0' = Continuous Controller 7 on channels 1-8(9).", all, brown) + nbox = win.box(False, all) + win.text("", nbox) + but1 = win.cbbutton(nbox, self.version1, " BROTHER SUN Music ") + 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, " SISTER MOON Music ") + but2.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0, 0x7700, 0)) + but2.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0)) + bbox = win.box(False, all) + self.bb = bbox + self.w = win + self.r = red + self.g = green + self.br = brown + self.ver = 0 + + def playcsd(self, widget): + if self.p == False: + self.p = True + self.w.play() + self.but.child.set_label("STOP !") + self.but.child.set_use_markup(True) + self.but.modify_bg(gtk.STATE_NORMAL, gtk.gdk.Color(0xFFFF, 0, 0)) + self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0xFFFF, 0, 0)) + else: + self.p = False + self.w.recompile() + self.w.channels_reinit() + 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)) + self.but.modify_bg(gtk.STATE_PRELIGHT, gtk.gdk.Color(0, 0x7700, 0)) + + def version1(self, widget): + if self.ver != 0: + self.box1.destroy() + self.box2.destroy() + self.ver = 1 + self.box1 = self.w.box(True, self.bb) + self.w.text("", self.box1) + self.box2 = self.w.box(True, self.bb) + self.f = self.w.framebox(" <b>Brother Sun Music</b> ", False, self.box2, self.r) + self.b1 = self.w.box(True, self.f) + self.b2 = self.w.box(True, self.f) + self.b3 = self.w.box(True, self.f) + self.b4 = self.w.box(True, self.f) + self.b5 = self.w.box(True, self.f) + self.w.reset() + self.w.csd("SunMusic.csd") + self.w.spin(0, 0, 16, 1, 1, self.b1, 0, "Chan", " Channel # ") + self.w.spin(20, 0, 120, 1, 1, self.b2, 0, "Cont", " 1st Controller # ") + self.w.button(self.b3, "Pan", "Pan Control ?") + self.w.spin(7, 0, 127, 1, 1, self.b4, 0, "PCont", "Pan Controller #") + self.p = False + self.w.text("<i>Select options first </i>", self.b5, self.g) + self.but = self.w.cbbutton(self.b5, 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)) + + def version2(self, widget): + if self.ver != 0: + self.box1.destroy() + self.box2.destroy() + self.ver = 2 + self.box1 = self.w.box(True, self.bb) + self.w.text("\t\t\t\t\t", self.box1) + self.box2 = self.w.box(True, self.bb) + self.f = self.w.framebox(" <b>Sister Moon Music</b> ", False, self.box2, self.r) + self.b1 = self.w.box(True, self.f) + self.b2 = self.w.box(True, self.f) + self.b3 = self.w.box(True, self.f) + self.b4 = self.w.box(True, self.f) + self.b5 = self.w.box(True, self.f) + self.w.reset() + self.w.csd("MoonMusic.csd") + self.w.spin(0, 0, 16, 1, 1, self.b1, 0, "Chan", " Channel # ") + self.w.spin(20, 0, 120, 1, 1, self.b2, 0, "Cont", " 1st Controller # ") + self.w.button(self.b3, "Pan", "Pan Control ?") + self.w.spin(7, 0, 127, 1, 1, self.b4, 0, "PCont", "Pan Controller #") + self.p = False + self.w.text("<i>Select options first </i>", self.b5, self.g) + self.but = self.w.cbbutton(self.b5, 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)) + + |