# 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  

ambiant_source.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 #error "Deprecated"
00026 
00027 #ifndef NL_AMBIANT_SOURCE_H
00028 #define NL_AMBIANT_SOURCE_H
00029 
00030 #include "nel/misc/types_nl.h"
00031 #include "nel/misc/time_nl.h"
00032 #include "simple_source.h"
00033 #include "env_sound_user.h"
00034 #include "playable.h"
00035 
00036 
00037 namespace NLSOUND {
00038 
00039 
00050 class CAmbiantSource : public IPlayable
00051 {
00052 public:
00053 
00055         CAmbiantSource();
00057         virtual ~CAmbiantSource();
00059         static void                             init() 
00060         {               
00061                 //NLMISC_REGISTER_CLASS(CAmbiantSource);                        
00062         }
00063 
00064         
00068         virtual void                    initPos( const NLMISC::CVector *posvector );
00070         virtual void                    update();
00072         virtual void                    enable( bool toplay, float gain );
00073 
00074 
00076         //virtual void                  serial( NLMISC::IStream& s );
00077         //NLMISC_DECLARE_CLASS(CAmbiantSource);
00079         CSimpleSource                           *getChannels() { return _StereoChannels; }
00081         void                                    setProperties( std::vector<TSoundId>& ambiantsounds,
00082                                                                                    std::vector<TSoundId>& sparsesounds,
00083                                                                                    uint32 crossfadeTimeMs=4000, uint32 sustainTimeMs=16000,
00084                                                                                    uint32 sparseAvgPeriodMs=30000 );
00085 
00086 protected:
00087 
00089         NLMISC::TTime                   calcPosInCycle( bool& crossfade, uint32& leadchannel );
00091         TSoundId                                getRandomSound( const std::vector<CSound*>& bank ) const;
00093         void                                    calcRandomSparseSoundTime( TSoundId currentsparesound );
00094 
00095 private:
00096 
00097         // Must play or not
00098         bool                                    _Play;
00099 
00100         // Non-localized stereo sources
00101         CSimpleSource                           _StereoChannels [MAX_ENV_CHANNELS];
00102         float                                   _StereoGain;
00103 
00104         // Sound banks
00105         std::vector<CSound*>    _AmbiantSounds, _SparseSounds;
00106 
00107         // Crossfade control
00108         NLMISC::TTime                   _StartTime;
00109         bool                                    _Sustain;
00110         bool                                    _RandomSoundChosen;
00111         NLMISC::TTime                   _NextSparseSoundTime;
00112 
00113         // Constants
00114         uint32                                  _CrossfadeTime;
00115         uint32                                  _SustainTime;
00116         uint32                                  _SparseAvgPeriod;
00117 
00118 };
00119 
00120 
00121 } // NLSOUND
00122 
00123 
00124 #endif // NL_AMBIANT_SOURCE_H
00125 
00126 /* End of ambiant_source.h */