svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r20937:21899
[blender.git] / source / gameengine / Ketsji / KX_SoundActuator.cpp
1 /**
2  * KX_SoundActuator.cpp
3  *
4  * $Id$
5  *
6  * ***** BEGIN GPL LICENSE BLOCK *****
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software Foundation,
20  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21  *
22  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
23  * All rights reserved.
24  *
25  * The Original Code is: all of this file.
26  *
27  * Contributor(s): none yet.
28  *
29  * ***** END GPL LICENSE BLOCK *****
30  *
31  */
32
33 #include "KX_SoundActuator.h"
34 #include "SND_SoundObject.h"
35 #include "KX_GameObject.h"
36 #include "SND_SoundObject.h"
37 #include "SND_Scene.h" // needed for replication
38 #include "KX_PyMath.h" // needed for PyObjectFrom()
39 #include <iostream>
40
41 #ifdef HAVE_CONFIG_H
42 #include <config.h>
43 #endif
44
45 /* ------------------------------------------------------------------------- */
46 /* Native functions                                                          */
47 /* ------------------------------------------------------------------------- */
48 KX_SoundActuator::KX_SoundActuator(SCA_IObject* gameobj,
49                                                                    SND_SoundObject* sndobj,
50                                                                    SND_Scene*   sndscene,
51                                                                    KX_SOUNDACT_TYPE type,
52                                                                    short start,
53                                                                    short end)
54                                                                    : SCA_IActuator(gameobj)
55 {
56         m_soundObject = sndobj;
57         m_soundScene = sndscene;
58         m_type = type;
59         m_lastEvent = true;
60         m_isplaying = false;
61         m_startFrame = start;
62         m_endFrame = end;
63         m_pino = false;
64         
65
66 }
67
68
69
70 KX_SoundActuator::~KX_SoundActuator()
71 {
72         if (m_soundObject)
73         {
74                 m_soundScene->RemoveActiveObject(m_soundObject);
75                 m_soundScene->DeleteObject(m_soundObject);
76         }
77 }
78
79
80
81 CValue* KX_SoundActuator::GetReplica()
82 {
83         KX_SoundActuator* replica = new KX_SoundActuator(*this);
84         replica->ProcessReplica();
85         return replica;
86 };
87
88 void KX_SoundActuator::ProcessReplica()
89 {
90         SCA_IActuator::ProcessReplica();
91         if (m_soundObject)
92         {
93             SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
94                 setSoundObject(soundobj);
95                 m_soundScene->AddObject(soundobj);
96         }
97 }       
98
99 bool KX_SoundActuator::Update(double curtime, bool frame)
100 {
101         if (!frame)
102                 return true;
103         bool result = false;
104
105         // do nothing on negative events, otherwise sounds are played twice!
106         bool bNegativeEvent = IsNegativeEvent();
107         bool bPositiveEvent = m_posevent;
108         
109         RemoveAllEvents();
110
111         if (!m_soundObject)
112                 return false;
113
114         // actual audio device playing state
115         bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false;
116
117         if (m_pino)
118         {
119                 bNegativeEvent = true;
120                 m_pino = false;
121         }
122
123         if (bNegativeEvent)
124         {       
125                 // here must be a check if it is still playing
126                 if (m_isplaying && isplaying) 
127                 {
128                         switch (m_type)
129                         {
130                         case KX_SOUNDACT_PLAYSTOP:
131                         case KX_SOUNDACT_LOOPSTOP:
132                         case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
133                                 {
134                                         m_soundScene->RemoveActiveObject(m_soundObject);
135                                         break;
136                                 }
137                         case KX_SOUNDACT_PLAYEND:
138                                 {
139                                         m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
140                                         break;
141                                 }
142                         case KX_SOUNDACT_LOOPEND:
143                         case KX_SOUNDACT_LOOPBIDIRECTIONAL:
144                                 {
145                                         m_soundObject->SetLoopMode(SND_LOOP_OFF);
146                                         m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
147                                         break;
148                                 }
149                         default:
150                                 // implement me !!
151                                 break;
152                         }
153                 }
154                 // remember that we tried to stop the actuator
155                 m_isplaying = false;
156         }
157         
158 #if 1
159         // Warning: when de-activating the actuator, after a single negative event this runs again with...
160         // m_posevent==false && m_posevent==false, in this case IsNegativeEvent() returns false 
161         // and assumes this is a positive event.
162         // check that we actually have a positive event so as not to play sounds when being disabled.
163         else if(bPositiveEvent) { // <- added since 2.49
164 #else
165         else {  // <- works in most cases except a loop-end sound will never stop unless
166                         // the negative pulse is done continuesly
167 #endif
168                 if (!m_isplaying)
169                 {
170                         switch (m_type)
171                         {
172                         case KX_SOUNDACT_LOOPBIDIRECTIONAL:
173                         case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
174                                 {
175                                         m_soundObject->SetLoopMode(SND_LOOP_BIDIRECTIONAL);
176                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
177                                         m_isplaying = true;
178                                         result = true;
179                                         break;
180                                 }
181                         case KX_SOUNDACT_LOOPEND:
182                         case KX_SOUNDACT_LOOPSTOP:
183                                 {
184                                         m_soundObject->SetLoopMode(SND_LOOP_NORMAL);
185                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
186                                         m_isplaying = true;
187                                         result = true;
188                                         break;
189                                 }
190                         case KX_SOUNDACT_PLAYSTOP:
191                         case KX_SOUNDACT_PLAYEND:
192                                 {
193                                         m_soundObject->SetLoopMode(SND_LOOP_OFF);
194                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
195                                         m_isplaying = true;
196                                         result = true;
197                                         break;
198                                 }
199                         default:
200                                 // implement me !!
201                                 break;
202                         }
203                 }
204         }
205         // verify that the sound is still playing
206         isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false;
207
208         if (isplaying)
209         {
210                 m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition());
211                 m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity());
212                 m_soundObject->SetOrientation(((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation());
213                 result = true;
214         }
215         else
216         {
217                 m_isplaying = false;
218                 result = false;
219         }
220         /*
221         if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP)))
222         {
223                 m_pino = true;
224         }
225         */
226         return result;
227 }
228
229
230
231 void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject)
232 {
233         m_soundObject = soundobject;
234 }
235
236
237
238 /* ------------------------------------------------------------------------- */
239 /* Python functions                                                          */
240 /* ------------------------------------------------------------------------- */
241
242
243
244 /* Integration hooks ------------------------------------------------------- */
245 PyTypeObject KX_SoundActuator::Type = {
246 #if (PY_VERSION_HEX >= 0x02060000)
247         PyVarObject_HEAD_INIT(NULL, 0)
248 #else
249         /* python 2.5 and below */
250         PyObject_HEAD_INIT( NULL )  /* required py macro */
251         0,                          /* ob_size */
252 #endif
253                 "KX_SoundActuator",
254                 sizeof(PyObjectPlus_Proxy),
255                 0,
256                 py_base_dealloc,
257                 0,
258                 0,
259                 0,
260                 0,
261                 py_base_repr,
262                 0,0,0,0,0,0,0,0,0,
263                 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
264                 0,0,0,0,0,0,0,
265                 Methods,
266                 0,
267                 0,
268                 &SCA_IActuator::Type,
269                 0,0,0,0,0,0,
270                 py_base_new
271 };
272
273 PyMethodDef KX_SoundActuator::Methods[] = {
274         // Deprecated ----->
275         {"setFilename", (PyCFunction) KX_SoundActuator::sPySetFilename, METH_VARARGS,NULL},
276         {"getFilename", (PyCFunction) KX_SoundActuator::sPyGetFilename, METH_NOARGS,NULL},
277         {"setGain",(PyCFunction) KX_SoundActuator::sPySetGain,METH_VARARGS,NULL},
278         {"getGain",(PyCFunction) KX_SoundActuator::sPyGetGain,METH_NOARGS,NULL},
279         {"setPitch",(PyCFunction) KX_SoundActuator::sPySetPitch,METH_VARARGS,NULL},
280         {"getPitch",(PyCFunction) KX_SoundActuator::sPyGetPitch,METH_NOARGS,NULL},
281         {"setRollOffFactor",(PyCFunction) KX_SoundActuator::sPySetRollOffFactor,METH_VARARGS,NULL},
282         {"getRollOffFactor",(PyCFunction) KX_SoundActuator::sPyGetRollOffFactor,METH_NOARGS,NULL},
283         {"setLooping",(PyCFunction) KX_SoundActuator::sPySetLooping,METH_VARARGS,NULL},
284         {"getLooping",(PyCFunction) KX_SoundActuator::sPyGetLooping,METH_NOARGS,NULL},
285         {"setPosition",(PyCFunction) KX_SoundActuator::sPySetPosition,METH_VARARGS,NULL},
286         {"setVelocity",(PyCFunction) KX_SoundActuator::sPySetVelocity,METH_VARARGS,NULL},
287         {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL},
288         {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL},
289         {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_NOARGS,NULL},
290         // <-----
291
292         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, startSound),
293         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, pauseSound),
294         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, stopSound),
295         {NULL,NULL,NULL,NULL} //Sentinel
296 };
297
298 PyAttributeDef KX_SoundActuator::Attributes[] = {
299         KX_PYATTRIBUTE_RW_FUNCTION("fileName", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename),
300         KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain),
301         KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch),
302         KX_PYATTRIBUTE_RW_FUNCTION("rollOffFactor", KX_SoundActuator, pyattr_get_rollOffFactor, pyattr_set_rollOffFactor),
303         KX_PYATTRIBUTE_RW_FUNCTION("looping", KX_SoundActuator, pyattr_get_looping, pyattr_set_looping),
304         KX_PYATTRIBUTE_RW_FUNCTION("position", KX_SoundActuator, pyattr_get_position, pyattr_set_position),
305         KX_PYATTRIBUTE_RW_FUNCTION("velocity", KX_SoundActuator, pyattr_get_velocity, pyattr_set_velocity),
306         KX_PYATTRIBUTE_RW_FUNCTION("orientation", KX_SoundActuator, pyattr_get_orientation, pyattr_set_orientation),
307         KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
308         { NULL }        //Sentinel
309 };
310
311 /* Methods ----------------------------------------------------------------- */
312 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, 
313 "startSound()\n"
314 "\tStarts the sound.\n")
315 {
316         if (m_soundObject)
317                 // This has no effect if the actuator is not active.
318                 // To start the sound you must activate the actuator. 
319                 // This function is to restart the sound.
320                 m_soundObject->StartSound();    
321         Py_RETURN_NONE;
322 }         
323
324 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
325 "pauseSound()\n"
326 "\tPauses the sound.\n")
327 {
328         if (m_soundObject)
329                 // unfortunately, openal does not implement pause correctly, it is equivalent to a stop
330                 m_soundObject->PauseSound();    
331         Py_RETURN_NONE;
332
333
334 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
335 "stopSound()\n"
336 "\tStops the sound.\n")
337 {
338         if (m_soundObject)
339                 m_soundObject->StopSound();     
340         Py_RETURN_NONE;
341 }
342
343 /* Atribute setting and getting -------------------------------------------- */
344
345 PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
346 {
347         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
348         if (!actuator->m_soundObject)
349         {
350                 return PyUnicode_FromString("");
351         }
352         STR_String objectname = actuator->m_soundObject->GetObjectName();
353         char* name = objectname.Ptr();
354         
355         if (!name) {
356                 PyErr_SetString(PyExc_RuntimeError, "value = actuator.fileName: KX_SoundActuator, unable to get sound fileName");
357                 return NULL;
358         } else
359                 return PyUnicode_FromString(name);
360 }
361
362 PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
363 {
364         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
365         float gain = (actuator->m_soundObject) ? actuator->m_soundObject->GetGain() : 1.0f;
366
367         PyObject* result = PyFloat_FromDouble(gain);
368         
369         return result;
370 }
371
372 PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
373 {
374         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
375         float pitch = (actuator->m_soundObject) ? actuator->m_soundObject->GetPitch() : 1.0;
376         PyObject* result = PyFloat_FromDouble(pitch);
377         
378         return result;
379 }
380
381 PyObject* KX_SoundActuator::pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
382 {
383         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
384         float rollofffactor = (actuator->m_soundObject) ? actuator->m_soundObject->GetRollOffFactor() : 1.0;
385         PyObject* result = PyFloat_FromDouble(rollofffactor);
386         
387         return result;
388 }
389
390 PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
391 {
392         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
393         int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
394         PyObject* result = PyLong_FromSsize_t(looping);
395         
396         return result;
397 }
398
399 PyObject* KX_SoundActuator::pyattr_get_position(void * self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
400 {
401         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
402         MT_Vector3 pos(0.0, 0.0, 0.0);
403
404         if (actuator->m_soundObject)
405                 pos = actuator->m_soundObject->GetPosition();
406
407         PyObject * result = PyObjectFrom(pos);
408         return result;
409 }
410
411 PyObject* KX_SoundActuator::pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
412 {
413         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
414         MT_Vector3 vel;
415
416         if (actuator->m_soundObject)
417                 vel = actuator->m_soundObject->GetVelocity();
418
419         PyObject * result = PyObjectFrom(vel);
420         return result;
421 }
422
423 PyObject* KX_SoundActuator::pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
424 {
425         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
426         MT_Matrix3x3 ori;
427
428         if (actuator->m_soundObject)
429                 ori = actuator->m_soundObject->GetOrientation();
430
431         PyObject * result = PyObjectFrom(ori);
432         return result;
433 }
434
435 int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
436 {
437         char *soundName = NULL;
438         KX_SoundActuator * actuator = static_cast<KX_SoundActuator*> (self);
439         // void *soundPointer = NULL; /*unused*/
440         
441         if (!PyArg_Parse(value, "s", &soundName))
442                 return PY_SET_ATTR_FAIL;
443
444         if (actuator->m_soundObject) {
445                 actuator->m_soundObject->SetObjectName(soundName);
446         }
447         
448         return PY_SET_ATTR_SUCCESS;
449 }
450
451
452 int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
453 {
454         float gain = 1.0;
455         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
456         if (!PyArg_Parse(value, "f", &gain))
457                 return PY_SET_ATTR_FAIL;
458         
459         if (actuator->m_soundObject)
460                 actuator->m_soundObject->SetGain(gain);
461         
462         return PY_SET_ATTR_SUCCESS;
463 }         
464
465 int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
466 {
467         float pitch = 1.0;
468         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
469         if (!PyArg_Parse(value, "f", &pitch))
470                 return PY_SET_ATTR_FAIL;
471         
472         if (actuator->m_soundObject)
473                 actuator->m_soundObject->SetPitch(pitch);
474         
475         return PY_SET_ATTR_SUCCESS;
476 }         
477
478 int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
479 {
480         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
481         float rollofffactor = 1.0;
482         if (!PyArg_Parse(value, "f", &rollofffactor))
483                 return PY_SET_ATTR_FAIL;
484         
485         if (actuator->m_soundObject)
486                 actuator->m_soundObject->SetRollOffFactor(rollofffactor);
487
488         return PY_SET_ATTR_SUCCESS;
489 }         
490
491 int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
492 {
493         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
494         int looping = 1;
495         if (!PyArg_Parse(value, "i", &looping))
496                 return PY_SET_ATTR_FAIL;
497         
498         if (actuator->m_soundObject)
499                 actuator->m_soundObject->SetLoopMode(looping);
500         
501         return PY_SET_ATTR_SUCCESS;
502 }         
503
504 int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
505 {
506         float pos[3];
507
508         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
509
510         if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
511                 return PY_SET_ATTR_FAIL;
512         
513         if (actuator->m_soundObject)
514                 actuator->m_soundObject->SetPosition(MT_Vector3(pos));
515         
516         return PY_SET_ATTR_SUCCESS;
517 }         
518
519 int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
520 {
521         float vel[3];
522         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
523
524
525         if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
526                 return PY_SET_ATTR_FAIL;
527         
528         if (actuator->m_soundObject)
529                 actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
530         
531         return PY_SET_ATTR_SUCCESS;
532
533 }         
534
535 int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
536 {
537
538         MT_Matrix3x3 rot;
539         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
540
541         /* if value is not a sequence PyOrientationTo makes an error */
542         if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator"))
543                 return PY_SET_ATTR_FAIL;
544         
545         /* Since not having m_soundObject didn't do anything in the old version,
546          * it probably should be kept that way  */
547         if (!actuator->m_soundObject)
548                 return PY_SET_ATTR_SUCCESS;
549         
550         actuator->m_soundObject->SetOrientation(rot);
551         return PY_SET_ATTR_SUCCESS;
552 }
553
554 // Deprecated ----->
555 PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
556 {
557         char *soundName = NULL;
558         ShowDeprecationWarning("setFilename()", "the fileName property");
559         // void *soundPointer = NULL; /*unused*/
560         
561         if (!PyArg_ParseTuple(args, "s", &soundName))
562                 return NULL;
563
564         Py_RETURN_NONE;
565 }
566
567 PyObject* KX_SoundActuator::PyGetFilename()
568 {
569         ShowDeprecationWarning("getFilename()", "the fileName property");
570         if (!m_soundObject)
571         {
572                 return PyUnicode_FromString("");
573         }
574         STR_String objectname = m_soundObject->GetObjectName();
575         char* name = objectname.Ptr();
576         
577         if (!name) {
578                 PyErr_SetString(PyExc_RuntimeError, "Unable to get sound fileName");
579                 return NULL;
580         } else
581                 return PyUnicode_FromString(name);
582 }
583
584 PyObject* KX_SoundActuator::PySetGain(PyObject* args)
585 {
586         ShowDeprecationWarning("setGain()", "the volume property");
587         float gain = 1.0;
588         if (!PyArg_ParseTuple(args, "f:setGain", &gain))
589                 return NULL;
590         
591         if (m_soundObject)
592                 m_soundObject->SetGain(gain);
593         
594         Py_RETURN_NONE;
595 }         
596
597
598
599 PyObject* KX_SoundActuator::PyGetGain()
600 {
601         ShowDeprecationWarning("getGain()", "the volume property");
602         float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f;
603         PyObject* result = PyFloat_FromDouble(gain);
604         
605         return result;
606 }
607
608
609
610 PyObject* KX_SoundActuator::PySetPitch(PyObject* args)
611 {
612         ShowDeprecationWarning("setPitch()", "the pitch property");
613         float pitch = 1.0;
614         if (!PyArg_ParseTuple(args, "f:setPitch", &pitch))
615                 return NULL;
616         
617         if (m_soundObject)
618                 m_soundObject->SetPitch(pitch);
619         
620         Py_RETURN_NONE;
621 }         
622
623
624
625 PyObject* KX_SoundActuator::PyGetPitch()
626 {
627         ShowDeprecationWarning("getPitch()", "the pitch property");
628         float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0;
629         PyObject* result = PyFloat_FromDouble(pitch);
630         
631         return result;
632 }
633
634
635
636 PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args)
637 {
638         ShowDeprecationWarning("setRollOffFactor()", "the rollOffFactor property");
639         float rollofffactor = 1.0;
640         if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor))
641                 return NULL;
642         
643         if (m_soundObject)
644                 m_soundObject->SetRollOffFactor(rollofffactor);
645
646         Py_RETURN_NONE;
647 }         
648
649
650
651 PyObject* KX_SoundActuator::PyGetRollOffFactor()
652 {
653         ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property");
654         float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0;
655         PyObject* result = PyFloat_FromDouble(rollofffactor);
656         
657         return result;
658 }
659
660
661
662 PyObject* KX_SoundActuator::PySetLooping(PyObject* args)
663 {
664         ShowDeprecationWarning("setLooping()", "the looping property");
665         bool looping = 1;
666         if (!PyArg_ParseTuple(args, "i:setLooping", &looping))
667                 return NULL;
668         
669         if (m_soundObject)
670                 m_soundObject->SetLoopMode(looping);
671         
672         Py_RETURN_NONE;
673 }         
674
675
676
677 PyObject* KX_SoundActuator::PyGetLooping()
678 {
679         ShowDeprecationWarning("getLooping()", "the looping property");
680         int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
681         PyObject* result = PyLong_FromSsize_t(looping);
682         
683         return result;
684 }
685
686
687
688 PyObject* KX_SoundActuator::PySetPosition(PyObject* args)
689 {
690         MT_Point3 pos;
691         ShowDeprecationWarning("setPosition()", "the position property");
692         pos[0] = 0.0;
693         pos[1] = 0.0;
694         pos[2] = 0.0;
695
696         if (!PyArg_ParseTuple(args, "fff:setPosition", &pos[0], &pos[1], &pos[2]))
697                 return NULL;
698         
699         if (m_soundObject)
700                 m_soundObject->SetPosition(pos);
701         
702         Py_RETURN_NONE;
703 }         
704
705
706
707 PyObject* KX_SoundActuator::PySetVelocity(PyObject* args)
708 {
709         MT_Vector3 vel;
710         ShowDeprecationWarning("setVelocity()", "the velocity property");
711         vel[0] = 0.0;
712         vel[1] = 0.0;
713         vel[2] = 0.0;
714
715         if (!PyArg_ParseTuple(args, "fff:setVelocity", &vel[0], &vel[1], &vel[2]))
716                 return NULL;
717         
718         if (m_soundObject)
719                 m_soundObject->SetVelocity(vel);
720         
721         Py_RETURN_NONE;
722 }         
723
724
725
726 PyObject* KX_SoundActuator::PySetOrientation(PyObject* args)
727 {
728         MT_Matrix3x3 ori;
729         ShowDeprecationWarning("setOrientation()", "the orientation property");
730         ori[0][0] = 1.0;
731         ori[0][1] = 0.0;
732         ori[0][2] = 0.0;
733         ori[1][0] = 0.0;
734         ori[1][1] = 1.0;
735         ori[1][2] = 0.0;
736         ori[2][0] = 0.0;
737         ori[2][1] = 0.0;
738         ori[2][2] = 1.0;
739
740         if (!PyArg_ParseTuple(args, "fffffffff:setOrientation", &ori[0][0], &ori[0][1], &ori[0][2], &ori[1][0], &ori[1][1], &ori[1][2], &ori[2][0], &ori[2][1], &ori[2][2]))
741                 return NULL;
742         
743         if (m_soundObject)
744                 m_soundObject->SetOrientation(ori);
745         
746         Py_RETURN_NONE;
747 }
748
749 PyObject* KX_SoundActuator::PySetType(PyObject* args)
750 {
751         int typeArg;
752         ShowDeprecationWarning("setType()", "the mode property");
753
754         if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
755                 return NULL;
756         }
757
758         if ( (typeArg > KX_SOUNDACT_NODEF)
759           && (typeArg < KX_SOUNDACT_MAX) ) {
760                 m_type = (KX_SOUNDACT_TYPE) typeArg;
761         }
762
763         Py_RETURN_NONE;
764 }
765
766 PyObject* KX_SoundActuator::PyGetType()
767 {
768         ShowDeprecationWarning("getType()", "the mode property");
769         return PyLong_FromSsize_t(m_type);
770 }
771 // <-----
772