OpenBarnyard
 
Loading...
Searching...
No Matches
AWaveBank Class Referenceabstract

#include <AWaveBank.h>

Inheritance diagram for AWaveBank:
AWaveBankFMODFSB AWaveBankFMODFSBStream

Public Types

enum  LOADFLAGS_ : LOADFLAGS { LOADFLAGS_NONE = 0 , LOADFLAGS_LOCALISE = BITFLAG( 0 ) }
 
enum  LOADRESULT { LOADRESULT_ERR = -1 , LOADRESULT_OK = 0 }
 
enum  UNLOADRESULT { UNLOADRESULT_OK = 0 }
 
using LOADFLAGS = TUINT32
 

Public Member Functions

 AWaveBank (const Toshi::TPString8 &a_strBank, const Toshi::TPString8 &a_strPath, TBOOL a_bSetFrequency)
 
virtual TBOOL IsReady () const =0
 
virtual LOADRESULT Load (LOADFLAGS a_uiFlags, TINT a_iBufferSize)=0
 
virtual UNLOADRESULT Unload ()=0
 
virtual AWaveSampleHandle GetWaveSample (TINT a_iWaveIndex, TINT a_iUnused) const
 
virtual void ResetWave (TINT a_iWaveIndex)
 
virtual ~AWaveBank ()
 
AWaveGetWave (TINT a_iWaveIndex)
 
TINT GetWaveId (TINT a_iWaveIndex)
 
TINT GetWaveFrequency (TINT a_iWaveIndex)
 
AWaveSampleHandle CreateWaveSample (TINT a_iWaveIndex, TINT a_iUnused)
 
void SetWaveFlag1 (TINT a_iWaveIndex)
 
void SetWaveFlag2 (TINT a_iWaveIndex)
 
void ParseWavesData (const PBProperties *a_pBankProperties, TUINT a_uiForcedFlags)
 

Protected Attributes

TINT m_iNumWaves
 
TINT m_iNumLoads
 
Toshi::TPString8 m_strBank
 
Toshi::TPString8 m_strPath
 
Toshi::TPString8 m_strExtension
 
TBOOL m_bSetFrequency
 
AWavem_pWaves
 
AWaveBankFileHandle m_FileHandle
 

Detailed Description

Definition at line 10 of file AWaveBank.h.

Member Typedef Documentation

◆ LOADFLAGS

Definition at line 13 of file AWaveBank.h.

Member Enumeration Documentation

◆ LOADFLAGS_

Enumerator
LOADFLAGS_NONE 
LOADFLAGS_LOCALISE 

Definition at line 14 of file AWaveBank.h.

15 {
18 };
#define BITFLAG(x)
Definition Defines.h:10
@ LOADFLAGS_LOCALISE
Definition AWaveBank.h:17
@ LOADFLAGS_NONE
Definition AWaveBank.h:16

◆ LOADRESULT

Enumerator
LOADRESULT_ERR 
LOADRESULT_OK 

Definition at line 20 of file AWaveBank.h.

21 {
22 LOADRESULT_ERR = -1,
23 LOADRESULT_OK = 0,
24 };
@ LOADRESULT_OK
Definition AWaveBank.h:23
@ LOADRESULT_ERR
Definition AWaveBank.h:22

◆ UNLOADRESULT

Enumerator
UNLOADRESULT_OK 

Definition at line 26 of file AWaveBank.h.

27 {
29 };
@ UNLOADRESULT_OK
Definition AWaveBank.h:28

Constructor & Destructor Documentation

◆ AWaveBank()

AWaveBank::AWaveBank ( const Toshi::TPString8 & a_strBank,
const Toshi::TPString8 & a_strPath,
TBOOL a_bSetFrequency )

Definition at line 17 of file AWaveBank.cpp.

18{
19 m_iNumWaves = 0;
20 m_iNumLoads = 0;
21 m_strBank = a_strBank;
22 m_strPath = a_strPath;
24
26 m_bSetFrequency = a_bSetFrequency;
27
28 ASoundManager::ms_WaveBanks.Insert( a_strBank, this );
29}
#define TNULL
Definition Typedefs.h:23
Toshi::TPString8 m_strBank
Definition AWaveBank.h:56
AWave * m_pWaves
Definition AWaveBank.h:60
TBOOL m_bSetFrequency
Definition AWaveBank.h:59
AWaveBankFileHandle m_FileHandle
Definition AWaveBank.h:61
TINT m_iNumWaves
Definition AWaveBank.h:54
Toshi::TPString8 m_strPath
Definition AWaveBank.h:57
TINT m_iNumLoads
Definition AWaveBank.h:55

