From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/u__ps__sound__impl_8h-source.html | 279 +++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 docs/doxygen/nel/u__ps__sound__impl_8h-source.html (limited to 'docs/doxygen/nel/u__ps__sound__impl_8h-source.html') diff --git a/docs/doxygen/nel/u__ps__sound__impl_8h-source.html b/docs/doxygen/nel/u__ps__sound__impl_8h-source.html new file mode 100644 index 00000000..6762c041 --- /dev/null +++ b/docs/doxygen/nel/u__ps__sound__impl_8h-source.html @@ -0,0 +1,279 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

u_ps_sound_impl.h

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000, 2001 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #ifndef NL_PS_SOUND_IMPL_H
+00027 #define NL_PS_SOUND_IMPL_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include <string>
+00031 #include "nel/misc/debug.h"
+00032 #include "nel/misc/rgba.h"
+00033 #include "nel/sound/u_audio_mixer.h"
+00034 #include "nel/3d/u_particle_system_sound.h"
+00035 
+00036 
+00037 // WARNING : this file is not intended to be directly included by the client. 
+00038 // It is just used to avoid a dependencie between NL3D and NLSOUND
+00039 
+00040 #define NL3D_MEM_PS_SOUND                                                       NL_ALLOC_CONTEXT( 3dPSSnd )
+00041 
+00042 namespace NL3D 
+00043 {
+00044 
+00045 
+00046 inline void SpawnedSourceEndedCallback(NLSOUND::USource *source, void *userParam);
+00047 
+00048 
+00049 class CPSSoundServImpl;
+00050 
+00051 
+00053 class CPSSoundInstanceImpl : public UPSSoundInstance
+00054 {
+00055 public:
+00057 
+00059         CPSSoundInstanceImpl() 
+00060                 : _Source(NULL), _SoundServImpl(NULL), _Spawned(false)
+00061         {
+00062                 NL3D_MEM_PS_SOUND
+00063         }
+00064 
+00066         void init(NLSOUND::USource *source, CPSSoundServImpl *soundServImp, bool spawned)
+00067         {
+00068                 NL3D_MEM_PS_SOUND
+00069                 nlassert(source);
+00070                 _Source = source;               
+00071                 _Spawned    = spawned;
+00072                 _SoundServImpl = soundServImp;
+00073         }
+00074 
+00076         virtual void setSoundParams(float gain
+00077                                                    , const NLMISC::CVector &pos
+00078                                                    , const NLMISC::CVector &velocity
+00079                                                    , float pitch
+00080                                                   )
+00081         {
+00082                 NL3D_MEM_PS_SOUND
+00083                 if (!_Source) return;           
+00084                 if (gain < 0) gain = 0;
+00085                 if (gain > 1) gain = 1;
+00086                 if (pitch > 1) pitch = 1;
+00087                 if (pitch < 0.0001f) pitch = 0.0001f;
+00088                 _Source->setPos(pos);
+00089                 _Source->setVelocity(velocity);
+00090                 _Source->setRelativeGain(gain);
+00091                 _Source->setPitch(pitch);
+00092         }
+00093 
+00095         virtual void play(void)
+00096         {
+00097                 NL3D_MEM_PS_SOUND
+00098                 if (!_Source) return;
+00099                 _Source->play();
+00100         }
+00101 
+00102 
+00103         virtual bool isPlaying(void) const
+00104         {
+00105                 NL3D_MEM_PS_SOUND
+00106                 if (!_Source) return false;
+00107                 return _Source->isPlaying();
+00108         }
+00109 
+00111         virtual void stop(void)
+00112         {
+00113                 NL3D_MEM_PS_SOUND
+00114                 if (!_Source) return;
+00115                 _Source->stop();
+00116         }
+00117 
+00119         virtual void release(void);     
+00120 
+00121 protected:
+00122         friend inline void SpawnedSourceEndedCallback(NLSOUND::USource *source, void *userParam);
+00123         NLSOUND::USource *_Source;
+00124         bool                     _Spawned;
+00125         CPSSoundServImpl   *_SoundServImpl;
+00126 };
+00127 
+00128 
+00129 
+00130 
+00131 
+00132 
+00133 
+00140 class CPSSoundServImpl : public UPSSoundServer
+00141 {
+00142 public: 
+00144         CPSSoundServImpl() : _AudioMixer(NULL)
+00145         {
+00146         }
+00147 
+00148         
+00149 
+00151         void init(NLSOUND::UAudioMixer *audioMixer)
+00152         {               
+00153                 _AudioMixer = audioMixer;
+00154         }
+00155 
+00156 
+00158         NLSOUND::UAudioMixer *getAudioMixer(void) { return _AudioMixer;}
+00159         const NLSOUND::UAudioMixer *getAudioMixer(void) const { return _AudioMixer;}
+00160 
+00161 
+00163         UPSSoundInstance *createSound(const std::string &soundName, bool spawned = true)
+00164         {               
+00165                 if (!_AudioMixer) return NULL;
+00166                 CPSSoundInstanceImpl *sound = new CPSSoundInstanceImpl;
+00167                 NLSOUND::USource *source = _AudioMixer->createSource(soundName, spawned, SpawnedSourceEndedCallback, sound );
+00168                 if (source)
+00169                 {                       
+00170                         if (spawned)
+00171                         {
+00172                                 source->setLooping(false);
+00173                         }
+00174                         sound->init(source, this, spawned);
+00175                         return sound;
+00176                 }
+00177                 else
+00178                 {
+00179                         // should usually not happen
+00180                         delete sound;
+00181                         return NULL;
+00182                 }
+00183         }
+00184 
+00185 protected:
+00186 
+00187         NLSOUND::UAudioMixer  *_AudioMixer;
+00188 
+00189 };
+00190 
+00191 
+00193 inline void SpawnedSourceEndedCallback(NLSOUND::USource *source, void *userParam)
+00194 {
+00195         nlassert(((CPSSoundInstanceImpl *) userParam)->_Source == source);
+00196         ((CPSSoundInstanceImpl *) userParam)->_Source = NULL;
+00197 }
+00198 
+00199 
+00200 
+00201 void CPSSoundInstanceImpl::release(void)
+00202 {       
+00203         if (!_Spawned) // remove this source from the audio mixer if it hasn't been spawned
+00204         {
+00205                 if (_SoundServImpl->getAudioMixer())
+00206                 {                       
+00207 //                      _SoundServImpl->getAudioMixer()->removeSource(_Source);
+00208                         delete _Source;
+00209                 }
+00210         }
+00211         else
+00212         {
+00213                 if (_Source) // tells this spawned source not to notify us when it ends
+00214                 {
+00215                         _Source->unregisterSpawnCallBack();
+00216                 }
+00217         }
+00218         delete this;
+00219 }
+00220 
+00221 
+00222 
+00223 
+00224 } // NL3D
+00225 
+00226 
+00227 #endif // NL_PS_SOUND_IMPL_H
+00228 
+00229 /* End of ps_sound_impl.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1