|
Blender
V2.59
|
00001 /* 00002 * $Id: KX_SoundActuator.h 37750 2011-06-23 09:27:56Z campbellbarton $ 00003 * 00004 * ***** BEGIN GPL LICENSE BLOCK ***** 00005 * 00006 * This program is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU General Public License 00008 * as published by the Free Software Foundation; either version 2 00009 * of the License, or (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 * 00020 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV. 00021 * All rights reserved. 00022 * 00023 * The Original Code is: all of this file. 00024 * 00025 * Contributor(s): none yet. 00026 * 00027 * ***** END GPL LICENSE BLOCK ***** 00028 */ 00029 00034 #ifndef __KX_SOUNDACTUATOR 00035 #define __KX_SOUNDACTUATOR 00036 00037 #include "SCA_IActuator.h" 00038 00039 #ifdef WITH_AUDASPACE 00040 # include "AUD_C-API.h" 00041 #endif 00042 00043 #include "BKE_sound.h" 00044 00045 typedef struct KX_3DSoundSettings 00046 { 00047 float min_gain; 00048 float max_gain; 00049 float reference_distance; 00050 float max_distance; 00051 float rolloff_factor; 00052 float cone_inner_angle; 00053 float cone_outer_angle; 00054 float cone_outer_gain; 00055 } KX_3DSoundSettings; 00056 00057 class KX_SoundActuator : public SCA_IActuator 00058 { 00059 Py_Header; 00060 bool m_isplaying; 00061 AUD_Sound* m_sound; 00062 float m_volume; 00063 float m_pitch; 00064 bool m_is3d; 00065 KX_3DSoundSettings m_3d; 00066 AUD_Channel* m_handle; 00067 00068 void play(); 00069 00070 public: 00071 00072 enum KX_SOUNDACT_TYPE 00073 { 00074 KX_SOUNDACT_NODEF = 0, 00075 KX_SOUNDACT_PLAYSTOP, 00076 KX_SOUNDACT_PLAYEND, 00077 KX_SOUNDACT_LOOPSTOP, 00078 KX_SOUNDACT_LOOPEND, 00079 KX_SOUNDACT_LOOPBIDIRECTIONAL, 00080 KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, 00081 KX_SOUNDACT_MAX 00082 }; 00083 00084 KX_SOUNDACT_TYPE m_type; 00085 00086 KX_SoundActuator(SCA_IObject* gameobj, 00087 AUD_Sound* sound, 00088 float volume, 00089 float pitch, 00090 bool is3d, 00091 KX_3DSoundSettings settings, 00092 KX_SOUNDACT_TYPE type); 00093 00094 ~KX_SoundActuator(); 00095 00096 virtual bool Update(double curtime, bool frame); 00097 00098 CValue* GetReplica(); 00099 void ProcessReplica(); 00100 00101 #ifdef WITH_PYTHON 00102 00103 /* -------------------------------------------------------------------- */ 00104 /* Python interface --------------------------------------------------- */ 00105 /* -------------------------------------------------------------------- */ 00106 00107 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound); 00108 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound); 00109 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound); 00110 00111 static int pyattr_set_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00112 static int pyattr_set_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00113 static int pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00114 static int pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00115 static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00116 00117 static PyObject* pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00118 static PyObject* pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00119 static PyObject* pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00120 static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00121 static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00122 00123 #endif // WITH_PYTHON 00124 00125 }; 00126 00127 #endif //__KX_SOUNDACTUATOR 00128