◆ ~AWaveBank()

AWaveBank::~AWaveBank ( )
virtual

Definition at line 41 of file AWaveBank.cpp.

42{
43 ASoundManager::ms_WaveBanks.Remove( m_strBank );
44 delete[] m_pWaves;
45}

Member Function Documentation

◆ CreateWaveSample()

AWaveSampleHandle AWaveBank::CreateWaveSample ( TINT a_iWaveIndex,
TINT a_iUnused )

Definition at line 65 of file AWaveBank.cpp.

66{
67 TASSERT( a_iWaveIndex < m_iNumWaves );
68
69 if ( m_pWaves[ a_iWaveIndex ].pSampleHandle == TNULL )
70 {
71 m_pWaves[ a_iWaveIndex ].pSampleHandle = GetWaveSample( a_iWaveIndex, a_iUnused );
72 }
73
74 return m_pWaves[ a_iWaveIndex ].pSampleHandle;
75}
#define TASSERT(X,...)
Definition Defines.h:138
virtual AWaveSampleHandle GetWaveSample(TINT a_iWaveIndex, TINT a_iUnused) const
Definition AWaveBank.cpp:31

◆ GetWave()

AWave * AWaveBank::GetWave ( TINT a_iWaveIndex)

Definition at line 47 of file AWaveBank.cpp.

48{
49 TASSERT( a_iWaveIndex < m_iNumWaves );
50 return &m_pWaves[ a_iWaveIndex ];
51}

◆ GetWaveFrequency()

TINT AWaveBank::GetWaveFrequency ( TINT a_iWaveIndex)

Definition at line 59 of file AWaveBank.cpp.

60{
61 TASSERT( a_iWaveIndex < m_iNumWaves );
62 return m_pWaves[ a_iWaveIndex ].iFrequency;
63}

◆ GetWaveId()

TINT AWaveBank::GetWaveId ( TINT a_iWaveIndex)

Definition at line 53 of file AWaveBank.cpp.

54{
55 TASSERT( a_iWaveIndex < m_iNumWaves );
56 return m_pWaves[ a_iWaveIndex ].iIndex;
57}

◆ GetWaveSample()

AWaveSampleHandle AWaveBank::GetWaveSample ( TINT a_iWaveIndex,
TINT a_iUnused ) const
virtual

Definition at line 31 of file AWaveBank.cpp.

32{
33 TASSERT( a_iWaveIndex < m_iNumWaves );
34 return m_pWaves[ a_iWaveIndex ].pSampleHandle;
35}

◆ IsReady()

virtual TBOOL AWaveBank::IsReady ( ) const
pure virtual

◆ Load()

virtual LOADRESULT AWaveBank::Load ( LOADFLAGS a_uiFlags,
TINT a_iBufferSize )
pure virtual

◆ ParseWavesData()

void AWaveBank::ParseWavesData ( const PBProperties * a_pBankProperties,
TUINT a_uiForcedFlags )

Definition at line 91 of file AWaveBank.cpp.

92{
93 TVALIDPTR( a_pBankProperties );
94
95 m_iNumWaves = 0;
96
97 T2DynamicVector<AWave> vecWaves( GetGlobalAllocator(), 128, 128 );
98
99 for ( TUINT i = 0; i < a_pBankProperties->GetPropertyCount(); i++ )
100 {
101 const PBProperties::PBProperty* pProperty = a_pBankProperties->GetPropertyByIndex( i );
102
103 // Skip any properties other than Wave
104 if ( pProperty->GetName().GetString()[ 0 ] != 'W' ) continue;
105
106 TINT iFrequency = 22050;
107 TFLOAT fLength = 0.0f;
108 TUINT uiFlags = a_uiForcedFlags;
109
110 const PBProperties* pWaveProperties = pProperty->GetValue()->GetProperties();
111
112 // Parse flags
113 const PBPropertyValue* pFlagsProperty = pWaveProperties->GetProperty( "flags" );
114 if ( pFlagsProperty && uiFlags == 0 ) uiFlags = pFlagsProperty->GetInteger();
115
116 // Parse frequency
117 const PBPropertyValue* pFreqProperty = pWaveProperties->GetProperty( "frequency" );
118 if ( pFreqProperty )
119 {
120 if ( m_bSetFrequency )
121 iFrequency = pFreqProperty->GetInteger();
122 else
123 iFrequency = ASoundManager::GetSingleton()->m_iGlobalFrequency;
124 }
125
126 // Parse length
127 pWaveProperties->GetOptionalPropertyValue( fLength, "length" );
128
129 vecWaves.EmplaceBack( uiFlags, iFrequency, fLength, TNULL, -1 );
130 m_iNumWaves += 1;
131 }
132
133 // Allocate the actual array that will store info about samples
135
136 // Copy data from the vector
137 for ( TINT i = 0; i < m_iNumWaves; i++ )
138 m_pWaves[ i ] = vecWaves[ i ];
139}
#define TVALIDPTR(PTR)
Definition Defines.h:139
TFORCEINLINE T2Allocator * GetGlobalAllocator()
Definition T2Allocator.h:49
unsigned int TUINT
Definition Typedefs.h:8
float TFLOAT
Definition Typedefs.h:4
int TINT
Definition Typedefs.h:7
const class PBProperties * GetProperties() const
TINT GetInteger() const
const TCHAR * GetString() const
TUINT32 GetPropertyCount() const
const PBPropertyValue * GetProperty(const TCHAR *a_szName) const
TBOOL GetOptionalPropertyValue(T &a_rOutValue, const TCHAR *a_szName) const
const PBProperty * GetPropertyByIndex(TSIZE a_iIndex) const
PBPropertyValue * GetValue()
PBPropertyName & GetName()
@ POOL_Sound
Definition AMemory.h:37
static Toshi::TMemory::MemBlock * GetMemBlock(POOL a_ePool)
Definition AMemory.cpp:38

◆ ResetWave()

void AWaveBank::ResetWave ( TINT a_iWaveIndex)
virtual

Definition at line 37 of file AWaveBank.cpp.

38{
39}

◆ SetWaveFlag1()

void AWaveBank::SetWaveFlag1 ( TINT a_iWaveIndex)

Definition at line 77 of file AWaveBank.cpp.

78{
79 TASSERT( a_iWaveIndex < m_iNumWaves );
80 m_pWaves[ a_iWaveIndex ].iFlags &= ~2;
81 m_pWaves[ a_iWaveIndex ].iFlags |= 1;
82}

◆ SetWaveFlag2()

void AWaveBank::SetWaveFlag2 ( TINT a_iWaveIndex)

Definition at line 84 of file AWaveBank.cpp.

85{
86 TASSERT( a_iWaveIndex < m_iNumWaves );
87 m_pWaves[ a_iWaveIndex ].iFlags &= ~1;
88 m_pWaves[ a_iWaveIndex ].iFlags |= 2;
89}

◆ Unload()

virtual UNLOADRESULT AWaveBank::Unload ( )
pure virtual

Member Data Documentation

◆ m_bSetFrequency

TBOOL AWaveBank::m_bSetFrequency
protected

Definition at line 59 of file AWaveBank.h.

◆ m_FileHandle

AWaveBankFileHandle AWaveBank::m_FileHandle
protected

Definition at line 61 of file AWaveBank.h.

◆ m_iNumLoads

TINT AWaveBank::m_iNumLoads
protected

Definition at line 55 of file AWaveBank.h.

◆ m_iNumWaves

TINT AWaveBank::m_iNumWaves
protected

Definition at line 54 of file AWaveBank.h.

◆ m_pWaves

AWave* AWaveBank::m_pWaves
protected

Definition at line 60 of file AWaveBank.h.

◆ m_strBank

Toshi::TPString8 AWaveBank::m_strBank
protected

Definition at line 56 of file AWaveBank.h.

◆ m_strExtension

Toshi::TPString8 AWaveBank::m_strExtension
protected

Definition at line 58 of file AWaveBank.h.

◆ m_strPath

Toshi::TPString8 AWaveBank::m_strPath
protected

Definition at line 57 of file AWaveBank.h.


The documentation for this class was generated from the following files: