def play_sound_on_frame(self, frames, layer, armature, sound_name, sound_object=None, play_type='play', use_3d=True, lowpass=True, obstructed_lowpass=True, alert_entities=True, volume=1.0): """ Play a sound tied to an animation frame """ ### New sound instance sound = Sound() ### Choose random sound if isinstance(sound_name, list): sound.name = sound_name[random.randrange(0,len(sound_name))] else: sound.name = sound_name ### sound.play_on_frame = True sound.frames = frames sound.layer = layer sound.armature = armature sound.object = sound_object sound.play_type = play_type sound.use_3d = use_3d sound.lowpass = lowpass sound.obstructed_lowpass = obstructed_lowpass sound.alert_entities = alert_entities ### Check for duplicates passed = True for sound_obj in self.sounds: if sound_obj.play_on_frame: if (sound_obj.armature == armature) and (sound_obj.layer == layer): passed = False if passed: self.sounds.append(sound)
def play_sound(self, sound_name, sound_object=None, play_type='play', use_3d=True, lowpass=True, obstructed_lowpass=True, alert_entities=True, volume=1.0): """ Play a sound """ ### New sound instance sound = Sound() ### Choose random sound if isinstance(sound_name, list): sound.name = sound_name[random.randrange(0,len(sound_name))] else: sound.name = sound_name ### sound.object = sound_object sound.play_type = play_type sound.use_3d = use_3d sound.lowpass = lowpass sound.obstructed_lowpass = obstructed_lowpass sound.alert_entities = alert_entities self.sounds.append(sound)