Home | nevrax.com |
|
background_source.hGo 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 #ifndef NL_BACKGROUND_SOURCE_H 00027 #define NL_BACKGROUND_SOURCE_H 00028 00029 #include "nel/misc/types_nl.h" 00030 //#include "nel/sound/u_source.h" 00031 #include "source_common.h" 00032 #include "background_sound.h" 00033 00034 00035 namespace NLSOUND { 00036 00037 class CBackgroundSound; 00038 00044 class CBackgroundSource : public CSourceCommon, public CAudioMixerUser::IMixerEvent, public CAudioMixerUser::IMixerUpdate 00045 { 00046 public: 00048 CBackgroundSource (CBackgroundSound *backgroundSource=NULL, bool spawn=false, TSpawnEndCallback cb=0, void *cbUserParam = 0); 00050 ~CBackgroundSource (); 00051 00053 void setSound( TSoundId id, CSoundContext *context = 0); 00055 virtual TSoundId getSound(); 00056 00057 virtual void play(); 00059 virtual void stop(); 00060 00061 TSOURCE_TYPE getType() const {return SOURCE_BACKGROUND;} 00062 00063 void setGain( float gain ); 00064 void setRelativeGain( float gain ); 00065 00066 void setPos( const NLMISC::CVector& pos ); 00067 void setVelocity( const NLMISC::CVector& vel ); 00068 void setDirection( const NLMISC::CVector& dir ); 00069 00070 00071 private: 00072 00074 bool checkFilter(const UAudioMixer::TBackgroundFlags &filter); 00075 00077 void onUpdate(); 00079 void onEvent(); 00080 00082 enum TSubSourceStatus 00083 { 00085 SUB_STATUS_PLAY, 00087 SUB_STATUS_STOP, 00089 SUB_STATUS_FADEOUT, 00091 SUB_STATUS_FADEIN 00092 }; 00093 00095 struct TSubSource 00096 { 00098 USource *Source; 00100 TSubSourceStatus Status; 00102 NLMISC::TTime FadeStart; 00104 uint32 FilterFadeIn; 00106 uint32 FilterFadeOut; 00108 UAudioMixer::TBackgroundFlags Filter; 00109 }; 00110 00112 CBackgroundSound *_BackgroundSound; 00113 00115 std::vector<TSubSource> _Sources; 00116 00118 NLMISC::TTime _LastCheck; 00119 }; 00120 00121 00122 00123 } // NLSOOUND 00124 00125 #endif // NL_BACKGROUND_SOURCE_H |