OpenBarnyard
 
Loading...
Searching...
No Matches
AWaveBankFMODFSB Class Reference

#include <AWaveBankFMODFSB.h>

Inheritance diagram for AWaveBankFMODFSB:
AWaveBank

Public Member Functions

 AWaveBankFMODFSB (const Toshi::TPString8 &a_strBank, const Toshi::TPString8 &a_strPath)
 
virtual TBOOL IsReady () const OVERRIDE
 
virtual LOADRESULT Load (LOADFLAGS a_uiFlags, TINT a_iBufferSize) OVERRIDE
 
virtual UNLOADRESULT Unload () OVERRIDE
 
- Public Member Functions inherited from AWaveBank
 AWaveBank (const Toshi::TPString8 &a_strBank, const Toshi::TPString8 &a_strPath, TBOOL a_bSetFrequency)
 
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)
 

Additional Inherited Members

- Public Types inherited from AWaveBank
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
 
- Protected Attributes inherited from AWaveBank
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 4 of file AWaveBankFMODFSB.h.

Constructor & Destructor Documentation

◆ AWaveBankFMODFSB()

AWaveBankFMODFSB::AWaveBankFMODFSB ( const Toshi::TPString8 & a_strBank,
const Toshi::TPString8 & a_strPath )

Definition at line 19 of file AWaveBankFMODFSB.cpp.

20 : AWaveBank( a_strBank, a_strPath, TFALSE )
21{
22}
#define TFALSE
Definition Typedefs.h:24
AWaveBank(const Toshi::TPString8 &a_strBank, const Toshi::TPString8 &a_strPath, TBOOL a_bSetFrequency)
Definition AWaveBank.cpp:17

Member Function Documentation

◆ IsReady()

TBOOL AWaveBankFMODFSB::IsReady ( ) const
virtual

Implements AWaveBank.

Definition at line 24 of file AWaveBankFMODFSB.cpp.

25{
26 return FMUSIC_GetOpenState( (FMUSIC_MODULE*)m_FileHandle ) == 0;
27}
AWaveBankFileHandle m_FileHandle
Definition AWaveBank.h:61

◆ Load()

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

Implements AWaveBank.

Definition at line 29 of file AWaveBankFMODFSB.cpp.

