Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2011-07-21 18:57:14 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2011-07-21 18:57:14 (GMT)
commit963e9b44c5ac00c1e84b9b8659e343902cc704fb (patch)
tree4593131e04fdecb28e51230b2490732f28745f5e
parentad32a0ed62656ca0c3719fa0827740105cafc625 (diff)
parent3f5e31d621bd5f9088eee6a8b93dd6f1527daca5 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--NEWS12
-rw-r--r--TurtleArt/tabasics.py2
-rw-r--r--TurtleArtActivity.py10
-rw-r--r--activity/activity.info2
-rw-r--r--pysamples/csound.py140
-rw-r--r--samples/fractions.ta119
6 files changed, 275 insertions, 10 deletions
diff --git a/NEWS b/NEWS
index 1c08a91..f608d05 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+111
+
+ENHANCEMENTS
+* New sample program: urban_landscapes.ta
+* New sample program: fractions.ta
+* New python block example for csound
+* Translation updates for .de
+
+BUG FIX
+* Reverted default action name to 'action' instead of 'stack'
+* Reverted accelerator-key work-around (#2050) in light of #2986
+
110
BUG FIX
diff --git a/TurtleArt/tabasics.py b/TurtleArt/tabasics.py
index bfed2d7..371adef 100644
--- a/TurtleArt/tabasics.py
+++ b/TurtleArt/tabasics.py
@@ -881,7 +881,7 @@ variable'))
style='basic-style-head-1arg',
label=_('action'),
prim_name='nop3',
- default=_('stack'),
+ default=_('action'),
logo_command='to action',
help_string=_('top of nameable action stack'))
self.tw.lc.def_prim('nop3', 1, lambda self, x: None)
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 69bb506..7076179 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -587,15 +587,9 @@ class TurtleArtActivity(activity.Activity):
view_toolbar.show()
help_toolbar.show()
self._toolbox.show()
- # Setup palette toolbar only *after* initializing the plugins
-
- if self.has_toolbarbox:
- # Hack as a workaround for #2050
- edit_toolbar_button.set_expanded(True)
- edit_toolbar_button.set_expanded(False)
- self._palette_toolbar_button.set_expanded(True)
- else:
+ # Setup palette toolbar only *after* initializing the plugins
+ if not self.has_toolbarbox:
self._toolbox.set_current_toolbar(1)
def _setup_palette_toolbar(self):
diff --git a/activity/activity.info b/activity/activity.info
index bfbbaf6..85b764e 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -1,6 +1,6 @@
[Activity]
name = Turtle Art
-activity_version = 110
+activity_version = 111
license = MIT
bundle_id = org.laptop.TurtleArtActivity
exec = sugar-activity TurtleArtActivity.TurtleArtActivity
diff --git a/pysamples/csound.py b/pysamples/csound.py
new file mode 100644
index 0000000..f2bccfa
--- /dev/null
+++ b/pysamples/csound.py
@@ -0,0 +1,140 @@
+#Copyright (c) 2011 Walter Bender
+
+# This procedure is invoked when the user-definable block on the
+# "extras" palette is selected.
+
+# Usage: Import this code into a Python (user-definable) block and
+# pass a sound name Python block. The sound will play.
+# Alternatively, pass a pitch, amplitude, and duration, e.g., 440, 5000, 1
+
+# Note: Assumes TamTam suite is installed in ~/Activities
+
+
+def myblock(tw, sound):
+ ''' Plays a sound file '''
+
+ from TurtleArt.tautils import get_path
+ import os
+
+ dirs = [os.path.join(os.environ['HOME'],
+ 'Activities/TamTamMini.activity/common/Resources/Sounds/')]
+ orchlines = []
+ scorelines = []
+ instrlist = []
+ fnum = [100]
+
+ def finddir():
+ for d in dirs:
+ if os.path.isdir(d):
+ return d
+
+ def playSine(pitch=1000, amplitude=5000, duration=1, starttime=0,
+ pitch_envelope='default', amplitude_envelope='default'):
+ """ Create a score to play a sine wave. """
+ _play(pitch, amplitude, duration, starttime, pitch_envelope,
+ amplitude_envelope, 1)
+
+ def _play(pitch, amplitude, duration, starttime, pitch_envelope,
+ amplitude_envelope, instrument):
+ if pitch_envelope == 'default':
+ pitenv = 99
+ else:
+ pitenv = pitch_envelope
+
+ if amplitude_envelope == 'default':
+ ampenv = 100
+ else:
+ ampenv = amplitude_envelope
+
+ if not 1 in instrlist:
+ orchlines.append("instr 1\n")
+ orchlines.append("kpitenv oscil 1, 1/p3, p6\n")
+ orchlines.append("aenv oscil 1, 1/p3, p7\n")
+ orchlines.append("asig oscil p5*aenv, p4*kpitenv, p8\n")
+ orchlines.append("out asig\n")
+ orchlines.append("endin\n\n")
+ instrlist.append(1)
+
+ scorelines.append("i1 %s %s %s %s %s %s %s\n" % (
+ str(starttime), str(duration), str(pitch), str(amplitude),
+ str(pitenv), str(ampenv), str(instrument)))
+
+ def playWave(sound='horse', pitch=1, amplitude=1, loop=False, duration=1,
+ starttime=0, pitch_envelope='default',
+ amplitude_envelope='default'):
+ """ Create a score to play a wave file. """
+
+ if '/' in sound:
+ fullname = sound
+ else:
+ fullname = finddir() + str(sound)
+
+ if loop == False: lp = 0
+ else: lp = 1
+
+ if pitch_envelope == 'default': pitenv = 99
+ else: pitenv = pitch_envelope
+
+ if amplitude_envelope == 'default': ampenv = 100
+ else: ampenv = amplitude_envelope
+
+ if not 9 in instrlist:
+ orchlines.append("instr 9\n")
+ orchlines.append("kpitenv oscil 1, 1/p3, p8\n")
+ orchlines.append("aenv oscil 1, 1/p3, p9\n")
+ orchlines.append("asig diskin p4, p5*kpitenv, 0, p7\n")
+ orchlines.append("out asig*p6*aenv\n")
+ orchlines.append("endin\n\n")
+ instrlist.append(9)
+
+ scorelines.append('i9 %f %f "%s" %s %s %s %s %s\n' % (
+ float(starttime), float(duration), fullname, str(pitch),
+ str(amplitude), str(lp), str(pitenv), str(ampenv)))
+
+ def audioWrite(file):
+ """ Compile a .csd file. """
+
+ csd = open(file, "w")
+ csd.write("<CsoundSynthesizer>\n\n")
+ csd.write("<CsOptions>\n")
+ csd.write("-+rtaudio=alsa -odevaudio -m0 -d -b256 -B512\n")
+ csd.write("</CsOptions>\n\n")
+ csd.write("<CsInstruments>\n\n")
+ csd.write("sr=16000\n")
+ csd.write("ksmps=50\n")
+ csd.write("nchnls=1\n\n")
+ # csd.write(orchlines.pop())
+ for line in orchlines:
+ csd.write(line)
+ csd.write("\n</CsInstruments>\n\n")
+ csd.write("<CsScore>\n\n")
+ csd.write("f1 0 2048 10 1\n")
+ csd.write("f2 0 2048 10 1 0 .33 0 .2 0 .143 0 .111\n")
+ csd.write("f3 0 2048 10 1 .5 .33 .25 .2 .175 .143 .125 .111 .1\n")
+ csd.write("f10 0 2048 10 1 0 0 .3 0 .2 0 0 .1\n")
+ csd.write("f99 0 2048 7 1 2048 1\n")
+ csd.write("f100 0 2048 7 0. 10 1. 1900 1. 132 0.\n")
+ csd.write(scorelines.pop())
+ csd.write("e\n")
+ csd.write("\n</CsScore>\n")
+ csd.write("\n</CsoundSynthesizer>")
+ csd.close()
+
+ if type(sound) == float:
+ playSine(pitch=float(sound))
+ elif type(sound) == list: # Create a score by computing a sinewave.
+ if len(sound) == 1:
+ playSine(pitch=float(sound[0]))
+ elif len(sound) == 2:
+ playSine(pitch=float(sound[0]), amplitude=float(sound[1]))
+ else:
+ playSine(pitch=float(sound[0]), amplitude=float(sound[1]),
+ duration=float(sound[2]))
+ else: # Create a score from a prerecorded Wave file.
+ playWave(sound)
+ if tw.running_sugar:
+ path = os.path.join(get_path(tw.activity, 'instance'), 'tmp.csd')
+ else:
+ path = os.path.join('/tmp', 'tmp.csd')
+ audioWrite(path) # Create a csound file from the score.
+ os.system('csound ' + path) # Play the csound file.
diff --git a/samples/fractions.ta b/samples/fractions.ta
new file mode 100644
index 0000000..5578f5c
--- /dev/null
+++ b/samples/fractions.ta
@@ -0,0 +1,119 @@
+[[0, ["start", 2.0], 19, 117, [null, 1]],
+[1, ["storein", 0], 19, 159, [0, 2, 3, 4]],
+[2, ["string", "denom"], 115, 159, [1, null]],
+[3, ["number", 7.0], 115, 201, [1, null]],
+[4, ["storein", 0], 19, 243, [1, 5, 6, 7]],
+[5, ["string", "num"], 115, 243, [4, null]],
+[6, ["number", 3], 115, 285, [4, null]],
+[7, "stack", 19, 327, [4, 8, 80]],
+[8, ["string", "setup"], 80, 327, [7, null]],
+[9, "hat", 671, 501, [null, 10, 11]],
+[10, ["string", "setup"], 732, 509, [9, null]],
+[11, "clean", 671, 551, [9, 110]],
+[12, "hat", 305, 540, [null, 13, 117]],
+[13, ["string", "print"], 366, 548, [12, null]],
+[14, "penup", 305, 632, [117, 98]],
+[15, "show", 305, 800, [97, 17, null]],
+[16, ["string", " / "], 484, 842, [18, null]],
+[17, ["plus2", 0], 376, 800, [15, 19, 18]],
+[18, ["plus2", 0], 430, 842, [17, 16, 21]],
+[19, "box", 430, 800, [17, 20, null]],
+[20, ["string", "num"], 489, 800, [19, null]],
+[21, "box", 484, 884, [18, 22, null]],
+[22, ["string", "denom"], 543, 884, [21, null]],
+[23, "startfill", 677, 184, [64, 68]],
+[24, "stopfill", 677, 268, [68, 58]],
+[25, "hat", 1040, 4, [null, 26, 27]],
+[26, ["string", "slice"], 1101, 12, [25, null]],
+[27, "forward", 1040, 54, [25, 31, 33]],
+[28, ["storein", 0], 671, 719, [94, 29, 30, null]],
+[29, ["string", "radius"], 767, 719, [28, null]],
+[30, ["number", 200.0], 767, 761, [28, null]],
+[31, "box", 1120, 54, [27, 32, null]],
+[32, ["string", "radius"], 1179, 54, [31, null]],
+[33, "right", 1040, 96, [27, 34, 115]],
+[34, ["number", 90], 1114, 96, [33, null]],
+[35, "repeat", 1040, 180, [115, 45, 107, 37]],
+[36, ["number", 3600.0], 1199, 180, [38, null]],
+[37, ["vspace", 100], 1040, 258, [35, 46]],
+[38, ["division2", 0], 1145, 180, [45, 36, 39]],
+[39, "box", 1223, 222, [38, 40, null]],
+[40, ["string", "denom"], 1282, 222, [39, null]],
+[41, "forward", 1105, 324, [108, 51, 106]],
+[42, ["number", 3600.0], 1263, 406, [51, null]],
+[43, "right", 1105, 448, [106, 44, null]],
+[44, ["number", 0.1], 1179, 448, [43, null]],
+[45, ["identity2", 0], 1091, 180, [35, 38]],
+[46, "right", 1040, 500, [37, 47, 48]],
+[47, ["number", 90], 1114, 500, [46, null]],
+[48, "forward", 1040, 542, [46, 49, 56]],
+[49, "box", 1120, 542, [48, 50, null]],
+[50, ["string", "radius"], 1179, 542, [49, null]],
+[51, ["division2", 20], 1185, 324, [41, 54, 42]],
+[52, "box", 1293, 324, [54, 53, null]],
+[53, ["string", "radius"], 1352, 324, [52, null]],
+[54, ["product2", 0], 1239, 324, [51, 52, 55]],
+[55, ["number", 6.283], 1293, 366, [54, null]],
+[56, "right", 1040, 584, [48, 57, null]],
+[57, ["number", 180.0], 1114, 584, [56, null]],
+[58, "left", 677, 310, [24, 60, 63]],
+[59, ["number", 360.0], 813, 310, [60, null]],
+[60, ["division2", 0], 759, 310, [58, 59, 61]],
+[61, "box", 837, 352, [60, 62, null]],
+[62, ["string", "denom"], 896, 352, [61, null]],
+[63, ["vspace", 0], 677, 352, [58, 66]],
+[64, "setgray", 677, 142, [112, 65, 23]],
+[65, ["number", 100.0], 803, 142, [64, null]],
+[66, "setgray", 677, 394, [63, 67, 70]],
+[67, ["number", 0.0], 803, 394, [66, null]],
+[68, "stack", 677, 226, [23, 69, 24]],
+[69, ["string", "slice"], 738, 226, [68, null]],
+[70, "stack", 677, 436, [66, 71, null]],
+[71, ["string", "slice"], 738, 436, [70, null]],
+[72, "hat", 677, 8, [null, 73, 112]],
+[73, ["string", "fancy slice"], 738, 16, [72, null]],
+[74, "repeat", 19, 613, [78, 84, 90, 105]],
+[75, ["vspace", 20], 19, 489, [76, 78]],
+[76, "repeat", 19, 411, [80, 89, 77, 75]],
+[77, ["vspace", 0], 84, 471, [76, 92]],
+[78, "setcolor", 19, 571, [75, 79, 74]],
+[79, "red", 104, 571, [78, null]],
+[80, "setcolor", 19, 369, [7, 81, 76]],
+[81, "blue", 104, 369, [80, null]],
+[82, "box", 202, 453, [88, 83, null]],
+[83, ["string", "num"], 261, 453, [82, null]],
+[84, "box", 70, 613, [74, 85, null]],
+[85, ["string", "num"], 129, 613, [84, null]],
+[86, "box", 178, 411, [88, 87, null]],
+[87, ["string", "denom"], 237, 411, [86, null]],
+[88, ["minus2", 0], 124, 411, [89, 86, 82]],
+[89, ["identity2", 0], 70, 411, [76, 88]],
+[90, "stack", 84, 673, [74, 91, null]],
+[91, ["string", "fancy slice"], 145, 673, [90, null]],
+[92, "stack", 84, 513, [77, 93, null]],
+[93, ["string", "fancy slice"], 145, 513, [92, null]],
+[94, ["fillscreen", 0], 671, 635, [110, 96, 95, 28]],
+[95, ["number", 80], 810, 677, [94, null]],
+[96, "white", 810, 635, [94, null]],
+[97, "pendown", 305, 758, [98, 15]],
+[98, ["setxy2", 0], 305, 674, [14, 99, 101, 97]],
+[99, "box", 369, 674, [98, 100, null]],
+[100, ["string", "radius"], 428, 674, [99, null]],
+[101, "box", 369, 716, [98, 102, null]],
+[102, ["string", "radius"], 428, 716, [101, null]],
+[103, "stack", 19, 733, [105, 104, null]],
+[104, ["string", "print"], 80, 733, [103, null]],
+[105, ["vspace", 0], 19, 691, [74, 103]],
+[106, ["vspace", 20], 1105, 366, [41, 43]],
+[107, ["vspace", 0], 1105, 240, [35, 108]],
+[108, "comment", 1105, 282, [107, 109, 41]],
+[109, ["string", "circumfrence/360"], 1191, 282, [108, null]],
+[110, "setpensize", 671, 593, [11, 111, 94]],
+[111, ["number", 5.0], 779, 593, [110, null]],
+[112, ["setxy2", 0], 677, 58, [72, 113, 114, 64]],
+[113, ["number", 0], 741, 58, [112, null]],
+[114, ["number", 0], 741, 100, [112, null]],
+[115, "comment", 1040, 138, [33, 116, 35]],
+[116, ["string", "higher precision"], 1126, 138, [115, null]],
+[117, "setscale", 305, 590, [12, 118, 14]],
+[118, ["number", 100.0], 402, 590, [117, null]]]