
1917.4. Adding Audio to the Game Engine
// Read and register the sound bank file with XACT
result = E_FAIL; // Default to failure code, replaced on success
hFile = CreateFile( SOUND_BANK, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, 0, NULL );
if( hFile != INVALID_HANDLE_VALUE )
{
fileSize = GetFileSize( hFile, NULL );
if( fileSize != -1 )
{
soundBankData = new BYTE[fileSize]; // Reserve memory for
// sound bank
if( soundBankData )
{
if(0 != ReadFile( hFile, soundBankData, fileSize,
&bytesRead, NULL))
result = xactEngine->CreateSoundBank( soundBankData,
fileSize,
0, 0, &soundBank
);
}
}
CloseHandle( hFile );
}
if( FAILED( ...