svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r22205:22290
[blender.git] / source / gameengine / Ketsji / KX_SoundActuator.h
1 /**
2  * KX_SoundActuator.h
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 #ifndef __KX_SOUNDACTUATOR
33 #define __KX_SOUNDACTUATOR
34
35 #include "SCA_IActuator.h"
36
37 class KX_SoundActuator : public SCA_IActuator
38 {
39         Py_Header;
40         bool                                    m_lastEvent;
41         bool                                    m_isplaying;
42         /* just some handles to the audio-data... */
43         class SND_SoundObject*  m_soundObject;
44         class SND_Scene*                m_soundScene;
45         short                                   m_startFrame;
46         short                                   m_endFrame;
47         bool                                    m_pino;
48 public:
49
50         enum KX_SOUNDACT_TYPE
51         {
52                         KX_SOUNDACT_NODEF = 0,
53                         KX_SOUNDACT_PLAYSTOP,
54                         KX_SOUNDACT_PLAYEND,
55                         KX_SOUNDACT_LOOPSTOP,
56                         KX_SOUNDACT_LOOPEND,
57                         KX_SOUNDACT_LOOPBIDIRECTIONAL,
58                         KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP,
59                         KX_SOUNDACT_MAX
60         };
61
62         KX_SOUNDACT_TYPE                m_type;
63
64         KX_SoundActuator(SCA_IObject* gameobj,
65                                         class SND_SoundObject* sndobj,
66                                         class SND_Scene*        sndscene,
67                                         KX_SOUNDACT_TYPE type,
68                                         short start,
69                                         short end);
70
71         ~KX_SoundActuator();
72
73         void setSoundObject(class SND_SoundObject* soundobject);
74         virtual bool Update(double curtime, bool frame);
75
76         CValue* GetReplica();
77         void ProcessReplica();
78
79         /* -------------------------------------------------------------------- */
80         /* Python interface --------------------------------------------------- */
81         /* -------------------------------------------------------------------- */
82
83         KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound);
84         KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound);
85         KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound);
86
87         static int pyattr_set_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
88         static int pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
89         static int pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
90         static int pyattr_set_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
91         static int pyattr_set_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
92         static int pyattr_set_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
93         static int pyattr_set_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
94         static int pyattr_set_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
95         static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
96
97         static PyObject* pyattr_get_filename(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
98         static PyObject* pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
99         static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
100         static PyObject* pyattr_get_looping(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
101         static PyObject* pyattr_get_rollOffFactor(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
102         static PyObject* pyattr_get_position(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
103         static PyObject* pyattr_get_velocity(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
104         static PyObject* pyattr_get_orientation(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
105         static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef);
106
107         // Deprecated ----->
108         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetFilename);
109         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetFilename);
110         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetGain);
111         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetGain);
112         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetPitch);
113         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetPitch);
114         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetRollOffFactor);
115         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetRollOffFactor);
116         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetLooping);
117         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetLooping);
118         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetPosition);
119         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetVelocity);
120         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetOrientation);
121         KX_PYMETHOD_VARARGS(KX_SoundActuator,SetType);
122         KX_PYMETHOD_NOARGS(KX_SoundActuator,GetType);
123         // <-----
124
125 };
126
127 #endif //__KX_SOUNDACTUATOR
128