Mercurial > touhou
comparison pytouhou/ui/music.pyx @ 535:a50c0a1b628f
Don’t stop music loading if the pos file isn’t found.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 05 Apr 2014 13:51:31 +0200 |
parents | bd0c15d28dd6 |
children | e15672733c93 |
comparison
equal
deleted
inserted
replaced
534:346cbf266856 | 535:a50c0a1b628f |
---|---|
34 continue | 34 continue |
35 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') | 35 posname = bgm[1].replace('bgm/', '').replace('.mid', '.pos') |
36 try: | 36 try: |
37 track = resource_loader.get_track(posname) | 37 track = resource_loader.get_track(posname) |
38 except KeyError: | 38 except KeyError: |
39 self.bgms.append(None) | 39 track = None |
40 logger.warn(u'Music description “%s” not found.', posname) | 40 logger.warn(u'Music description “%s” not found, continuing without looping data.', posname) |
41 continue | |
42 globname = join(resource_loader.game_dir, bgm[1].encode('ascii')).replace('.mid', '.*') | 41 globname = join(resource_loader.game_dir, bgm[1].encode('ascii')).replace('.mid', '.*') |
43 filenames = glob(globname) | 42 filenames = glob(globname) |
44 for filename in reversed(filenames): | 43 for filename in reversed(filenames): |
45 try: | 44 try: |
46 source = sdl.load_music(filename) | 45 source = sdl.load_music(filename) |
47 except sdl.SDLError as error: | 46 except sdl.SDLError as error: |
48 logger.debug(u'Music file “%s” unreadable: %s', filename, error) | 47 logger.debug(u'Music file “%s” unreadable: %s', filename, error) |
49 continue | 48 continue |
50 else: | 49 else: |
51 source.set_loop_points(track.start / 44100., track.end / 44100.) #TODO: retrieve the sample rate from the actual track. | 50 if track is not None: |
51 source.set_loop_points(track.start / 44100., track.end / 44100.) #TODO: retrieve the sample rate from the actual track. | |
52 self.bgms.append(source) | 52 self.bgms.append(source) |
53 logger.debug(u'Music file “%s” opened.', filename) | 53 logger.debug(u'Music file “%s” opened.', filename) |
54 break | 54 break |
55 else: | 55 else: |
56 self.bgms.append(None) | 56 self.bgms.append(None) |