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 PyObject* KX_SoundActuator::py_getattro_dict() {
344         py_getattro_dict_up(SCA_IActuator);
345 }
346
347 int KX_SoundActuator::py_setattro(PyObject *attr, PyObject* value) {
348         py_setattro_up(SCA_IActuator);
349 }
350
351 PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
352 {
353         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
354         if (!actuator->m_soundObject)
355         {
356                 return PyString_FromString("");
357         }
358         STR_String objectname = actuator->m_soundObject->GetObjectName();
359         char* name = objectname.Ptr();
360         
361         if (!name) {
362                 PyErr_SetString(PyExc_RuntimeError, "value = actuator.filename: KX_SoundActuator, unable to get sound filename");
363                 return NULL;
364         } else
365                 return PyString_FromString(name);
366 }
367
368 PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
369 {
370         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
371         float gain = (actuator->m_soundObject) ? actuator->m_soundObject->GetGain() : 1.0f;
372
373         PyObject* result = PyFloat_FromDouble(gain);
374         
375         return result;
376 }
377
378 PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
379 {
380         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
381         float pitch = (actuator->m_soundObject) ? actuator->m_soundObject->GetPitch() : 1.0;
382         PyObject* result = PyFloat_FromDouble(pitch);
383         
384         return result;
385 }
386
387 PyObject* KX_SoundActuator::pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
388 {
389         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
390         float rollofffactor = (actuator->m_soundObject) ? actuator->m_soundObject->GetRollOffFactor() : 1.0;
391         PyObject* result = PyFloat_FromDouble(rollofffactor);
392         
393         return result;
394 }
395
396 PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
397 {
398         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
399         int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
400         PyObject* result = PyInt_FromLong(looping);
401         
402         return result;
403 }
404
405 PyObject* KX_SoundActuator::pyattr_get_position(void * self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
406 {
407         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
408         MT_Vector3 pos(0.0, 0.0, 0.0);
409
410         if (actuator->m_soundObject)
411                 pos = actuator->m_soundObject->GetPosition();
412
413         PyObject * result = PyObjectFrom(pos);
414         return result;
415 }
416
417 PyObject* KX_SoundActuator::pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
418 {
419         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
420         MT_Vector3 vel;
421
422         if (actuator->m_soundObject)
423                 vel = actuator->m_soundObject->GetVelocity();
424
425         PyObject * result = PyObjectFrom(vel);
426         return result;
427 }
428
429 PyObject* KX_SoundActuator::pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
430 {
431         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
432         MT_Matrix3x3 ori;
433
434         if (actuator->m_soundObject)
435                 ori = actuator->m_soundObject->GetOrientation();
436
437         PyObject * result = PyObjectFrom(ori);
438         return result;
439 }
440
441 int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
442 {
443         char *soundName = NULL;
444         KX_SoundActuator * actuator = static_cast<KX_SoundActuator*> (self);
445         // void *soundPointer = NULL; /*unused*/
446         
447         if (!PyArg_Parse(value, "s", &soundName))
448                 return 1;
449
450         if (actuator->m_soundObject) {
451                 actuator->m_soundObject->SetObjectName(soundName);
452         }
453         
454         return 0;
455 }
456
457
458 int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
459 {
460         float gain = 1.0;
461         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
462         if (!PyArg_Parse(value, "f", &gain))
463                 return 1;
464         
465         if (actuator->m_soundObject)
466                 actuator->m_soundObject->SetGain(gain);
467         
468         return 0;
469 }         
470
471 int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
472 {
473         float pitch = 1.0;
474         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
475         if (!PyArg_Parse(value, "f", &pitch))
476                 return 1;
477         
478         if (actuator->m_soundObject)
479                 actuator->m_soundObject->SetPitch(pitch);
480         
481         return 0;
482 }         
483
484 int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
485 {
486         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
487         float rollofffactor = 1.0;
488         if (!PyArg_Parse(value, "f", &rollofffactor))
489                 return 1;
490         
491         if (actuator->m_soundObject)
492                 actuator->m_soundObject->SetRollOffFactor(rollofffactor);
493
494         return 0;
495 }         
496
497 int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
498 {
499         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
500         int looping = 1;
501         if (!PyArg_Parse(value, "i", &looping))
502                 return 1;
503         
504         if (actuator->m_soundObject)
505                 actuator->m_soundObject->SetLoopMode(looping);
506         
507         return 0;
508 }         
509
510 int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
511 {
512         float pos[3];
513
514         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
515
516         if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
517                 return 1;
518         
519         if (actuator->m_soundObject)
520                 actuator->m_soundObject->SetPosition(MT_Vector3(pos));
521         
522         return 0;
523 }         
524
525 int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
526 {
527         float vel[3];
528         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
529
530
531         if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
532                 return 1;
533         
534         if (actuator->m_soundObject)
535                 actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
536         
537         return 0;
538
539 }         
540
541 int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
542 {
543
544         MT_Matrix3x3 rot;
545         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
546
547         /* if value is not a sequence PyOrientationTo makes an error */
548         if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator"))
549                 return NULL;
550         
551         if (!actuator->m_soundObject)
552                 return 0; /* Since not having m_soundObject didn't do anything in the old version,
553                                         * it probably should be kept that way  */
554         
555         actuator->m_soundObject->SetOrientation(rot);
556         return 0;
557 }
558
559 // Deprecated ----->
560 PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
561 {
562         char *soundName = NULL;
563         ShowDeprecationWarning("setFilename()", "the filename property");
564         // void *soundPointer = NULL; /*unused*/
565         
566         if (!PyArg_ParseTuple(args, "s", &soundName))
567                 return NULL;
568
569         Py_RETURN_NONE;
570 }
571
572 PyObject* KX_SoundActuator::PyGetFilename()
573 {
574         ShowDeprecationWarning("getFilename()", "the filename property");
575         if (!m_soundObject)
576         {
577                 return PyString_FromString("");
578         }
579         STR_String objectname = m_soundObject->GetObjectName();
580         char* name = objectname.Ptr();
581         
582         if (!name) {
583                 PyErr_SetString(PyExc_RuntimeError, "Unable to get sound filename");
584                 return NULL;
585         } else
586                 return PyString_FromString(name);
587 }
588
589 PyObject* KX_SoundActuator::PySetGain(PyObject* args)
590 {
591         ShowDeprecationWarning("setGain()", "the volume property");
592         float gain = 1.0;
593         if (!PyArg_ParseTuple(args, "f:setGain", &gain))
594                 return NULL;
595         
596         if (m_soundObject)
597                 m_soundObject->SetGain(gain);
598         
599         Py_RETURN_NONE;
600 }         
601
602
603
604 PyObject* KX_SoundActuator::PyGetGain()
605 {
606         ShowDeprecationWarning("getGain()", "the volume property");
607         float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f;
608         PyObject* result = PyFloat_FromDouble(gain);
609         
610         return result;
611 }
612
613
614
615 PyObject* KX_SoundActuator::PySetPitch(PyObject* args)
616 {
617         ShowDeprecationWarning("setPitch()", "the pitch property");
618         float pitch = 1.0;
619         if (!PyArg_ParseTuple(args, "f:setPitch", &pitch))
620                 return NULL;
621         
622         if (m_soundObject)
623                 m_soundObject->SetPitch(pitch);
624         
625         Py_RETURN_NONE;
626 }         
627
628
629
630 PyObject* KX_SoundActuator::PyGetPitch()
631 {
632         ShowDeprecationWarning("getPitch()", "the pitch property");
633         float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0;
634         PyObject* result = PyFloat_FromDouble(pitch);
635         
636         return result;
637 }
638
639
640
641 PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args)
642 {
643         ShowDeprecationWarning("setRollOffFactor()", "the rollOffFactor property");
644         float rollofffactor = 1.0;
645         if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor))
646                 return NULL;
647         
648         if (m_soundObject)
649                 m_soundObject->SetRollOffFactor(rollofffactor);
650
651         Py_RETURN_NONE;
652 }         
653
654
655
656 PyObject* KX_SoundActuator::PyGetRollOffFactor()
657 {
658         ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property");
659         float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0;
660         PyObject* result = PyFloat_FromDouble(rollofffactor);
661         
662         return result;
663 }
664
665
666
667 PyObject* KX_SoundActuator::PySetLooping(PyObject* args)
668 {
669         ShowDeprecationWarning("setLooping()", "the looping property");
670         bool looping = 1;
671         if (!PyArg_ParseTuple(args, "i:setLooping", &looping))
672                 return NULL;
673         
674         if (m_soundObject)
675                 m_soundObject->SetLoopMode(looping);
676         
677         Py_RETURN_NONE;
678 }         
679
680
681
682 PyObject* KX_SoundActuator::PyGetLooping()
683 {
684         ShowDeprecationWarning("getLooping()", "the looping property");
685         int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
686         PyObject* result = PyInt_FromLong(looping);
687         
688         return result;
689 }
690
691
692
693 PyObject* KX_SoundActuator::PySetPosition(PyObject* args)
694 {
695         MT_Point3 pos;
696         ShowDeprecationWarning("setPosition()", "the position property");
697         pos[0] = 0.0;
698         pos[1] = 0.0;
699         pos[2] = 0.0;
700
701         if (!PyArg_ParseTuple(args, "fff:setPosition", &pos[0], &pos[1], &pos[2]))
702                 return NULL;
703         
704         if (m_soundObject)
705                 m_soundObject->SetPosition(pos);
706         
707         Py_RETURN_NONE;
708 }         
709
710
711
712 PyObject* KX_SoundActuator::PySetVelocity(PyObject* args)
713 {
714         MT_Vector3 vel;
715         ShowDeprecationWarning("setVelocity()", "the velocity property");
716         vel[0] = 0.0;
717         vel[1] = 0.0;
718         vel[2] = 0.0;
719
720         if (!PyArg_ParseTuple(args, "fff:setVelocity", &vel[0], &vel[1], &vel[2]))
721                 return NULL;
722         
723         if (m_soundObject)
724                 m_soundObject->SetVelocity(vel);
725         
726         Py_RETURN_NONE;
727 }         
728
729
730
731 PyObject* KX_SoundActuator::PySetOrientation(PyObject* args)
732 {
733         MT_Matrix3x3 ori;
734         ShowDeprecationWarning("setOrientation()", "the orientation property");
735         ori[0][0] = 1.0;
736         ori[0][1] = 0.0;
737         ori[0][2] = 0.0;
738         ori[1][0] = 0.0;
739         ori[1][1] = 1.0;
740         ori[1][2] = 0.0;
741         ori[2][0] = 0.0;
742         ori[2][1] = 0.0;
743         ori[2][2] = 1.0;
744
745         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]))
746                 return NULL;
747         
748         if (m_soundObject)
749                 m_soundObject->SetOrientation(ori);
750         
751         Py_RETURN_NONE;
752 }
753
754 PyObject* KX_SoundActuator::PySetType(PyObject* args)
755 {
756         int typeArg;
757         ShowDeprecationWarning("setType()", "the type property");
758
759         if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
760                 return NULL;
761         }
762
763         if ( (typeArg > KX_SOUNDACT_NODEF)
764           && (typeArg < KX_SOUNDACT_MAX) ) {
765                 m_type = (KX_SOUNDACT_TYPE) typeArg;
766         }
767
768         Py_RETURN_NONE;
769 }
770
771 PyObject* KX_SoundActuator::PyGetType()
772 {
773         ShowDeprecationWarning("getType()", "the type property");
774         return PyInt_FromLong(m_type);
775 }
776 // <-----
777