Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/library
diff options
context:
space:
mode:
authorC. Scott Ananian <cscott@laptop.org>2007-12-14 18:45:23 (GMT)
committer C. Scott Ananian <cscott@laptop.org>2007-12-14 18:55:26 (GMT)
commit71c9a57d4fbc4713b9f5892e1e9140d12cb256fc (patch)
treef741de17c215d25fe2ad9a29e33b9ab78f014b30 /library
parenta9d1055a632ad960231dddf98045c060a2a660d7 (diff)
Move imports around to ensure 'import pippy' is as fast as possible.
Diffstat (limited to 'library')
-rw-r--r--library/pippy/game.py14
-rwxr-xr-xlibrary/pippy/sound.py6
2 files changed, 14 insertions, 6 deletions
diff --git a/library/pippy/game.py b/library/pippy/game.py
index c6a96b9..03a51f4 100644
--- a/library/pippy/game.py
+++ b/library/pippy/game.py
@@ -1,10 +1,9 @@
"""pygame support for pippy."""
-import pygame
-
def pause():
"""Display a "Paused" screen and suspend."""
from gettext import gettext as _
+ import pygame
caption, icon_caption = pygame.display.get_caption()
screen = pygame.display.get_surface()
old_screen = screen.copy() # save this for later.
@@ -43,14 +42,19 @@ def pause():
pygame.display.flip()
_last_event_time=0
-def next_frame(max_fps=20, idle_timeout=20,
- clock=pygame.time.Clock(), pause=pause):
+_default_clock=None
+def next_frame(max_fps=20, idle_timeout=20, clock=None, pause=pause):
"""Limit maximum frame rate of pygame. Returns True.
If idle longer than the idle_timeout (in seconds), then we'll put up a
"paused" message and the XO will suspend. This ensures that we don't
burn up all of our battery running an animation!"""
- global _last_event_time
+ import pygame
+ global _last_event_time, _default_clock
+ if _default_clock is None:
+ _default_clock = pygame.time.Clock()
+ if clock is None:
+ clock = _default_clock
clock.tick(max_fps)
if pygame.event.peek(xrange(pygame.NOEVENT, pygame.USEREVENT)):
diff --git a/library/pippy/sound.py b/library/pippy/sound.py
index 570c10c..319e190 100755
--- a/library/pippy/sound.py
+++ b/library/pippy/sound.py
@@ -2,18 +2,19 @@
# added frequency modulation genertor
# audioOut write a wave file if a string is given as argument
-import os
orchlines = []
scorelines = []
instrlist = []
fnum = [100]
+"""XXX: This function seems to be broken. (CSA)
def quit(self):
perf.Stop()
perf.Join()
cs.Reset()
cs = None
+"""
def defAdsr(attack=0.01, decay=0.1, sustain=0.8, release=0.1):
"""Define an ADSR envelope. fnum = defADSR(attack = [0.01], decay = [0.1], sustain = [0.8], release = [0.1])"""
@@ -166,13 +167,16 @@ def playWave(sound='horse', pitch=1, amplitude=1, loop=False, duration=1, startt
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 getSoundList():
+ import os
return sorted(os.listdir('/usr/share/activities/TamTamEdit.activity/common/Resources/Sounds/'))
def audioOut(file=None):
"""Compile a .csd file and start csound to run it. If a string is given as argument, it write a wave file on disk instead of sending sound to hp. (file = [None])"""
global temp_path
+ import os
if temp_path is None:
from sugar import env
+ import os.path
temp_path = env.get_profile_path() + '/pippy'
if not os.path.isdir(temp_path):
os.mkdir(temp_path)