diff pytouhou/ui/music.pyx @ 455:6864a38b2413

Make pytouhou.lib.sdl cimportable, and convert pytouhou.ui.window.* to extension types.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 02 Sep 2013 22:16:38 +0200
parents pytouhou/ui/music.py@b1248bab2d0f
children ca22df9e70bc
line wrap: on
line diff
copy from pytouhou/ui/music.py
copy to pytouhou/ui/music.pyx
--- a/pytouhou/ui/music.py
+++ b/pytouhou/ui/music.pyx
@@ -15,7 +15,7 @@
 
 from os.path import join
 from glob import glob
-from pytouhou.lib import sdl
+from pytouhou.lib cimport sdl
 from pytouhou.utils.helpers import get_logger
 
 logger = get_logger(__name__)
@@ -53,6 +53,7 @@ class MusicPlayer(object):
                 logger.warn(u'No working music file for ā€œ%sā€, disabling bgm.', globname)
 
     def play(self, index):
+        cdef sdl.Music bgm
         bgm = self.bgms[index]
         if bgm:
             bgm.play(-1)
@@ -75,11 +76,13 @@ class SFXPlayer(object):
     def get_sound(self, name):
         if name not in self.sounds:
             wave_file = self.loader.get_file(name)
-            self.sounds[name] = sdl.load_chunk(wave_file)
-            self.sounds[name].volume = self.volume
+            chunk = sdl.load_chunk(wave_file)
+            chunk.set_volume(self.volume)
+            self.sounds[name] = chunk
         return self.sounds[name]
 
     def play(self, name, volume=None):
+        cdef sdl.Chunk sound
         sound = self.get_sound(name)
         channel = self.get_channel(name)
         if volume: