sfxAmbience.h

Engine/source/sfx/sfxAmbience.h

More...

Classes:

class

Datablock for describing an ambient audio space.

Detailed Description

  1
  2//-----------------------------------------------------------------------------
  3// Copyright (c) 2012 GarageGames, LLC
  4//
  5// Permission is hereby granted, free of charge, to any person obtaining a copy
  6// of this software and associated documentation files (the "Software"), to
  7// deal in the Software without restriction, including without limitation the
  8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
  9// sell copies of the Software, and to permit persons to whom the Software is
 10// furnished to do so, subject to the following conditions:
 11//
 12// The above copyright notice and this permission notice shall be included in
 13// all copies or substantial portions of the Software.
 14//
 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 21// IN THE SOFTWARE.
 22//-----------------------------------------------------------------------------
 23
 24#ifndef _SFXAMBIENCE_H_
 25#define _SFXAMBIENCE_H_
 26
 27#ifndef _SIMDATABLOCK_H_
 28   #include "console/simDatablock.h"
 29#endif
 30#ifndef _CONSOLETYPES_H_
 31   #include "console/consoleTypes.h"
 32#endif
 33#ifndef _TSIGNAL_H_
 34   #include "core/util/tSignal.h"
 35#endif
 36
 37
 38class SFXEnvironment;
 39class SFXTrack;
 40class SFXState;
 41
 42
 43/// Datablock for describing an ambient audio space.
 44///
 45class SFXAmbience : public SimDataBlock
 46{
 47   public:
 48   
 49      typedef SimDataBlock Parent;
 50      typedef Signal< void( SFXAmbience* ) > ChangeSignal;
 51      
 52      enum
 53      {
 54         /// Maximum number of states that can be tied to an ambient space.
 55         MaxStates = 4
 56      };
 57         
 58   protected:
 59   
 60      /// Doppler shift factor for this space.
 61      F32 mDopplerFactor;
 62      
 63      /// Rolloff factor for this space.  Only applies to logarithmic distance model.
 64      F32 mRolloffFactor;
 65   
 66      /// Sound track to play when inside the ambient space.
 67      SFXTrack* mSoundTrack;
 68
 69      /// Reverb environment to apply when inside the ambient space.
 70      SFXEnvironment* mEnvironment;
 71      
 72      /// SFXStates to activate when in this ambient space.
 73      SFXState* mState[ MaxStates ];
 74      
 75      ///
 76      static ChangeSignal smChangeSignal;
 77
 78   public:
 79   
 80      SFXAmbience();
 81            
 82      /// Ensure all properties of this ambience adhere to their value contraints.
 83      void validate();
 84      
 85      /// Return the rolloff factor to apply to distance-based volume attenuation in this space (logarithmic distance model only).
 86      F32 getRolloffFactor() const { return mRolloffFactor; }
 87      
 88      /// Return the doppler shift factor to apply in this space.
 89      F32 getDopplerFactor() const { return mDopplerFactor; }
 90            
 91      /// Return the reverb environment of the ambient space.
 92      SFXEnvironment* getEnvironment() const { return mEnvironment; }
 93      
 94      /// Return the ambient soundtrack of this ambient space.
 95      SFXTrack* getSoundTrack() const { return mSoundTrack; }
 96      
 97      /// Return the given state bound to this ambient space.
 98      SFXState* getState( U32 i ) const
 99      {
100         AssertFatal( i < MaxStates, "SFXState::getState() - index out of range" );
101         return mState[ i ];
102      }
103      
104      ///
105      static ChangeSignal& getChangeSignal() { return smChangeSignal; }
106                  
107      // SimDataBlock.
108      virtual bool onAdd();
109      virtual void packData( BitStream* stream );
110      virtual void unpackData( BitStream* stream );
111      virtual bool preload( bool server, String& errorStr );
112      virtual void inspectPostApply();
113      
114      static void initPersistFields();
115   
116      DECLARE_CONOBJECT( SFXAmbience );
117      DECLARE_CATEGORY( "SFX" );
118      DECLARE_DESCRIPTION( "An ambient sound environment." );
119};
120
121#endif // !_SFXAMBIENCE_H_
122