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

sound.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 "sound.h"
+00029 #include "nel/misc/path.h"
+00030 #include "sound_bank.h"
+00031 
+00032 #include "simple_sound.h"
+00033 #include "complex_sound.h"
+00034 #include "context_sound.h"
+00035 
+00036 using namespace std;
+00037 using namespace NLMISC;
+00038 
+00039 
+00040 namespace NLSOUND {
+00041 
+00042 CSound *CSound::createSound(const std::string &filename, NLGEORGES::UFormElm& formRoot)
+00043 {
+00044         CSound *ret = NULL;
+00045         string  soundType;
+00046 
+00047         NLGEORGES::UFormElm *psoundType;
+00048 
+00049         if (!formRoot.getNodeByName(&psoundType, ".SoundType"))
+00050         {
+00051                 nlwarning("No SoundType in : %s", filename.c_str());
+00052                 return 0;
+00053         }
+00054 
+00055         if (psoundType != NULL)
+00056         {
+00057                 std::string dfnName;
+00058                 psoundType->getDfnName(dfnName);
+00059 
+00060                 if (dfnName == "simple_sound.dfn")
+00061                 {
+00062                         ret = new CSimpleSound();
+00063                         ret->importForm(filename, formRoot);
+00064                 }
+00065                 else if (dfnName == "complex_sound.dfn")
+00066                 {
+00067                         ret = new CComplexSound();
+00068                         ret->importForm(filename, formRoot);
+00069                 }
+00070                 else if (dfnName == "background_sound.dfn")
+00071                 {
+00072                         ret = new CBackgroundSound();
+00073                         ret->importForm(filename, formRoot);
+00074                 }
+00075                 else if (dfnName == "context_sound.dfn")
+00076                 {
+00077                         ret = new CContextSound();
+00078                         ret->importForm(filename, formRoot);
+00079                 }
+00080                 else
+00081                 {
+00082                         nlassertex(false, ("SoundType unsuported : %s", dfnName.c_str()));
+00083                 }
+00084                         
+00085         }
+00086 
+00087         return ret;
+00088 }
+00089 
+00090 
+00091 
+00092 /*
+00093  * Constructor
+00094  */
+00095 CSound::CSound() : 
+00096         _Gain(1.0f), 
+00097         _Pitch(1.0f),
+00098         _MaxDist(1000000.0f),
+00099         _Priority(MidPri), 
+00100         _Looping(false),
+00101         _ConeInnerAngle(6.283185f), 
+00102         _ConeOuterAngle(6.283185f), 
+00103         _ConeOuterGain( 1.0f )
+00104 {
+00105 }
+00106 
+00107 CSound::~CSound()
+00108 {}
+00109 
+00110 
+00111 void    CSound::serial(NLMISC::IStream &s)
+00112 {
+00113         s.serial(_Gain);
+00114         s.serial(_Pitch);
+00115         s.serialEnum(_Priority);
+00116         s.serial(_ConeInnerAngle, _ConeOuterAngle, _ConeOuterGain);
+00117         s.serial(_Direction);
+00118         s.serial(_Looping);
+00119         s.serial(_MaxDist);
+00120         s.serial(_Name);
+00121 }
+00122 
+00123 
+00127 void                            CSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root)
+00128 {
+00129         // Name
+00130         _Name = CFile::getFilenameWithoutExtension(filename);   
+00131 
+00132         // InternalConeAngle
+00133         uint32 inner;
+00134         root.getValueByName(inner, ".InternalConeAngle");
+00135         if (inner > 360)
+00136         {
+00137                 inner = 360;
+00138         }
+00139         _ConeInnerAngle = (float) (Pi * inner / 180.0f);  // convert to radians
+00140 
+00141         // ExternalConeAngle
+00142         uint32 outer;
+00143         root.getValueByName(outer, ".ExternalConeAngle");
+00144         if (outer > 360)
+00145         {
+00146                 outer = 360;
+00147         }
+00148         _ConeOuterAngle= (float) (Pi * outer / 180.0f);  // convert to radians
+00149 
+00150         // Loop
+00151         root.getValueByName(_Looping, ".Loop");
+00152 
+00153         // Gain
+00154         sint32 gain;
+00155         root.getValueByName(gain, ".Gain");
+00156         if (gain > 0)
+00157         {
+00158                 gain = 0;
+00159         }
+00160         if (gain < -100)
+00161         {
+00162                 gain = -100;
+00163         }
+00164         _Gain = (float) pow(10.0, gain / 20.0); // convert dB to linear gain
+00165 
+00166         // External gain
+00167         root.getValueByName(gain, ".ExternalGain");
+00168         if (gain > 0)
+00169         {
+00170                 gain = 0;
+00171         }
+00172         if (gain < -100)
+00173         {
+00174                 gain = -100;
+00175         }
+00176         _ConeOuterGain = (float) pow(10.0, gain / 20.0); // convert dB to linear gain
+00177 
+00178         // Direction
+00179         float x, y, z;
+00180 
+00181         root.getValueByName(x, ".Direction.X");
+00182         root.getValueByName(y, ".Direction.Y");
+00183         root.getValueByName(z, ".Direction.Z");
+00184         _Direction = CVector(x, y, z);
+00185 
+00186 
+00187         // Pitch
+00188         sint32 trans;
+00189         root.getValueByName(trans, ".Transpose");
+00190         _Pitch =  (float) pow(Sqrt12_2, trans); // convert semi-tones to playback speed
+00191 
+00192         // Priority
+00193         uint32 prio = 0;
+00194         root.getValueByName(prio, ".Priority");
+00195         switch (prio)
+00196         {
+00197         case 0: _Priority = LowPri; break;
+00198         default:
+00199         case 1: _Priority = MidPri; break;
+00200         case 2: _Priority = HighPri; break;
+00201         case 3: _Priority = HighestPri; break;
+00202         }
+00203 }
+00204 
+00205 
+00206 
+00207 } // NLSOUND
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1