240 lines
6 KiB
C++
240 lines
6 KiB
C++
#include "Precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "RakiTests/Initializer/TestInitializer.h"
|
|
|
|
|
|
#include "RakiEngine/Data/Serialization/Serializer.h"
|
|
#include "RakiEngine/Data/Stream/FileStream.h"
|
|
#include "RakiEngine/Data/Stream/SeekableStreamPart.h"
|
|
#include "RakiEngine/Data/WaveFile/RiffChunkManager.h"
|
|
#include "RakiEngine/Data/WaveFile/BinWaveData/BinWaveData.h"
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
#include "RakiTests/_Win32/CoInitializeInitObject.h"
|
|
|
|
#endif // ( RAKI_PLATFORM_WIN32 )
|
|
|
|
|
|
#if defined ( RAKI_USING_XAUDIO2 )
|
|
|
|
#include "RakiEngine/Sounds/_XAudio2/BufferSoundNative.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
#include <cell/mstream.h>
|
|
#include <sysutil/sysutil_common.h>
|
|
#include "RakiEngine/Sounds/_PS3/BufferSoundNative_PS3.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
|
|
#include <revolution/vi.h>
|
|
#include <revolution/pad.h>
|
|
|
|
#include "RakiEngine/Sounds/_Wii/BufferSoundNative_Wii.h"
|
|
|
|
#include <revolution/os.h>
|
|
#include <revolution/ax.h>
|
|
#include <revolution/mem.h>
|
|
#include <revolution/ai.h>
|
|
#include <revolution/dvd.h>
|
|
#include <revolution/vi.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace raki
|
|
{
|
|
|
|
|
|
|
|
|
|
static bool TestSurround( const char * _path, const bool _useCenterSpeaker, const f32 _pan = 0.f, const f32 _span = 1.f )
|
|
{
|
|
RiffChunkManager::singleton().setShouldReadDataBlockForWaveData( true );
|
|
|
|
FileStream * fileStream = EngineInitializer::singleton().createReadFileStream();
|
|
|
|
if ( !fileStream )
|
|
return false;
|
|
|
|
bool opened = fileStream->open( _path );
|
|
|
|
if ( !opened )
|
|
{
|
|
RAKI_DELETE( fileStream );
|
|
|
|
return false;
|
|
}
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
BinWaveData binWaveData( MemoryBlock::standard );
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
BinWaveData binWaveData( MemoryBlock::xma2_aligned2048 );
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
BinWaveData binWaveData( MemoryBlock::ps3_aligned128 );
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
BinWaveData binWaveData( MemoryBlock::wii_mem2_aligned32 );
|
|
#endif
|
|
|
|
if ( !binWaveData.read( fileStream ) )
|
|
{
|
|
RAKI_DELETE( fileStream );
|
|
|
|
return false;
|
|
}
|
|
|
|
BufferSoundNative bufferSound;
|
|
|
|
const bool isMusic = false;
|
|
const bool isLooping = false;
|
|
SoundParams soundParams( isMusic, isLooping );
|
|
|
|
bufferSound.createVoice( &binWaveData, soundParams );
|
|
|
|
if ( _useCenterSpeaker )
|
|
{
|
|
bufferSound.setUseOnlyCenterSpeaker( true );
|
|
}
|
|
else
|
|
{
|
|
bufferSound.setPan( _pan );
|
|
bufferSound.setSpan( _span );
|
|
}
|
|
|
|
bufferSound.updateVolume( true );
|
|
|
|
bufferSound.start();
|
|
|
|
while( bufferSound.isPlaying() )
|
|
{
|
|
#ifdef RAKI_PLATFORM_WII
|
|
VIWaitForRetrace();
|
|
#else // RAKI_PLATFORM_WII
|
|
Thread::sleep( 16 );
|
|
#endif // RAKI_PLATFORM_WII
|
|
}
|
|
|
|
bufferSound.destroyVoice();
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WII )
|
|
|
|
// wait for audio callback on Wii
|
|
Thread::sleep(15);
|
|
#endif // defined ( RAKI_PLATFORM_WII )
|
|
|
|
|
|
RAKI_DELETE( fileStream );
|
|
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace raki
|
|
|
|
#if defined ( RAKI_USING_XAUDIO2 )
|
|
int _tmain(int /*argc*/, _TCHAR* /*argv[]*/)
|
|
#else // RAKI_USING_XAUDIO2
|
|
int main( int /*argc*/, char * /*argv[]*/ )
|
|
#endif // RAKI_USING_XAUDIO2
|
|
{
|
|
|
|
#if defined ( RAKI_PLATFORM_WII )
|
|
DVDInit();
|
|
VIInit();
|
|
|
|
raki::SystemAllocator_Initialize();
|
|
|
|
#elif defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
raki::CoInitializeInitObject coInitializeInitObject;
|
|
|
|
#endif
|
|
|
|
|
|
raki::TestInitializer initializer;
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
const char path_mono[] = "../../../../TestData/Sfx_ChangeCostume_01.wav.w32adpcm";
|
|
const char path_surroundTestL[] = "../../../../TestData/surroundTestL.wav.w32adpcm";
|
|
const char path_surroundTestR[] = "../../../../TestData/surroundTestR.wav.w32adpcm";
|
|
const char path_surroundTestBR[] = "../../../../TestData/surroundTestBR.wav.w32adpcm";
|
|
const char path_surroundTestBL[] = "../../../../TestData/surroundTestBL.wav.w32adpcm";
|
|
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
|
|
const char path_mono[] = "game:\\Sfx_ChangeCostume_01.wav.x360";
|
|
const char path_surroundTestL[] = "game:\\surroundTestL.wav.x360";
|
|
const char path_surroundTestR[] = "game:\\surroundTestR.wav.x360";
|
|
const char path_surroundTestBR[] = "game:\\surroundTestBR.wav.x360";
|
|
const char path_surroundTestBL[] = "game:\\surroundTestBL.wav.x360";
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
const char path_mono[] = "/app_home/Sfx_ChangeCostume_01.wav.ps3";
|
|
const char path_surroundTestL[] = "/app_home/surroundTestL.wav.ps3";
|
|
const char path_surroundTestR[] = "/app_home/surroundTestR.wav.ps3";
|
|
const char path_surroundTestBR[] = "/app_home/surroundTestBR.wav.ps3";
|
|
const char path_surroundTestBL[] = "/app_home/surroundTestBL.wav.ps3";
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
|
|
const char path_mono[] = "Sfx_ChangeCostume_01.wav.wii";
|
|
const char path_surroundTestL[] = "surroundTestL.wav.wii";
|
|
const char path_surroundTestR[] = "surroundTestR.wav.wii";
|
|
const char path_surroundTestBR[] = "surroundTestBR.wav.wii";
|
|
const char path_surroundTestBL[] = "surroundTestBL.wav.wii";
|
|
|
|
#endif
|
|
|
|
int count = 1;
|
|
while ( count )
|
|
{
|
|
|
|
RAKI_OUTPUT( "playing CENTER" );
|
|
bool playedOK = raki::TestSurround( path_mono, true );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
RAKI_OUTPUT( "playing FRONT LEFT" );
|
|
playedOK = playedOK = raki::TestSurround( path_surroundTestL, false, -1.f, 1.f );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
RAKI_OUTPUT( "playing FRONT RIGHT" );
|
|
playedOK = playedOK = raki::TestSurround( path_surroundTestR, false, 1.f, 1.f );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
RAKI_OUTPUT( "playing BACK RIGHT" );
|
|
playedOK = playedOK = raki::TestSurround( path_surroundTestBR, false, 1.f, -1.f );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
RAKI_OUTPUT( "playing BACK LEFT" );
|
|
playedOK = playedOK = raki::TestSurround( path_surroundTestBL, false, -1.f, -1.f );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
//--count;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|