예제 #1
0
파일: sounds.py 프로젝트: hemebond/procgen
 def updateActor(self, interval, world):
     """Update the actor"""
     super(SoundTexture, self).updateActor(interval, world)
     #
     # Update the volume of all sounds
     if self.listener:
         for sound in self.sounds:
             #
             # Update the sound volume
             current_volume = sound.get_volume()
             target_volume = sound.get_scaled_volume(
                 (self.listener.x, self.listener.y))
             #
             # Damp changes in the sound volume
             if self.damping is None:
                 new_volume = target_volume * self._master_volume
             else:
                 new_volume = max(
                     0.0,
                     min(1.0, interval / 1000.0 * self.damping) *
                     (target_volume - current_volume) +
                     current_volume) * self._master_volume
             sound.set_volume(new_volume)
     elif self._listener_required:
         raise NoListener(
             'A listener has not been set for this texture (%s)' %
             self.getNiceName())
     #
     # Play any random sounds
     if self._playing:
         for sound in self.random_sounds:
             sound.try_to_play(interval)
예제 #2
0
 def updateActor(self, interval, world):
     """Update the actor"""
     super(SoundTexture, self).updateActor(interval, world)
     #
     # Update the volume of all sounds
     if self.listener:
         for sound in self.sounds:
             #
             # Update the sound volume
             current_volume = sound.get_volume()
             target_volume = sound.get_scaled_volume((self.listener.x, self.listener.y))
             #
             # Damp changes in the sound volume
             if self.damping is None:
                 new_volume = target_volume*self._master_volume
             else:
                 new_volume = max(0.0, min(1.0, interval/1000.0*self.damping)*
                                 (target_volume - current_volume) + current_volume)*self._master_volume
             sound.set_volume(new_volume)
     elif self._listener_required:
         raise NoListener('A listener has not been set for this texture (%s)' % self.getNiceName())
     #
     # Play any random sounds
     if self._playing:
         for sound in self.random_sounds:
             sound.try_to_play(interval)
예제 #3
0
파일: sounds.py 프로젝트: hemebond/procgen
 def set_volume(self, volume):
     """Set the master volume
     
     This affects the volume of all sounds. The target volume for a sound is multiplied
     by this master.
     
     :param volume: master volume setting (0=silent, 1=full volume)
     
     """
     self._master_volume = volume
     for sound in self.getSounds():
         sound.set_volume(volume)
예제 #4
0
 def set_volume(self, volume):
     """Set the master volume
     
     This affects the volume of all sounds. The target volume for a sound is multiplied
     by this master.
     
     :param volume: master volume setting (0=silent, 1=full volume)
     
     """
     self._master_volume = volume
     for sound in self.getSounds():
         sound.set_volume(volume)