Package horizons :: Package component :: Module ambientsoundcomponent :: Class AmbientSoundComponent
[hide private]
[frames] | no frames]

Class AmbientSoundComponent

source code

Component --+
            |
           AmbientSoundComponent

Support for playing ambient sounds, such as animal noise or collector sounds.

Instance Methods [hide private]
 
__init__(self, soundfiles=None)
Used for initialization code that does not require any other components.
source code
 
__init(self) source code
 
__create_emitter(self, gain) source code
 
_init_playing(self) source code
 
load(self, db, worldid)
This does on load what __init() and initalize() together do on constructions at runtime.
source code
 
remove(self)
Removes component and reference to instance
source code
 
play_ambient(self, soundfile, loop_interval=None, position=None, gain=10)
Starts playing an ambient sound.
source code
 
stop_sound(self)
Stops playing an ambient sound
source code
    Inherited from Component
 
__gt__(self, other) source code
 
__lt__(self, other) source code
 
initialize(self)
This is called by the ComponentHolder after it set the instance.
source code
 
save(self, db)
Will do nothing, but will be always called in componentholder code, even if not implemented.
source code
 
session(self) source code
Class Methods [hide private]
 
play_special(cls, sound, position=None, gain=10)
Plays a special sound listed in the db table sounds_special from anywhere in the code and without an instance of AmbientSound.
source code
    Inherited from Component
 
get_instance(cls, arguments=None)
This function is used to instantiate classes from yaml data.
source code
Class Variables [hide private]
  AMBIENT_SOUND_INTERVAL = 20
  AMBIENT_SOUND_INTERVAL_VARIANCE = [0, 15]
  NAME = "ambientsound"
hash(x)
    Inherited from Component
  DEPENDENCIES = []
Method Details [hide private]

__init__(self, soundfiles=None)
(Constructor)

source code 

Used for initialization code that does not require any other components. This is always called first, on construction and on load.

Parameters:
  • soundfiles - list of paths
Overrides: Component.__init__

load(self, db, worldid)

source code 

This does on load what __init() and initalize() together do on constructions at runtime. Has to set up everything that is not setup in __init__(). Note that on loading __init__() is called with the data needed by the component through get_instance(), but initialize() is not, so any work needed for loading as well should be moved to a separate method and called here.

Overrides: Component.load
(inherited documentation)

remove(self)

source code 

Removes component and reference to instance

Overrides: Component.remove
(inherited documentation)

play_ambient(self, soundfile, loop_interval=None, position=None, gain=10)

source code 

Starts playing an ambient sound. On looping, it will also play right now. Default: play sound once

Parameters:
  • soundfile - path to audio file
  • loop_interval - delay between two plays, None means no looping, 0 is no pause between looping
  • position - Point
  • gain - float, volume of the sound, default is 10

play_special(cls, sound, position=None, gain=10)
Class Method

source code 

Plays a special sound listed in the db table sounds_special from anywhere in the code and without an instance of AmbientSound.

Parameters:
  • sound - string, key in table sounds_special
  • position - optional, source of sound on map
  • gain - float, volume of the sound, default is 10