annotate engine/python/fife/extensions/soundmanager.py @ 500:5e6ff32a46fb

Added listener position to the soundmanager.
author prock@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 14 May 2010 20:28:05 +0000
parents 5ff83f209333
children 6614a5446352
rev   line source
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
1 # -*- coding: utf-8 -*-
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
2
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
3 # ####################################################################
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
4 # Copyright (C) 2005-2010 by the FIFE team
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
5 # http://www.fifengine.net
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
6 # This file is part of FIFE.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
7 #
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
8 # FIFE is free software; you can redistribute it and/or
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
9 # modify it under the terms of the GNU Lesser General Public
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
10 # License as published by the Free Software Foundation; either
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
11 # version 2.1 of the License, or (at your option) any later version.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
12 #
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
13 # This library is distributed in the hope that it will be useful,
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
16 # Lesser General Public License for more details.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
17 #
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
19 # License along with this library; if not, write to the
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
20 # Free Software Foundation, Inc.,
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
22 # ####################################################################
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
23
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
24 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
25 Sound Manager
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
26 ==================================
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
27
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
28 This is a simple implementation of a sound manager that was originaly
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
29 intended for the shooter demo. It was functional enough that we decided
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
30 to include it in the FIFE extensions. This is by no means a fully featured
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
31 implementation for several reasons. It doesnt limit how many sounds can
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
32 play at once or allow the positioning of sounds. It does however provide
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
33 a good starting point for a more advanced version of a sound manager.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
34
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
35 Usage::
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
36 soundmanager = SoundManager(my_fife_engine)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
37
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
38 emitter = soundmanager.createSoundEmitter("path/filename.ogg")
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
39 emitter.gain = 128
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
40 emitter.play()
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
41
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
42 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
43
495
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
44 from fife import fife
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
45
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
46 import fife.extensions.fife_timer as fife_timer
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
47 from fife.extensions.pychan.tools import callbackWithArguments as cbwa
ae9f5383f5b1 Added a new log module called Script. This should be used by the python modules.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 494
diff changeset
48
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
49 class SoundEmitter(object):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
50 """
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
51 Wraps the L{fife.SoundEmitter} class.
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
52
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
53 This class wraps an instance of a L{fife.SoundEmitter} class along
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
54 with some information about a sound clip (like gain and if its
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
55 looping). All instances of SoundEmitter should be created by SoundManager.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
56
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
57 @todo: At some point this class will store positional information
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
58 and also be responsible for updating the L{fife.SoundEmitter} position.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
59 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
60 def __init__(self, soundmanager, clipid, soundname, emitter):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
61 """
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
62 @param soundmanager: A reference to the SoundManager
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
63 @type soundmanager: L{SoundManager}
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
64 @param clipid: The FIFE sound clip ID from the sound clip pool
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
65 @type clipid: C{int}
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
66 @param soundname: The filename of the sound
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
67 @type soundname: C{string}
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
68 @param emitter: A reference to the L{fife.SoundEmitter} associated with this clip
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
69 @type emitter: L{fife.SoundEmitter}
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
70
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
71 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
72 self._soundmanager = soundmanager
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
73 self._name = soundname
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
74
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
75 #The FIFE SoundEmitter associated with this SoundEmitter.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
76 #Note that we do NOT own the emitter.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
77 self._fifeemitter = emitter
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
78 self._fifeemitter.thisown = 0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
79 self._fifeclipid = clipid
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
80
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
81 #0 = mute, 255 = normal volume
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
82 self._gain = 255.0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
83 self._looping = False
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
84
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
85 #if you set the callback it will be executed after the sound
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
86 #has finished playing.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
87 self._callback = None
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
88
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
89 #length of the sound
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
90 self._duration = 0
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
91
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
92 self._timer = None
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
93
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
94 self._position = None
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
95 self._rolloff = 0
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
96
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
97 def play(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
98 self._soundmanager.playClip(self)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
99
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
100 def stop(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
101 self._soundmanager.stopClip(self)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
102
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
103 def _getClipID(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
104 return self._fifeclipid
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
105
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
106 def _getGain(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
107 return self._gain
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
108
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
109 def _setGain(self, gain):
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
110 """
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
111 Sets the volume of the L{SoundEmitter}.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
112
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
113 @param gain: Value should be from 0-255. 0 being mute and 255 being the normal
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
114 volume of the clip.
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
115 @type gain: C{int}
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
116 """
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
117 self._gain = float(gain)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
118
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
119 def _getLooping(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
120 return self._looping
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
121
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
122 def _setLooping(self, looping):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
123 self._looping = looping
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
124
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
125 def _getFifeEmitter(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
126 return self._fifeemitter
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
127
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
128 def _setFifeEmitter(self, emitter):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
129 self._fifeemitter = emitter
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
130 if self._fifeemitter:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
131 self._fifeemitter.thisown = 0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
132
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
133 def _getName(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
134 return self._name
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
135
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
136 def _getCallback(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
137 return self._callback
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
138
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
139 def _setCallback(self, cb):
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
140 self._callback = cb
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
141
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
142 def _getDuration(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
143 return self._duration
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
144
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
145 def _setDuration(self, millliseconds):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
146 self._duration = millliseconds
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
147
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
148 def _getTimer(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
149 return self._timer
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
150
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
151 def _setTimer(self, timer):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
152 self._timer = timer
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
153
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
154 def _setPosition(self, position):
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
155 self._position = position
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
156
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
157 def _getPosition(self):
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
158 return self._position
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
159
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
160 def _setRolloff(self, rolloff):
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
161 self._rolloff = rolloff
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
162
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
163 def _getRolloff(self):
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
164 return self._rolloff
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
165
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
166 rolloff = property(_getRolloff, _setRolloff)
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
167 position = property(_getPosition, _setPosition)
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
168 timer = property(_getTimer, _setTimer)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
169 clipid = property(_getClipID)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
170 gain = property(_getGain, _setGain)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
171 looping = property(_getLooping, _setLooping)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
172 fifeemitter = property(_getFifeEmitter, _setFifeEmitter)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
173 name = property(_getName)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
174 callback = property(_getCallback, _setCallback)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
175 duration = property(_getDuration, _setDuration)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
176
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
177 class SoundManager(object):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
178 """
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
179 A simple sound manager class.
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
180
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
181 This class manages and plays all the sounds of the game.
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
182 It creates SoundEmitters and ensures that there is only one
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
183 L{fife.SoundEmitter} per unique sound.
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
184 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
185 def __init__(self, engine):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
186 """
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
187 @param engine: A reference to the FIFE engine
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
188 @type engine: L{fife.Engine}
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
189 """
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
190
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
191 self._engine = engine
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
192
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
193 self._fifesoundmanager = self._engine.getSoundManager()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
194 self._fifesoundmanager.init()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
195
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
196 # basic rolloff used for positional sounds
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
197 self._rolloff = 1
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
198
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
199 #A dict of fife emitters
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
200 self._loadedclips = {}
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
201
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
202 #A tuple representing the listener position (x,y)
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
203 self._listenerposition = None
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
204
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
205 def createSoundEmitter(self, filename, forceUnique=False, position=None):
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
206 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
207 Returns a valid SoundEmitter instance.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
208
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
209 @param filename: The relative path and filename of the sound file
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
210 @type clip: C{string}
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
211 @param forceUnique: This forces a new L{fife.SoundEmitter} to be created.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
212 This is useful if you want more than one instance of the same sound
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
213 to be played at the same time.
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
214 @type forceUnique: C{boolean}
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
215 @param position: The position on the map that the sound emitter
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
216 is to be created at.
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
217 @type position: L{tuple}
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
218
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
219 @return: Returns a new L{SoundEmitter} instance.
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
220 @rtype: L{SoundEmitter}
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
221 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
222 if not self._loadedclips.has_key(filename):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
223 clipid = self._engine.getSoundClipPool().addResourceFromFile(filename)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
224 fifeemitter = self._fifesoundmanager.createEmitter()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
225 fifeemitter.thisown = 0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
226 fifeemitter.setSoundClip(clipid)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
227 self._loadedclips[filename] = [fifeemitter]
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
228 clip = SoundEmitter(self, clipid, filename, fifeemitter)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
229 clip.duration = fifeemitter.getDuration()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
230 else:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
231 if forceUnique:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
232 clipid = self._engine.getSoundClipPool().addResourceFromFile(filename)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
233 fifeemitter = self._fifesoundmanager.createEmitter()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
234 fifeemitter.thisown = 0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
235 fifeemitter.setSoundClip(clipid)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
236 self._loadedclips[filename].append(fifeemitter)
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
237 else:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
238 fifeemitter = self._loadedclips[filename][0]
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
239
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
240 clip = SoundEmitter(self, fifeemitter.getID(), filename, fifeemitter)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
241 clip.duration = fifeemitter.getDuration()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
242
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
243 if position is not None:
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
244 clip.position = position
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
245 clip.rolloff = self.rolloff
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
246
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
247 return clip
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
248
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
249 def playClip(self, clip):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
250 """
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
251 Plays a sound clip.
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
252
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
253 This function does not use the L{fife.SoundEmitter}
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
254 "looping" property to loop a sound. Instead it registers
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
255 a new timer and uses the duration of the clip as the timer length.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
256
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
257 If the SoundEmitter is invalid (no fifeemitter) then it attempts
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
258 to load it before playing it.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
259
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
260 @note: This will stop any clips that use the same L{fife.SoundEmitter}.
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
261 You cannot play the same sound more than once at a time unless you create
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
262 the SoundEmitter with the forceUnique paramater set to True.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
263
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
264 @param clip: The L{SoundEmitter} to be played
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
265 @type clip: L{SoundEmitter}
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
266 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
267 if clip.fifeemitter:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
268 if clip.callback:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
269 if clip.timer:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
270 clip.timer.stop()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
271 timer = None
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
272
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
273 if clip.looping:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
274 repeat = 0
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
275 def real_callback(c, e, g):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
276 c()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
277 e.stop()
493
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
278 e.setGain(float(g)/255.0)
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
279 e.play()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
280
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
281 clip.callback = cbwa(real_callback, clip.callback, clip.fifeemitter, clip.gain)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
282
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
283 else:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
284 repeat = 1
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
285
493
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
286 clip.timer = fife_timer.Timer(clip.duration, clip.callback, repeat)
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
287
493
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
288 else:
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
289 if clip.looping:
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
290 def real_callback(e, g):
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
291 e.stop()
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
292 e.setGain(float(g)/255.0)
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
293 e.play()
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
294
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
295 clip.callback = cbwa(real_callback, clip.fifeemitter, clip.gain)
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
296 clip.timer = fife_timer.Timer(clip.duration, clip.callback, 0)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
297
493
e29853880e87 Adapted rio_do_hola to use the new SoundManager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 492
diff changeset
298 clip.fifeemitter.setGain(float(clip.gain)/255.0)
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
299
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
300 if self.listenerposition and clip.position:
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
301 # Use 1 as z coordinate, no need to specify it
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
302 clip.fifeemitter.setPosition(clip.position[0], clip.position[1], 1)
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
303 clip.fifeemitter.setRolloff(clip.rolloff)
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
304 elif self.listenerposition and not clip.position:
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
305 clip.fifeemitter.setPosition(self.listenerposition[0], self.listenerposition[1], 1)
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
306 clip.fifeemitter.setRolloff(self.rolloff)
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
307
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
308 clip.fifeemitter.play()
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
309 if clip.timer:
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
310 clip.timer.start()
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
311
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
312 else:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
313 clip = self.createSoundEmitter(clip.name)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
314 self.playClip(clip)
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
315
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
316 def stopClip(self, clip):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
317 """
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
318 Stops playing the sound clip. Note that this will stop all clips that
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
319 use the same FIFE emitter.
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
320
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
321 @param clip: The SoundEmitter to stop.
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
322 @type clip: L{SoundEmitter}
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
323 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
324 if clip.fifeemitter:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
325 clip.fifeemitter.stop()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
326
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
327 if clip.timer:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
328 clip.timer.stop()
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
329 clip.timer = None
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
330
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
331 def stopAllSounds(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
332 for emitterlist in self._loadedclips.values():
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
333 for emitter in emitterlist:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
334 emitter.stop()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
335
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
336 def destroy(self):
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
337 """
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
338 Releases all instances of L{fife.SoundEmitter}.
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
339
494
e241d7553496 Fixing the epydoc markup. Did some more commenting.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 493
diff changeset
340 @note: This does not free the resources from the FIFE sound clip pool.
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
341 """
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
342 self.stopAllSounds()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
343
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
344 for emitterlist in self._loadedclips.values():
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
345 for emitter in emitterlist:
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
346 self._fifesoundmanager.releaseEmitter(emitter.getID())
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
347 emitter = None
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
348
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
349 self._loadedclips.clear()
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
350
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
351 def _getRolloff(self):
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
352 return self._rolloff
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
353
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
354 def _setRolloff(self, rolloff):
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
355 self._rolloff = rolloff
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
356
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
357 def _getListenerPosition(self):
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
358 return self._listenerposition
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
359
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
360 def _setListenerPosition(self, position):
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
361 self._listenerposition = position
498
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
362 self._fifesoundmanager.setListenerPosition(self._listenerposition[0], self._listenerposition[1], 1)
5ff83f209333 Added positioning to the soundmanager classes
nihathrael@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 495
diff changeset
363
500
5e6ff32a46fb Added listener position to the soundmanager.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents: 498
diff changeset
364 rolloff = property(_getRolloff, _setRolloff)
492
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
365 listenerposition = property(_getListenerPosition, _setListenerPosition)
16ceb3228324 Moved the SoundManager and the 2D math function (helpers) from the shooter demo to the fife extensions.
prock@33b003aa-7bff-0310-803a-e67f0ece8222
parents:
diff changeset
366