def load_sound(filename): """Return pygame sound object. Sound file shoud be a C{.wav} file. Checks the status of the sound system first, and if there is a problem, hands out L{pygsear.Sound.DummySound} objects instead of actual L{pygame.mixer.Sound} objects. @param filename: Name of file to load data from. """ global sound_cache if sound_cache.has_key(filename): sound = sound_cache[filename] return sound else: if conf.sound_status is None: Sound.check_sound() dirs = get_dirs('sounds') full_path = get_full_path(filename, dirs) try: if conf.sound_status == 'OK': sound = pygame.mixer.Sound(full_path) else: sound = Sound.DummySound() except pygame.error: sound = None if sound is None: raise pygame.error, 'Could not load %s' % filename #sound_cache[filename] = sound return sound