sfxTrack.h

Engine/source/sfx/sfxTrack.h

More...

Classes:

class

A datablock that describes sound data for playback.

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 _SFXTRACK_H_
25#define _SFXTRACK_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
34
35class SFXDescription;
36
37
38/// A datablock that describes sound data for playback.
39class SFXTrack : public SimDataBlock
40{
41   public:
42      
43      typedef SimDataBlock Parent;
44      
45      enum
46      {
47         /// Maximum numbers of parameters that can be pre-assigned to tracks.
48         MaxNumParameters = 8
49      };
50      
51   protected:
52   
53      /// The description which controls playback settings.
54      SFXDescription *mDescription;
55
56      /// Name of the parameters to which sources playing this track should
57      /// connect.
58      StringTableEntry mParameters[ MaxNumParameters ];
59   
60      /// Overload this to disable direct instantiation of this class via script 'new'.
61      virtual bool processArguments( S32 argc, ConsoleValueRef *argv );
62
63   public:
64         
65      ///
66      SFXTrack();
67      
68      ///
69      SFXTrack( SFXDescription* description );
70      
71      /// Returns the description object for this sound profile.
72      SFXDescription* getDescription() const { return mDescription; }
73
74      ///
75      StringTableEntry getParameter( U32 index ) const
76      {
77         AssertFatal( index < MaxNumParameters, "SFXTrack::getParameter() - index out of range" );
78         return mParameters[ index ];
79      }
80      
81      ///
82      void setParameter( U32 index, const char* name );
83      
84      // SimDataBlock.
85      virtual void packData( BitStream* stream );
86      virtual void unpackData( BitStream* stream );
87      virtual bool preload( bool server, String& errorStr );
88      virtual bool onAdd();
89      virtual void inspectPostApply();
90      
91      static void initPersistFields();
92      
93      DECLARE_CONOBJECT( SFXTrack );
94      DECLARE_CATEGORY( "SFX" );
95      DECLARE_DESCRIPTION( "Abstract base class for any kind of data that can be turned into SFXSources." );
96};
97
98#endif // !_SFXTRACK_H_
99