30{
31 if ( m_iNumLoads > 0 || m_FileHandle != TNULL )
32 {
34 return LOADRESULT_OK;
35 }
36
37 TString8 strFileName;
39 strFileName += "FSB/";
40
41 if ( a_uiFlags & LOADFLAGS_LOCALISE )
42 {
43 ALocaleManager::Lang iLangId = ALocaleManager::Lang_UNKNOWN;
44 ALocaleManager* pLocale = ALocaleManager::Interface();
45
46 if ( pLocale )
47 iLangId = pLocale->GetLanguage();
48
49 if ( iLangId == ALocaleManager::Lang_UNKNOWN )
51
52 strFileName += pLocale->GetVOLocaleDir( iLangId );
53 }
54
55 strFileName += m_strPath.GetString8();
56 strFileName += ".";
57 strFileName += "fsb";
58
59 TFileManager* pFileManager = TFileManager::GetSingleton();
60
61 TNativeFileInfo oFileInfo;
62 TBOOL bGotFileInfo = pFileManager->GetFileInfo( strFileName, oFileInfo );
63
64 TASSERT( TTRUE == bGotFileInfo );
65
66 if ( bGotFileInfo )
67 {
68 // Load the FSB file
70
71 FMUSIC_MODULE* pModule = FMUSIC_LoadSongEx( oFileInfo.InternalPath, oFileInfo.Offset, oFileInfo.Length, FSOUND_NONBLOCKING, 0, 0 );
72 TVALIDPTR( pModule );
73
74 TINT iOpenState = FMUSIC_GetOpenState( pModule );
75 while ( iOpenState == -2 )
76 {
77#ifndef BARNYARD_COMMUNITY_PATCH
78 ThreadSleep( 5 );
79#endif // BARNYARD_COMMUNITY_PATCH
80 iOpenState = FMUSIC_GetOpenState( pModule );
81 }
82
84
85 // The file is loaded now, get some info about the samples
86
87 if ( pModule != TNULL )
88 {
89 m_iNumLoads += 1;
90 m_FileHandle = pModule;
91
92 TINT iNumSamples = FMUSIC_GetNumSamples( pModule );
93
94 for ( TINT i = 0; i < iNumSamples; i++ )
95 {
96 FSOUND_SAMPLE* pSample = FMUSIC_GetSample( pModule, i );
97
98 AWave* pWave = &m_pWaves[ i ];
99 pWave->iFlags |= ( 4 | 8 );
100 pWave->pSampleHandle = pSample;
101 pWave->iIndex = i;
102
103 TINT iDeffreq;
104 FSOUND_Sample_GetDefaults( pSample, &iDeffreq, TNULL, TNULL, TNULL );
105
106 pWave->iFrequency = TUINT( iDeffreq );
107 }
108
109 return LOADRESULT_OK;
110 }
111 }
112
113 return LOADRESULT_ERR;
114}
#define TASSERT(X,...)
Definition Defines.h:138
#define TVALIDPTR(PTR)
Definition Defines.h:139
unsigned int TUINT
Definition Typedefs.h:8
#define TNULL
Definition Typedefs.h:23
int TINT
Definition Typedefs.h:7
#define TTRUE
Definition Typedefs.h:25
bool TBOOL
Definition Typedefs.h:6
TBOOL g_bIsLoadingFSBFile
void ThreadSleep(TUINT dwMilliseconds)
TString8 InternalPath
Definition TFile.h:54
TUINT32 Length
Definition TFile.h:56
TUINT32 Offset
Definition TFile.h:55
TBOOL GetFileInfo(const TString8 &a_strPath, TNativeFileInfo &a_rNativeInfo)
static TFORCEINLINE TFileManager * GetSingleton()
Definition TSingleton.h:49
static ALocaleManager * Interface()
const TCHAR * GetVOLocaleDir(Lang a_eLang)
static constexpr const TCHAR * SOUNDS_BASE_DIRECTORY
TINT iFrequency
Definition AWave.h:16
AWaveSampleHandle pSampleHandle
Definition AWave.h:18
TINT iIndex
Definition AWave.h:19
TINT iFlags
Definition AWave.h:15
AWave * m_pWaves
Definition AWaveBank.h:60
Toshi::TPString8 m_strPath
Definition AWaveBank.h:57
@ LOADRESULT_OK
Definition AWaveBank.h:23
@ LOADRESULT_ERR
Definition AWaveBank.h:22
@ LOADFLAGS_LOCALISE
Definition AWaveBank.h:17
TINT m_iNumLoads
Definition AWaveBank.h:55

◆ Unload()

AWaveBank::UNLOADRESULT AWaveBankFMODFSB::Unload ( )
virtual

Implements AWaveBank.

Definition at line 116 of file AWaveBankFMODFSB.cpp.

117{
118 if ( m_iNumLoads != 0 && --m_iNumLoads < 1 && m_FileHandle )
119 {
120 m_iNumLoads = 0;
121
122 // Reset the waves
123 for ( TINT i = 0; i < m_iNumWaves; i++ )
124 {
125 AWave* pWave = &m_pWaves[ i ];
126 pWave->pSampleHandle = TNULL;
127 pWave->iIndex = -1;
128 pWave->iFlags &= ~( 4 | 8 );
129 }
130
131 FMUSIC_MODULE* pModule = (FMUSIC_MODULE*)m_FileHandle;
132
133 TINT iOpenState = FMUSIC_GetOpenState( pModule );
134 while ( iOpenState == -2 )
135 {
136#ifndef BARNYARD_COMMUNITY_PATCH
137 ThreadSleep( 5 );
138#endif // BARNYARD_COMMUNITY_PATCH
139 iOpenState = FMUSIC_GetOpenState( pModule );
140 }
141
142 FMUSIC_FreeSong( pModule );
144 }
145
146 return UNLOADRESULT_OK;
147}
@ UNLOADRESULT_OK
Definition AWaveBank.h:28
TINT m_iNumWaves
Definition AWaveBank.h:54

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