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/source__common_8cpp-source.html | 279 +++++++++++++++++++++++ 1 file changed, 279 insertions(+) create mode 100644 docs/doxygen/nel/source__common_8cpp-source.html (limited to 'docs/doxygen/nel/source__common_8cpp-source.html') diff --git a/docs/doxygen/nel/source__common_8cpp-source.html b/docs/doxygen/nel/source__common_8cpp-source.html new file mode 100644 index 00000000..67d09d80 --- /dev/null +++ b/docs/doxygen/nel/source__common_8cpp-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  
+

source_common.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 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 #include "stdsound.h"
+00027 
+00028 #include "source_common.h"
+00029 
+00030 
+00031 using namespace NLMISC;
+00032 
+00033 namespace NLSOUND 
+00034 {
+00035 
+00036 CSourceCommon::CSourceCommon(TSoundId id, bool spawn, TSpawnEndCallback cb, void *cbUserParam)
+00037 :       _Priority(MidPri),
+00038         _Playing(false),
+00039         _Looping(false),
+00040         _Position(CVector::Null),
+00041         _Velocity(CVector::Null),
+00042         _Direction(CVector::Null),
+00043         _Gain(1.0f),
+00044         _InitialGain(1.0f),
+00045         _Pitch(1.0f),
+00046         _RelativeMode(false),
+00047         _3DPosition(NULL),
+00048         _PlayStart(0),
+00049         _Spawn(spawn),
+00050         _SpawnEndCb(cb),
+00051         _CbUserParam(cbUserParam)
+00052 {
+00053         CAudioMixerUser::instance()->addSource(this);
+00054 }
+00055 
+00056 CSourceCommon::~CSourceCommon()
+00057 {
+00058         CAudioMixerUser::instance()->removeSource(this);
+00059 }
+00060 
+00061 
+00062 /*
+00063  * Change the priority of the source
+00064  */
+00065 void CSourceCommon::setPriority( TSoundPriority pr)
+00066 {
+00067         _Priority = pr;
+00068 
+00069         // The AudioMixer redispatches as necessary in the update() function [PH]
+00070         // Redispatch the tracks if needed
+00071         //if ( redispatch )
+00072         //{
+00073         //      CAudioMixerUser::instance()->balanceSources();
+00074         //}
+00075 }
+00076 
+00077 /*
+00078  * Set looping on/off for future playbacks (default: off)
+00079  */
+00080 void                                    CSourceCommon::setLooping( bool l )
+00081 {
+00082         _Looping = l;
+00083 }
+00084 
+00085 /*
+00086  * Return the looping state
+00087  */
+00088 bool                                    CSourceCommon::getLooping() const
+00089 {
+00090         return _Looping;
+00091 }
+00092 
+00093 /*
+00094  * Play
+00095  */
+00096 void                                    CSourceCommon::play()
+00097 {
+00098         _Playing = true;
+00099         _PlayStart = CTime::getLocalTime();
+00100 }
+00101 
+00102 /*
+00103  * Stop playing
+00104  */
+00105 void                                    CSourceCommon::stop()
+00106 {
+00107         _Playing = false;
+00108 }
+00109 
+00110 /* Set the position vector (default: (0,0,0)).
+00111  * 3D mode -> 3D position
+00112  * st mode -> x is the pan value (from left (-1) to right (1)), set y and z to 0
+00113  */
+00114 void                                    CSourceCommon::setPos( const NLMISC::CVector& pos )
+00115 {
+00116         _Position = pos;
+00117 }
+00118 
+00119 /* Get the position vector.
+00120  * If the source is stereo, return the position vector which reference was passed to set3DPositionVector()
+00121  */
+00122 const NLMISC::CVector &CSourceCommon::getPos() const
+00123 {
+00124         if ( _3DPosition == NULL )
+00125         {
+00126                 return _Position;
+00127         }
+00128         else
+00129         {
+00130                 return *_3DPosition;
+00131         }
+00132         
+00133 }
+00134 
+00135 /* Shift the frequency. 1.0f equals identity, each reduction of 50% equals a pitch shift
+00136  * of one octave. 0 is not a legal value.
+00137  */
+00138 void                                    CSourceCommon::setPitch( float pitch )
+00139 {
+00140         nlassert( (pitch > 0) && (pitch <= 1.0f ) );
+00141         _Pitch = pitch;
+00142 }
+00143 
+00144 
+00145 /*
+00146  * Set the velocity vector (3D mode only, ignored in stereo mode) (default: (0,0,0))
+00147  */
+00148 void                                    CSourceCommon::setVelocity( const NLMISC::CVector& vel )
+00149 {
+00150         _Velocity = vel;
+00151 }
+00152 
+00153 /*
+00154  * Set the direction vector (3D mode only, ignored in stereo mode) (default: (0,0,0) as non-directional)
+00155  */
+00156 void                                    CSourceCommon::setDirection( const NLMISC::CVector& dir )
+00157 {
+00158         _Direction = dir;
+00159 }
+00160 
+00161 /* Set the gain (volume value inside [0 , 1]). (default: 1)
+00162  * 0.0 -> silence
+00163  * 0.5 -> -6dB
+00164  * 1.0 -> no attenuation
+00165  * values > 1 (amplification) not supported by most drivers
+00166  */
+00167 void                                    CSourceCommon::setGain( float gain )
+00168 {
+00169         nlassert( (gain >= 0.0f) && (gain <= 1.0f ) );
+00170         _InitialGain = _Gain = gain;
+00171 }
+00172 
+00173 /* Set the gain amount (value inside [0, 1]) to map between 0 and the nominal gain
+00174  * (which is getSource()->getGain()). Does nothing if getSource() is null.
+00175  */
+00176 void                                    CSourceCommon::setRelativeGain( float gain )
+00177 {
+00178         nlassert( (gain >= 0.0f) && (gain <= 1.0f ) );
+00179 
+00180         _Gain = _InitialGain * gain;
+00181 }
+00182 
+00183 /*
+00184  * Return the relative gain (see setRelativeGain()), or the absolute gain if getSource() is null.
+00185  */
+00186 float                                   CSourceCommon::getRelativeGain() const
+00187 {
+00188         if (_InitialGain == 0.0f)
+00189                 return 0.0f;
+00190         else
+00191                 return _Gain / _InitialGain;
+00192 }
+00193 
+00194 /*
+00195  * Set the source relative mode. If true, positions are interpreted relative to the listener position (default: false)
+00196  */
+00197 void                                    CSourceCommon::setSourceRelativeMode( bool mode )
+00198 {
+00199         _RelativeMode = mode;
+00200 }
+00201 
+00202 
+00203 uint32                                  CSourceCommon::getTime()
+00204 {
+00205         // default implementation
+00206         return uint32(CTime::getLocalTime() - _PlayStart);
+00207 }
+00208 
+00209 
+00210 } // NLSOUND
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1