BGE Python API
[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                                                                    PyTypeObject* T)
55                                                                    : SCA_IActuator(gameobj,T)
56 {
57         m_soundObject = sndobj;
58         m_soundScene = sndscene;
59         m_type = type;
60         m_lastEvent = true;
61         m_isplaying = false;
62         m_startFrame = start;
63         m_endFrame = end;
64         m_pino = false;
65         
66
67 }
68
69
70
71 KX_SoundActuator::~KX_SoundActuator()
72 {
73         if (m_soundObject)
74         {
75                 m_soundScene->RemoveActiveObject(m_soundObject);
76                 m_soundScene->DeleteObject(m_soundObject);
77         }
78 }
79
80
81
82 CValue* KX_SoundActuator::GetReplica()
83 {
84         KX_SoundActuator* replica = new KX_SoundActuator(*this);
85         replica->ProcessReplica();
86         if (m_soundObject)
87         {
88             SND_SoundObject* soundobj = new SND_SoundObject(*m_soundObject);
89                 replica->setSoundObject(soundobj);
90                 m_soundScene->AddObject(soundobj);
91         }
92         
93         // this will copy properties and so on...
94         CValue::AddDataToReplica(replica);
95         return replica;
96 };
97
98
99
100 bool KX_SoundActuator::Update(double curtime, bool frame)
101 {
102         if (!frame)
103                 return true;
104         bool result = false;
105
106         // do nothing on negative events, otherwise sounds are played twice!
107         bool bNegativeEvent = IsNegativeEvent();
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) ? 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         else
158         {
159                 if (!m_isplaying)
160                 {
161                         switch (m_type)
162                         {
163                         case KX_SOUNDACT_LOOPBIDIRECTIONAL:
164                         case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
165                                 {
166                                         m_soundObject->SetLoopMode(SND_LOOP_BIDIRECTIONAL);
167                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
168                                         m_isplaying = true;
169                                         result = true;
170                                         break;
171                                 }
172                         case KX_SOUNDACT_LOOPEND:
173                         case KX_SOUNDACT_LOOPSTOP:
174                                 {
175                                         m_soundObject->SetLoopMode(SND_LOOP_NORMAL);
176                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
177                                         m_isplaying = true;
178                                         result = true;
179                                         break;
180                                 }
181                         case KX_SOUNDACT_PLAYSTOP:
182                         case KX_SOUNDACT_PLAYEND:
183                                 {
184                                         m_soundObject->SetLoopMode(SND_LOOP_OFF);
185                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
186                                         m_isplaying = true;
187                                         result = true;
188                                         break;
189                                 }
190                         default:
191                                 // implement me !!
192                                 break;
193                         }
194                 }
195         }
196         // verify that the sound is still playing
197         isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED) ? true : false;
198
199         if (isplaying)
200         {
201                 m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition());
202                 m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity());
203                 m_soundObject->SetOrientation(((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation());
204                 result = true;
205         }
206         else
207         {
208                 m_isplaying = false;
209                 result = false;
210         }
211         /*
212         if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP)))
213         {
214                 m_pino = true;
215         }
216         */
217         return result;
218 }
219
220
221
222 void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject)
223 {
224         m_soundObject = soundobject;
225 }
226
227
228
229 /* ------------------------------------------------------------------------- */
230 /* Python functions                                                          */
231 /* ------------------------------------------------------------------------- */
232
233
234
235 /* Integration hooks ------------------------------------------------------- */
236 PyTypeObject KX_SoundActuator::Type = {
237         PyObject_HEAD_INIT(NULL)
238                 0,
239                 "KX_SoundActuator",
240                 sizeof(PyObjectPlus_Proxy),
241                 0,
242                 py_base_dealloc,
243                 0,
244                 0,
245                 0,
246                 0,
247                 py_base_repr,
248                 0,0,0,0,0,0,
249                 py_base_getattro,
250                 py_base_setattro,
251                 0,0,0,0,0,0,0,0,0,
252                 Methods
253 };
254
255
256
257 PyParentObject KX_SoundActuator::Parents[] = {
258         &KX_SoundActuator::Type,
259                 &SCA_IActuator::Type,
260                 &SCA_ILogicBrick::Type,
261                 &CValue::Type,
262                 NULL
263 };
264
265
266
267 PyMethodDef KX_SoundActuator::Methods[] = {
268         // Deprecated ----->
269         {"setFilename", (PyCFunction) KX_SoundActuator::sPySetFilename, METH_VARARGS,NULL},
270         {"getFilename", (PyCFunction) KX_SoundActuator::sPyGetFilename, METH_NOARGS,NULL},
271         {"setGain",(PyCFunction) KX_SoundActuator::sPySetGain,METH_VARARGS,NULL},
272         {"getGain",(PyCFunction) KX_SoundActuator::sPyGetGain,METH_NOARGS,NULL},
273         {"setPitch",(PyCFunction) KX_SoundActuator::sPySetPitch,METH_VARARGS,NULL},
274         {"getPitch",(PyCFunction) KX_SoundActuator::sPyGetPitch,METH_NOARGS,NULL},
275         {"setRollOffFactor",(PyCFunction) KX_SoundActuator::sPySetRollOffFactor,METH_VARARGS,NULL},
276         {"getRollOffFactor",(PyCFunction) KX_SoundActuator::sPyGetRollOffFactor,METH_NOARGS,NULL},
277         {"setLooping",(PyCFunction) KX_SoundActuator::sPySetLooping,METH_VARARGS,NULL},
278         {"getLooping",(PyCFunction) KX_SoundActuator::sPyGetLooping,METH_NOARGS,NULL},
279         {"setPosition",(PyCFunction) KX_SoundActuator::sPySetPosition,METH_VARARGS,NULL},
280         {"setVelocity",(PyCFunction) KX_SoundActuator::sPySetVelocity,METH_VARARGS,NULL},
281         {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL},
282         {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL},
283         {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_NOARGS,NULL},
284         // <-----
285
286         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, startSound),
287         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, pauseSound),
288         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, stopSound),
289         {NULL,NULL,NULL,NULL} //Sentinel
290 };
291
292 PyAttributeDef KX_SoundActuator::Attributes[] = {
293         KX_PYATTRIBUTE_RW_FUNCTION("filename", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename),
294         KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain),
295         KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch),
296         KX_PYATTRIBUTE_RW_FUNCTION("rollOffFactor", KX_SoundActuator, pyattr_get_rollOffFactor, pyattr_set_rollOffFactor),
297         KX_PYATTRIBUTE_RW_FUNCTION("looping", KX_SoundActuator, pyattr_get_looping, pyattr_set_looping),
298         KX_PYATTRIBUTE_RW_FUNCTION("position", KX_SoundActuator, pyattr_get_position, pyattr_set_position),
299         KX_PYATTRIBUTE_RW_FUNCTION("velocity", KX_SoundActuator, pyattr_get_velocity, pyattr_set_velocity),
300         KX_PYATTRIBUTE_RW_FUNCTION("orientation", KX_SoundActuator, pyattr_get_orientation, pyattr_set_orientation),
301         KX_PYATTRIBUTE_ENUM_RW("type",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
302         { NULL }        //Sentinel
303 };
304
305 /* Methods ----------------------------------------------------------------- */
306 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, 
307 "startSound()\n"
308 "\tStarts the sound.\n")
309 {
310         if (m_soundObject)
311                 // This has no effect if the actuator is not active.
312                 // To start the sound you must activate the actuator. 
313                 // This function is to restart the sound.
314                 m_soundObject->StartSound();    
315         Py_RETURN_NONE;
316 }         
317
318 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
319 "pauseSound()\n"
320 "\tPauses the sound.\n")
321 {
322         if (m_soundObject)
323                 // unfortunately, openal does not implement pause correctly, it is equivalent to a stop
324                 m_soundObject->PauseSound();    
325         Py_RETURN_NONE;
326
327
328 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
329 "stopSound()\n"
330 "\tStops the sound.\n")
331 {
332         if (m_soundObject)
333                 m_soundObject->StopSound();     
334         Py_RETURN_NONE;
335 }
336
337 /* Atribute setting and getting -------------------------------------------- */
338 PyObject* KX_SoundActuator::py_getattro(PyObject *attr)
339 {
340         py_getattro_up(SCA_IActuator);
341 }
342
343 int KX_SoundActuator::py_setattro(PyObject *attr, PyObject* value) {
344         py_setattro_up(SCA_IActuator);
345 }
346
347 PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
348 {
349         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
350         if (!actuator->m_soundObject)
351         {
352                 return PyString_FromString("");
353         }
354         STR_String objectname = actuator->m_soundObject->GetObjectName();
355         char* name = objectname.Ptr();
356         
357         if (!name) {
358                 PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
359                 return NULL;
360         } else
361                 return PyString_FromString(name);
362 }
363
364 PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
365 {
366         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
367         float gain = (actuator->m_soundObject) ? actuator->m_soundObject->GetGain() : 1.0f;
368
369         PyObject* result = PyFloat_FromDouble(gain);
370         
371         return result;
372 }
373
374 PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
375 {
376         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
377         float pitch = (actuator->m_soundObject) ? actuator->m_soundObject->GetPitch() : 1.0;
378         PyObject* result = PyFloat_FromDouble(pitch);
379         
380         return result;
381 }
382
383 PyObject* KX_SoundActuator::pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
384 {
385         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
386         float rollofffactor = (actuator->m_soundObject) ? actuator->m_soundObject->GetRollOffFactor() : 1.0;
387         PyObject* result = PyFloat_FromDouble(rollofffactor);
388         
389         return result;
390 }
391
392 PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
393 {
394         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
395         int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
396         PyObject* result = PyInt_FromLong(looping);
397         
398         return result;
399 }
400
401 PyObject* KX_SoundActuator::pyattr_get_position(void * self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
402 {
403         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
404         MT_Vector3 pos(0.0, 0.0, 0.0);
405
406         if (actuator->m_soundObject)
407                 pos = actuator->m_soundObject->GetPosition();
408
409         PyObject * result = PyObjectFrom(pos);
410         return result;
411 }
412
413 PyObject* KX_SoundActuator::pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
414 {
415         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
416         MT_Vector3 vel;
417
418         if (actuator->m_soundObject)
419                 vel = actuator->m_soundObject->GetVelocity();
420
421         PyObject * result = PyObjectFrom(vel);
422         return result;
423 }
424
425 PyObject* KX_SoundActuator::pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
426 {
427         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
428         MT_Matrix3x3 ori;
429
430         if (actuator->m_soundObject)
431                 ori = actuator->m_soundObject->GetOrientation();
432
433         PyObject * result = PyObjectFrom(ori);
434         return result;
435 }
436
437 int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
438 {
439         char *soundName = NULL;
440         KX_SoundActuator * actuator = static_cast<KX_SoundActuator*> (self);
441         // void *soundPointer = NULL; /*unused*/
442         
443         if (!PyArg_Parse(value, "s", &soundName))
444                 return 1;
445
446         if (actuator->m_soundObject) {
447                 actuator->m_soundObject->SetObjectName(soundName);
448         }
449         
450         return 0;
451 }
452
453
454 int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
455 {
456         float gain = 1.0;
457         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
458         if (!PyArg_Parse(value, "f", &gain))
459                 return 1;
460         
461         if (actuator->m_soundObject)
462                 actuator->m_soundObject->SetGain(gain);
463         
464         return 0;
465 }         
466
467 int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
468 {
469         float pitch = 1.0;
470         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
471         if (!PyArg_Parse(value, "f", &pitch))
472                 return 1;
473         
474         if (actuator->m_soundObject)
475                 actuator->m_soundObject->SetPitch(pitch);
476         
477         return 0;
478 }         
479
480 int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
481 {
482         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
483         float rollofffactor = 1.0;
484         if (!PyArg_Parse(value, "f", &rollofffactor))
485                 return 1;
486         
487         if (actuator->m_soundObject)
488                 actuator->m_soundObject->SetRollOffFactor(rollofffactor);
489
490         return 0;
491 }         
492
493 int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
494 {
495         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
496         int looping = 1;
497         if (!PyArg_Parse(value, "i", &looping))
498                 return 1;
499         
500         if (actuator->m_soundObject)
501                 actuator->m_soundObject->SetLoopMode(looping);
502         
503         return 0;
504 }         
505
506 int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
507 {
508         float pos[3];
509
510         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
511
512         if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
513                 return 1;
514         
515         if (actuator->m_soundObject)
516                 actuator->m_soundObject->SetPosition(MT_Vector3(pos));
517         
518         return 0;
519 }         
520
521 int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
522 {
523         float vel[3];
524         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
525
526
527         if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
528                 return 1;
529         
530         if (actuator->m_soundObject)
531                 actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
532         
533         return 0;
534
535 }         
536
537 int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
538 {
539
540         MT_Matrix3x3 rot;
541         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
542
543         if (!PySequence_Check(value)) {
544                 PyErr_SetString(PyExc_AttributeError, "'orientation' attribute needs to be a sequence");
545                 return 1;
546         }
547
548         if (!actuator->m_soundObject)
549                 return 0; /* Since not having m_soundObject didn't do anything in the old version,
550                                   * it probably should be kept that way  */
551
552         if (PyMatTo(value, rot))
553         {
554                 actuator->m_soundObject->SetOrientation(rot);
555                 return 0;
556         }
557         PyErr_Clear();
558
559
560         if (PySequence_Size(value) == 4)
561         {
562                 MT_Quaternion qrot;
563                 if (PyVecTo(value, qrot))
564                 {
565                         rot.setRotation(qrot);
566                         actuator->m_soundObject->SetOrientation(rot);
567                         return 0;
568                 }
569                 return 1;
570         }
571
572         if (PySequence_Size(value) == 3)
573         {
574                 MT_Vector3 erot;
575                 if (PyVecTo(value, erot))
576                 {
577                         rot.setEuler(erot);
578                         actuator->m_soundObject->SetOrientation(rot);
579                         return 0;
580                 }
581                 return 1;
582         }
583
584         PyErr_SetString(PyExc_AttributeError, "could not set the orientation from a 3x3 matrix, quaternion or euler sequence");
585         return 1;
586
587 }
588
589 // Deprecated ----->
590 PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
591 {
592         char *soundName = NULL;
593         ShowDeprecationWarning("setFilename()", "the filename property");
594         // void *soundPointer = NULL; /*unused*/
595         
596         if (!PyArg_ParseTuple(args, "s", &soundName))
597                 return NULL;
598
599         Py_RETURN_NONE;
600 }
601
602 PyObject* KX_SoundActuator::PyGetFilename()
603 {
604         ShowDeprecationWarning("getFilename()", "the filename property");
605         if (!m_soundObject)
606         {
607                 return PyString_FromString("");
608         }
609         STR_String objectname = m_soundObject->GetObjectName();
610         char* name = objectname.Ptr();
611         
612         if (!name) {
613                 PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
614                 return NULL;
615         } else
616                 return PyString_FromString(name);
617 }
618
619 PyObject* KX_SoundActuator::PySetGain(PyObject* args)
620 {
621         ShowDeprecationWarning("setGain()", "the volume property");
622         float gain = 1.0;
623         if (!PyArg_ParseTuple(args, "f:setGain", &gain))
624                 return NULL;
625         
626         if (m_soundObject)
627                 m_soundObject->SetGain(gain);
628         
629         Py_RETURN_NONE;
630 }         
631
632
633
634 PyObject* KX_SoundActuator::PyGetGain()
635 {
636         ShowDeprecationWarning("getGain()", "the volume property");
637         float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f;
638         PyObject* result = PyFloat_FromDouble(gain);
639         
640         return result;
641 }
642
643
644
645 PyObject* KX_SoundActuator::PySetPitch(PyObject* args)
646 {
647         ShowDeprecationWarning("setPitch()", "the pitch property");
648         float pitch = 1.0;
649         if (!PyArg_ParseTuple(args, "f:setPitch", &pitch))
650                 return NULL;
651         
652         if (m_soundObject)
653                 m_soundObject->SetPitch(pitch);
654         
655         Py_RETURN_NONE;
656 }         
657
658
659
660 PyObject* KX_SoundActuator::PyGetPitch()
661 {
662         ShowDeprecationWarning("getPitch()", "the pitch property");
663         float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0;
664         PyObject* result = PyFloat_FromDouble(pitch);
665         
666         return result;
667 }
668
669
670
671 PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args)
672 {
673         ShowDeprecationWarning("setRollOffFactor()", "the rollOffFactor property");
674         float rollofffactor = 1.0;
675         if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor))
676                 return NULL;
677         
678         if (m_soundObject)
679                 m_soundObject->SetRollOffFactor(rollofffactor);
680
681         Py_RETURN_NONE;
682 }         
683
684
685
686 PyObject* KX_SoundActuator::PyGetRollOffFactor()
687 {
688         ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property");
689         float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0;
690         PyObject* result = PyFloat_FromDouble(rollofffactor);
691         
692         return result;
693 }
694
695
696
697 PyObject* KX_SoundActuator::PySetLooping(PyObject* args)
698 {
699         ShowDeprecationWarning("setLooping()", "the looping property");
700         bool looping = 1;
701         if (!PyArg_ParseTuple(args, "i:setLooping", &looping))
702                 return NULL;
703         
704         if (m_soundObject)
705                 m_soundObject->SetLoopMode(looping);
706         
707         Py_RETURN_NONE;
708 }         
709
710
711
712 PyObject* KX_SoundActuator::PyGetLooping()
713 {
714         ShowDeprecationWarning("getLooping()", "the looping property");
715         int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
716         PyObject* result = PyInt_FromLong(looping);
717         
718         return result;
719 }
720
721
722
723 PyObject* KX_SoundActuator::PySetPosition(PyObject* args)
724 {
725         MT_Point3 pos;
726         ShowDeprecationWarning("setPosition()", "the position property");
727         pos[0] = 0.0;
728         pos[1] = 0.0;
729         pos[2] = 0.0;
730
731         if (!PyArg_ParseTuple(args, "fff:setPosition", &pos[0], &pos[1], &pos[2]))
732                 return NULL;
733         
734         if (m_soundObject)
735                 m_soundObject->SetPosition(pos);
736         
737         Py_RETURN_NONE;
738 }         
739
740
741
742 PyObject* KX_SoundActuator::PySetVelocity(PyObject* args)
743 {
744         MT_Vector3 vel;
745         ShowDeprecationWarning("setVelocity()", "the velocity property");
746         vel[0] = 0.0;
747         vel[1] = 0.0;
748         vel[2] = 0.0;
749
750         if (!PyArg_ParseTuple(args, "fff:setVelocity", &vel[0], &vel[1], &vel[2]))
751                 return NULL;
752         
753         if (m_soundObject)
754                 m_soundObject->SetVelocity(vel);
755         
756         Py_RETURN_NONE;
757 }         
758
759
760
761 PyObject* KX_SoundActuator::PySetOrientation(PyObject* args)
762 {
763         MT_Matrix3x3 ori;
764         ShowDeprecationWarning("setOrientation()", "the orientation property");
765         ori[0][0] = 1.0;
766         ori[0][1] = 0.0;
767         ori[0][2] = 0.0;
768         ori[1][0] = 0.0;
769         ori[1][1] = 1.0;
770         ori[1][2] = 0.0;
771         ori[2][0] = 0.0;
772         ori[2][1] = 0.0;
773         ori[2][2] = 1.0;
774
775         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]))
776                 return NULL;
777         
778         if (m_soundObject)
779                 m_soundObject->SetOrientation(ori);
780         
781         Py_RETURN_NONE;
782 }
783
784 PyObject* KX_SoundActuator::PySetType(PyObject* args)
785 {
786         int typeArg;
787         ShowDeprecationWarning("setType()", "the type property");
788
789         if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
790                 return NULL;
791         }
792
793         if ( (typeArg > KX_SOUNDACT_NODEF)
794           && (typeArg < KX_SOUNDACT_MAX) ) {
795                 m_type = (KX_SOUNDACT_TYPE) typeArg;
796         }
797
798         Py_RETURN_NONE;
799 }
800
801 PyObject* KX_SoundActuator::PyGetType()
802 {
803         ShowDeprecationWarning("getType()", "the type property");
804         return PyInt_FromLong(m_type);
805 }
806 // <-----
807