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                                                                    : 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
108         RemoveAllEvents();
109
110         if (!m_soundObject)
111                 return false;
112
113         // actual audio device playing state
114         bool isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false;
115
116         if (m_pino)
117         {
118                 bNegativeEvent = true;
119                 m_pino = false;
120         }
121
122         if (bNegativeEvent)
123         {       
124                 // here must be a check if it is still playing
125                 if (m_isplaying && isplaying) 
126                 {
127                         switch (m_type)
128                         {
129                         case KX_SOUNDACT_PLAYSTOP:
130                         case KX_SOUNDACT_LOOPSTOP:
131                         case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
132                                 {
133                                         m_soundScene->RemoveActiveObject(m_soundObject);
134                                         break;
135                                 }
136                         case KX_SOUNDACT_PLAYEND:
137                                 {
138                                         m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
139                                         break;
140                                 }
141                         case KX_SOUNDACT_LOOPEND:
142                         case KX_SOUNDACT_LOOPBIDIRECTIONAL:
143                                 {
144                                         m_soundObject->SetLoopMode(SND_LOOP_OFF);
145                                         m_soundObject->SetPlaystate(SND_MUST_STOP_WHEN_FINISHED);
146                                         break;
147                                 }
148                         default:
149                                 // implement me !!
150                                 break;
151                         }
152                 }
153                 // remember that we tried to stop the actuator
154                 m_isplaying = false;
155         }
156         else
157         {
158                 if (!m_isplaying)
159                 {
160                         switch (m_type)
161                         {
162                         case KX_SOUNDACT_LOOPBIDIRECTIONAL:
163                         case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
164                                 {
165                                         m_soundObject->SetLoopMode(SND_LOOP_BIDIRECTIONAL);
166                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
167                                         m_isplaying = true;
168                                         result = true;
169                                         break;
170                                 }
171                         case KX_SOUNDACT_LOOPEND:
172                         case KX_SOUNDACT_LOOPSTOP:
173                                 {
174                                         m_soundObject->SetLoopMode(SND_LOOP_NORMAL);
175                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
176                                         m_isplaying = true;
177                                         result = true;
178                                         break;
179                                 }
180                         case KX_SOUNDACT_PLAYSTOP:
181                         case KX_SOUNDACT_PLAYEND:
182                                 {
183                                         m_soundObject->SetLoopMode(SND_LOOP_OFF);
184                                         m_soundScene->AddActiveObject(m_soundObject, curtime);
185                                         m_isplaying = true;
186                                         result = true;
187                                         break;
188                                 }
189                         default:
190                                 // implement me !!
191                                 break;
192                         }
193                 }
194         }
195         // verify that the sound is still playing
196         isplaying = (m_soundObject->GetPlaystate() != SND_STOPPED && m_soundObject->GetPlaystate() != SND_INITIAL) ? true : false;
197
198         if (isplaying)
199         {
200                 m_soundObject->SetPosition(((KX_GameObject*)this->GetParent())->NodeGetWorldPosition());
201                 m_soundObject->SetVelocity(((KX_GameObject*)this->GetParent())->GetLinearVelocity());
202                 m_soundObject->SetOrientation(((KX_GameObject*)this->GetParent())->NodeGetWorldOrientation());
203                 result = true;
204         }
205         else
206         {
207                 m_isplaying = false;
208                 result = false;
209         }
210         /*
211         if (result && (m_soundObject->IsLifeSpanOver(curtime)) && ((m_type == KX_SOUNDACT_PLAYEND) || (m_type == KX_SOUNDACT_PLAYSTOP)))
212         {
213                 m_pino = true;
214         }
215         */
216         return result;
217 }
218
219
220
221 void KX_SoundActuator::setSoundObject(class SND_SoundObject* soundobject)
222 {
223         m_soundObject = soundobject;
224 }
225
226
227
228 /* ------------------------------------------------------------------------- */
229 /* Python functions                                                          */
230 /* ------------------------------------------------------------------------- */
231
232
233
234 /* Integration hooks ------------------------------------------------------- */
235 PyTypeObject KX_SoundActuator::Type = {
236 #if (PY_VERSION_HEX >= 0x02060000)
237         PyVarObject_HEAD_INIT(NULL, 0)
238 #else
239         /* python 2.5 and below */
240         PyObject_HEAD_INIT( NULL )  /* required py macro */
241         0,                          /* ob_size */
242 #endif
243                 "KX_SoundActuator",
244                 sizeof(PyObjectPlus_Proxy),
245                 0,
246                 py_base_dealloc,
247                 0,
248                 0,
249                 0,
250                 0,
251                 py_base_repr,
252                 0,0,0,0,0,0,
253                 NULL, //py_base_getattro,
254                 NULL, //py_base_setattro,
255                 0,
256                 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
257                 0,0,0,0,0,0,0,
258                 Methods,
259                 0,
260                 0,
261                 &SCA_IActuator::Type
262 };
263
264 PyMethodDef KX_SoundActuator::Methods[] = {
265         // Deprecated ----->
266         {"setFilename", (PyCFunction) KX_SoundActuator::sPySetFilename, METH_VARARGS,NULL},
267         {"getFilename", (PyCFunction) KX_SoundActuator::sPyGetFilename, METH_NOARGS,NULL},
268         {"setGain",(PyCFunction) KX_SoundActuator::sPySetGain,METH_VARARGS,NULL},
269         {"getGain",(PyCFunction) KX_SoundActuator::sPyGetGain,METH_NOARGS,NULL},
270         {"setPitch",(PyCFunction) KX_SoundActuator::sPySetPitch,METH_VARARGS,NULL},
271         {"getPitch",(PyCFunction) KX_SoundActuator::sPyGetPitch,METH_NOARGS,NULL},
272         {"setRollOffFactor",(PyCFunction) KX_SoundActuator::sPySetRollOffFactor,METH_VARARGS,NULL},
273         {"getRollOffFactor",(PyCFunction) KX_SoundActuator::sPyGetRollOffFactor,METH_NOARGS,NULL},
274         {"setLooping",(PyCFunction) KX_SoundActuator::sPySetLooping,METH_VARARGS,NULL},
275         {"getLooping",(PyCFunction) KX_SoundActuator::sPyGetLooping,METH_NOARGS,NULL},
276         {"setPosition",(PyCFunction) KX_SoundActuator::sPySetPosition,METH_VARARGS,NULL},
277         {"setVelocity",(PyCFunction) KX_SoundActuator::sPySetVelocity,METH_VARARGS,NULL},
278         {"setOrientation",(PyCFunction) KX_SoundActuator::sPySetOrientation,METH_VARARGS,NULL},
279         {"setType",(PyCFunction) KX_SoundActuator::sPySetType,METH_VARARGS,NULL},
280         {"getType",(PyCFunction) KX_SoundActuator::sPyGetType,METH_NOARGS,NULL},
281         // <-----
282
283         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, startSound),
284         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, pauseSound),
285         KX_PYMETHODTABLE_NOARGS(KX_SoundActuator, stopSound),
286         {NULL,NULL,NULL,NULL} //Sentinel
287 };
288
289 PyAttributeDef KX_SoundActuator::Attributes[] = {
290         KX_PYATTRIBUTE_RW_FUNCTION("fileName", KX_SoundActuator, pyattr_get_filename, pyattr_set_filename),
291         KX_PYATTRIBUTE_RW_FUNCTION("volume", KX_SoundActuator, pyattr_get_gain, pyattr_set_gain),
292         KX_PYATTRIBUTE_RW_FUNCTION("pitch", KX_SoundActuator, pyattr_get_pitch, pyattr_set_pitch),
293         KX_PYATTRIBUTE_RW_FUNCTION("rollOffFactor", KX_SoundActuator, pyattr_get_rollOffFactor, pyattr_set_rollOffFactor),
294         KX_PYATTRIBUTE_RW_FUNCTION("looping", KX_SoundActuator, pyattr_get_looping, pyattr_set_looping),
295         KX_PYATTRIBUTE_RW_FUNCTION("position", KX_SoundActuator, pyattr_get_position, pyattr_set_position),
296         KX_PYATTRIBUTE_RW_FUNCTION("velocity", KX_SoundActuator, pyattr_get_velocity, pyattr_set_velocity),
297         KX_PYATTRIBUTE_RW_FUNCTION("orientation", KX_SoundActuator, pyattr_get_orientation, pyattr_set_orientation),
298         KX_PYATTRIBUTE_ENUM_RW("mode",KX_SoundActuator::KX_SOUNDACT_NODEF+1,KX_SoundActuator::KX_SOUNDACT_MAX-1,false,KX_SoundActuator,m_type),
299         { NULL }        //Sentinel
300 };
301
302 /* Methods ----------------------------------------------------------------- */
303 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, startSound, 
304 "startSound()\n"
305 "\tStarts the sound.\n")
306 {
307         if (m_soundObject)
308                 // This has no effect if the actuator is not active.
309                 // To start the sound you must activate the actuator. 
310                 // This function is to restart the sound.
311                 m_soundObject->StartSound();    
312         Py_RETURN_NONE;
313 }         
314
315 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, pauseSound,
316 "pauseSound()\n"
317 "\tPauses the sound.\n")
318 {
319         if (m_soundObject)
320                 // unfortunately, openal does not implement pause correctly, it is equivalent to a stop
321                 m_soundObject->PauseSound();    
322         Py_RETURN_NONE;
323
324
325 KX_PYMETHODDEF_DOC_NOARGS(KX_SoundActuator, stopSound,
326 "stopSound()\n"
327 "\tStops the sound.\n")
328 {
329         if (m_soundObject)
330                 m_soundObject->StopSound();     
331         Py_RETURN_NONE;
332 }
333
334 /* Atribute setting and getting -------------------------------------------- */
335
336 PyObject* KX_SoundActuator::pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
337 {
338         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
339         if (!actuator->m_soundObject)
340         {
341                 return PyString_FromString("");
342         }
343         STR_String objectname = actuator->m_soundObject->GetObjectName();
344         char* name = objectname.Ptr();
345         
346         if (!name) {
347                 PyErr_SetString(PyExc_RuntimeError, "value = actuator.fileName: KX_SoundActuator, unable to get sound fileName");
348                 return NULL;
349         } else
350                 return PyString_FromString(name);
351 }
352
353 PyObject* KX_SoundActuator::pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
354 {
355         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
356         float gain = (actuator->m_soundObject) ? actuator->m_soundObject->GetGain() : 1.0f;
357
358         PyObject* result = PyFloat_FromDouble(gain);
359         
360         return result;
361 }
362
363 PyObject* KX_SoundActuator::pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
364 {
365         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
366         float pitch = (actuator->m_soundObject) ? actuator->m_soundObject->GetPitch() : 1.0;
367         PyObject* result = PyFloat_FromDouble(pitch);
368         
369         return result;
370 }
371
372 PyObject* KX_SoundActuator::pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
373 {
374         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
375         float rollofffactor = (actuator->m_soundObject) ? actuator->m_soundObject->GetRollOffFactor() : 1.0;
376         PyObject* result = PyFloat_FromDouble(rollofffactor);
377         
378         return result;
379 }
380
381 PyObject* KX_SoundActuator::pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
382 {
383         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
384         int looping = (actuator->m_soundObject) ? actuator->m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
385         PyObject* result = PyInt_FromLong(looping);
386         
387         return result;
388 }
389
390 PyObject* KX_SoundActuator::pyattr_get_position(void * self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
391 {
392         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
393         MT_Vector3 pos(0.0, 0.0, 0.0);
394
395         if (actuator->m_soundObject)
396                 pos = actuator->m_soundObject->GetPosition();
397
398         PyObject * result = PyObjectFrom(pos);
399         return result;
400 }
401
402 PyObject* KX_SoundActuator::pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef)
403 {
404         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
405         MT_Vector3 vel;
406
407         if (actuator->m_soundObject)
408                 vel = actuator->m_soundObject->GetVelocity();
409
410         PyObject * result = PyObjectFrom(vel);
411         return result;
412 }
413
414 PyObject* KX_SoundActuator::pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef) 
415 {
416         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
417         MT_Matrix3x3 ori;
418
419         if (actuator->m_soundObject)
420                 ori = actuator->m_soundObject->GetOrientation();
421
422         PyObject * result = PyObjectFrom(ori);
423         return result;
424 }
425
426 int KX_SoundActuator::pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
427 {
428         char *soundName = NULL;
429         KX_SoundActuator * actuator = static_cast<KX_SoundActuator*> (self);
430         // void *soundPointer = NULL; /*unused*/
431         
432         if (!PyArg_Parse(value, "s", &soundName))
433                 return PY_SET_ATTR_FAIL;
434
435         if (actuator->m_soundObject) {
436                 actuator->m_soundObject->SetObjectName(soundName);
437         }
438         
439         return PY_SET_ATTR_SUCCESS;
440 }
441
442
443 int KX_SoundActuator::pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
444 {
445         float gain = 1.0;
446         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
447         if (!PyArg_Parse(value, "f", &gain))
448                 return PY_SET_ATTR_FAIL;
449         
450         if (actuator->m_soundObject)
451                 actuator->m_soundObject->SetGain(gain);
452         
453         return PY_SET_ATTR_SUCCESS;
454 }         
455
456 int KX_SoundActuator::pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
457 {
458         float pitch = 1.0;
459         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
460         if (!PyArg_Parse(value, "f", &pitch))
461                 return PY_SET_ATTR_FAIL;
462         
463         if (actuator->m_soundObject)
464                 actuator->m_soundObject->SetPitch(pitch);
465         
466         return PY_SET_ATTR_SUCCESS;
467 }         
468
469 int KX_SoundActuator::pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
470 {
471         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
472         float rollofffactor = 1.0;
473         if (!PyArg_Parse(value, "f", &rollofffactor))
474                 return PY_SET_ATTR_FAIL;
475         
476         if (actuator->m_soundObject)
477                 actuator->m_soundObject->SetRollOffFactor(rollofffactor);
478
479         return PY_SET_ATTR_SUCCESS;
480 }         
481
482 int KX_SoundActuator::pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
483 {
484         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
485         int looping = 1;
486         if (!PyArg_Parse(value, "i", &looping))
487                 return PY_SET_ATTR_FAIL;
488         
489         if (actuator->m_soundObject)
490                 actuator->m_soundObject->SetLoopMode(looping);
491         
492         return PY_SET_ATTR_SUCCESS;
493 }         
494
495 int KX_SoundActuator::pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
496 {
497         float pos[3];
498
499         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
500
501         if (!PyArg_ParseTuple(value, "fff", &pos[0], &pos[1], &pos[2]))
502                 return PY_SET_ATTR_FAIL;
503         
504         if (actuator->m_soundObject)
505                 actuator->m_soundObject->SetPosition(MT_Vector3(pos));
506         
507         return PY_SET_ATTR_SUCCESS;
508 }         
509
510 int KX_SoundActuator::pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
511 {
512         float vel[3];
513         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
514
515
516         if (!PyArg_ParseTuple(value, "fff", &vel[0], &vel[1], &vel[2]))
517                 return PY_SET_ATTR_FAIL;
518         
519         if (actuator->m_soundObject)
520                 actuator->m_soundObject->SetVelocity(MT_Vector3(vel));
521         
522         return PY_SET_ATTR_SUCCESS;
523
524 }         
525
526 int KX_SoundActuator::pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value)
527 {
528
529         MT_Matrix3x3 rot;
530         KX_SoundActuator * actuator = static_cast<KX_SoundActuator *> (self);
531
532         /* if value is not a sequence PyOrientationTo makes an error */
533         if (!PyOrientationTo(value, rot, "actuator.orientation = value: KX_SoundActuator"))
534                 return PY_SET_ATTR_FAIL;
535         
536         /* Since not having m_soundObject didn't do anything in the old version,
537          * it probably should be kept that way  */
538         if (!actuator->m_soundObject)
539                 return PY_SET_ATTR_SUCCESS;
540         
541         actuator->m_soundObject->SetOrientation(rot);
542         return PY_SET_ATTR_SUCCESS;
543 }
544
545 // Deprecated ----->
546 PyObject* KX_SoundActuator::PySetFilename(PyObject* args)
547 {
548         char *soundName = NULL;
549         ShowDeprecationWarning("setFilename()", "the fileName property");
550         // void *soundPointer = NULL; /*unused*/
551         
552         if (!PyArg_ParseTuple(args, "s", &soundName))
553                 return NULL;
554
555         Py_RETURN_NONE;
556 }
557
558 PyObject* KX_SoundActuator::PyGetFilename()
559 {
560         ShowDeprecationWarning("getFilename()", "the fileName property");
561         if (!m_soundObject)
562         {
563                 return PyString_FromString("");
564         }
565         STR_String objectname = m_soundObject->GetObjectName();
566         char* name = objectname.Ptr();
567         
568         if (!name) {
569                 PyErr_SetString(PyExc_RuntimeError, "Unable to get sound fileName");
570                 return NULL;
571         } else
572                 return PyString_FromString(name);
573 }
574
575 PyObject* KX_SoundActuator::PySetGain(PyObject* args)
576 {
577         ShowDeprecationWarning("setGain()", "the volume property");
578         float gain = 1.0;
579         if (!PyArg_ParseTuple(args, "f:setGain", &gain))
580                 return NULL;
581         
582         if (m_soundObject)
583                 m_soundObject->SetGain(gain);
584         
585         Py_RETURN_NONE;
586 }         
587
588
589
590 PyObject* KX_SoundActuator::PyGetGain()
591 {
592         ShowDeprecationWarning("getGain()", "the volume property");
593         float gain = (m_soundObject) ? m_soundObject->GetGain() : 1.0f;
594         PyObject* result = PyFloat_FromDouble(gain);
595         
596         return result;
597 }
598
599
600
601 PyObject* KX_SoundActuator::PySetPitch(PyObject* args)
602 {
603         ShowDeprecationWarning("setPitch()", "the pitch property");
604         float pitch = 1.0;
605         if (!PyArg_ParseTuple(args, "f:setPitch", &pitch))
606                 return NULL;
607         
608         if (m_soundObject)
609                 m_soundObject->SetPitch(pitch);
610         
611         Py_RETURN_NONE;
612 }         
613
614
615
616 PyObject* KX_SoundActuator::PyGetPitch()
617 {
618         ShowDeprecationWarning("getPitch()", "the pitch property");
619         float pitch = (m_soundObject) ? m_soundObject->GetPitch() : 1.0;
620         PyObject* result = PyFloat_FromDouble(pitch);
621         
622         return result;
623 }
624
625
626
627 PyObject* KX_SoundActuator::PySetRollOffFactor(PyObject* args)
628 {
629         ShowDeprecationWarning("setRollOffFactor()", "the rollOffFactor property");
630         float rollofffactor = 1.0;
631         if (!PyArg_ParseTuple(args, "f:setRollOffFactor", &rollofffactor))
632                 return NULL;
633         
634         if (m_soundObject)
635                 m_soundObject->SetRollOffFactor(rollofffactor);
636
637         Py_RETURN_NONE;
638 }         
639
640
641
642 PyObject* KX_SoundActuator::PyGetRollOffFactor()
643 {
644         ShowDeprecationWarning("getRollOffFactor()", "the rollOffFactor property");
645         float rollofffactor = (m_soundObject) ? m_soundObject->GetRollOffFactor() : 1.0;
646         PyObject* result = PyFloat_FromDouble(rollofffactor);
647         
648         return result;
649 }
650
651
652
653 PyObject* KX_SoundActuator::PySetLooping(PyObject* args)
654 {
655         ShowDeprecationWarning("setLooping()", "the looping property");
656         bool looping = 1;
657         if (!PyArg_ParseTuple(args, "i:setLooping", &looping))
658                 return NULL;
659         
660         if (m_soundObject)
661                 m_soundObject->SetLoopMode(looping);
662         
663         Py_RETURN_NONE;
664 }         
665
666
667
668 PyObject* KX_SoundActuator::PyGetLooping()
669 {
670         ShowDeprecationWarning("getLooping()", "the looping property");
671         int looping = (m_soundObject) ? m_soundObject->GetLoopMode() : (int)SND_LOOP_OFF;
672         PyObject* result = PyInt_FromLong(looping);
673         
674         return result;
675 }
676
677
678
679 PyObject* KX_SoundActuator::PySetPosition(PyObject* args)
680 {
681         MT_Point3 pos;
682         ShowDeprecationWarning("setPosition()", "the position property");
683         pos[0] = 0.0;
684         pos[1] = 0.0;
685         pos[2] = 0.0;
686
687         if (!PyArg_ParseTuple(args, "fff:setPosition", &pos[0], &pos[1], &pos[2]))
688                 return NULL;
689         
690         if (m_soundObject)
691                 m_soundObject->SetPosition(pos);
692         
693         Py_RETURN_NONE;
694 }         
695
696
697
698 PyObject* KX_SoundActuator::PySetVelocity(PyObject* args)
699 {
700         MT_Vector3 vel;
701         ShowDeprecationWarning("setVelocity()", "the velocity property");
702         vel[0] = 0.0;
703         vel[1] = 0.0;
704         vel[2] = 0.0;
705
706         if (!PyArg_ParseTuple(args, "fff:setVelocity", &vel[0], &vel[1], &vel[2]))
707                 return NULL;
708         
709         if (m_soundObject)
710                 m_soundObject->SetVelocity(vel);
711         
712         Py_RETURN_NONE;
713 }         
714
715
716
717 PyObject* KX_SoundActuator::PySetOrientation(PyObject* args)
718 {
719         MT_Matrix3x3 ori;
720         ShowDeprecationWarning("setOrientation()", "the orientation property");
721         ori[0][0] = 1.0;
722         ori[0][1] = 0.0;
723         ori[0][2] = 0.0;
724         ori[1][0] = 0.0;
725         ori[1][1] = 1.0;
726         ori[1][2] = 0.0;
727         ori[2][0] = 0.0;
728         ori[2][1] = 0.0;
729         ori[2][2] = 1.0;
730
731         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]))
732                 return NULL;
733         
734         if (m_soundObject)
735                 m_soundObject->SetOrientation(ori);
736         
737         Py_RETURN_NONE;
738 }
739
740 PyObject* KX_SoundActuator::PySetType(PyObject* args)
741 {
742         int typeArg;
743         ShowDeprecationWarning("setType()", "the mode property");
744
745         if (!PyArg_ParseTuple(args, "i:setType", &typeArg)) {
746                 return NULL;
747         }
748
749         if ( (typeArg > KX_SOUNDACT_NODEF)
750           && (typeArg < KX_SOUNDACT_MAX) ) {
751                 m_type = (KX_SOUNDACT_TYPE) typeArg;
752         }
753
754         Py_RETURN_NONE;
755 }
756
757 PyObject* KX_SoundActuator::PyGetType()
758 {
759         ShowDeprecationWarning("getType()", "the mode property");
760         return PyInt_FromLong(m_type);
761 }
762 // <-----
763