music_sound.cpp

Go to the documentation of this file.
00001 
00005 /* Copyright, 2000-2004 Nevrax Ltd.
00006  *
00007  * This file is part of NEVRAX NEL.
00008  * NEVRAX NEL is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2, or (at your option)
00011  * any later version.
00012 
00013  * NEVRAX NEL is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * General Public License for more details.
00017 
00018  * You should have received a copy of the GNU General Public License
00019  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00021  * MA 02111-1307, USA.
00022  */
00023 
00024 #include "stdsound.h"
00025 
00026 #include "music_sound.h"
00027 #include "nel/misc/path.h"
00028 #include "nel/georges/u_form_elm.h"
00029 
00030 
00031 using namespace std;
00032 using namespace NLMISC;
00033 
00034 namespace NLSOUND {
00035 
00036 
00037 // ***************************************************************************
00038 CMusicSound::CMusicSound()
00039 {
00040     // init with NULL in case of unexcepted access
00041     _FileName= NULL;
00042     _FadeInLength= 2000;
00043     _FadeOutLength= 2000;
00044     _MinimumPlayTime= 10000;
00045     _TimeBeforeCanReplay= 0;
00046     LastStopTime= INT_MIN;
00047 }
00048 
00049 // ***************************************************************************
00050 CMusicSound::~CMusicSound()
00051 {
00052 }
00053 
00054 
00055 // ***************************************************************************
00056 void        CMusicSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root)
00057 {
00058     NLGEORGES::UFormElm *psoundType;
00059     std::string dfnName;
00060 
00061     // some basic checking.
00062     root.getNodeByName(&psoundType, ".SoundType");
00063     nlassert(psoundType != NULL);
00064     psoundType->getDfnName(dfnName);
00065     nlassert(dfnName == "music_sound.dfn");
00066 
00067     // Call the base class
00068     CSound::importForm(filename, root);
00069 
00070     // fileName
00071     std::string musicFileName;
00072     root.getValueByName(musicFileName, ".SoundType.FileName");
00073     musicFileName = CFile::getFilename(musicFileName);
00074     _FileName = CStringMapper::map(musicFileName);
00075 
00076     // Other params
00077     root.getValueByName(_FadeInLength, ".SoundType.FadeInLength");
00078     root.getValueByName(_FadeOutLength, ".SoundType.FadeOutLength");
00079     root.getValueByName(_MinimumPlayTime, ".SoundType.MinimumPlayTime");
00080     root.getValueByName(_TimeBeforeCanReplay, ".SoundType.TimeBeforeCanReplay");
00081 
00082 }
00083 
00084 // ***************************************************************************
00085 uint32      CMusicSound::getDuration()
00086 {
00087     // Cannot know the length of this music sound.
00088     // Since its not really a sound (played in an other "channel"), suppose 0
00089     return 0;
00090 }
00091 
00092 // ***************************************************************************
00093 void        CMusicSound::getSubSoundList(std::vector<std::pair<std::string, CSound*> > &subsounds) const
00094 {
00095     subsounds.clear();
00096 }
00097 
00098 // ***************************************************************************
00099 void        CMusicSound::serial(NLMISC::IStream &s)
00100 {
00101     s.serialVersion(0);
00102     CSound::serial(s);
00103 
00104     CStringMapper::serialString(s, _FileName);
00105     s.serial(_FadeInLength, _FadeOutLength);
00106     s.serial(_MinimumPlayTime, _TimeBeforeCanReplay);
00107 }
00108 
00109 // ***************************************************************************
00110 float       CMusicSound::getMaxDistance() const
00111 {
00112     // used in background_sound_manager, since 2D sound, return 0 because
00113     // the sound must be cut once out of the patat
00114     return 0.f;
00115 }
00116 
00117 // ***************************************************************************
00118 bool        CMusicSound::isDetailed() const
00119 {
00120     return false;
00121 }
00122 
00123 
00124 
00125 } // NLSOUND

Generated on Thu Jan 7 08:26:38 2010 for NeL by  doxygen 1.6.1