423 lines
12 KiB
C++
423 lines
12 KiB
C++
|
|
#include "Precompiled.h"
|
|
|
|
#include "RakiTests/Initializer/TestInitializer.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"
|
|
#include "RakiEngine/Sounds/SoftwareEngine/BufferSoftwareSound.h"
|
|
#include "RakiEngine/Utils/MarkerContainerReader.h"
|
|
#include "RakiEngine/Utils/StringContainerReader.h"
|
|
#include "RakiEngine/Utils/File/FileStreamObject.h"
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 ) || defined ( RAKI_PLATFORM_SCARLETT )
|
|
|
|
#include "RakiTests/_Win32/CoInitializeInitObject.h"
|
|
#include "RakiEngine/Data/WaveFile/BinWaveData/_XAudio2/BinWaveDataNative_XAudio2.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>
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
#include "RakiEngine/Sounds/_Cafe/BufferSoundNative_Cafe.h"
|
|
#include "RakiTests/_Cafe/Memory/SimpleHeap_Cafe.h"
|
|
|
|
#elif defined ( RAKI_PLATFORM_ORBIS ) || defined ( RAKI_PLATFORM_PROSPERO )
|
|
|
|
size_t sceLibcHeapSize = SCE_LIBC_HEAP_SIZE_EXTENDED_ALLOC_NO_LIMIT;
|
|
unsigned int sceLibcHeapExtendedAlloc = 1;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//#define RAKI_TESTBINWAVEDATA_USING_TEST_FILTER
|
|
|
|
|
|
|
|
|
|
namespace raki
|
|
{
|
|
|
|
|
|
static bool TestBinWaveData( const char * _path, const bool _isLooping )
|
|
{
|
|
FileStreamObject fileStreamObject( true );
|
|
|
|
if ( !fileStreamObject.open( _path ) )
|
|
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_SCARLETT )
|
|
BinWaveDataNative binWaveData;
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
BinWaveData binWaveData( MemoryBlock::ps3_aligned128 );
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
BinWaveData binWaveData( MemoryBlock::wii_mem2_aligned32 );
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
BinWaveData binWaveData( MemoryBlock::cafe_aligned64 );
|
|
#elif defined ( RAKI_PLATFORM_ORBIS )
|
|
BinWaveData binWaveData( MemoryBlock::standard );
|
|
#elif defined ( RAKI_PLATFORM_PROSPERO )
|
|
BinWaveData binWaveData( MemoryBlock::standard );
|
|
#endif
|
|
|
|
if ( !binWaveData.read( &fileStreamObject ) )
|
|
return false;
|
|
|
|
if ( binWaveData.getChunkData( RiffChunkManager::ms_riffTagMARK ) && binWaveData.getChunkData( RiffChunkManager::ms_riffTagSTRG ) )
|
|
{
|
|
MarkerContainerReader markerContainer( binWaveData.getChunkData( RiffChunkManager::ms_riffTagMARK ), binWaveData.getChunkSize( RiffChunkManager::ms_riffTagMARK ) );
|
|
StringContainerReader stringContainer( binWaveData.getChunkData( RiffChunkManager::ms_riffTagSTRG ), binWaveData.getChunkSize( RiffChunkManager::ms_riffTagSTRG ) );
|
|
|
|
for ( u32 marker = 0 ; marker < markerContainer.getNbMarkers() ; ++marker )
|
|
{
|
|
RAKI_ASSERT( stringContainer.getString( markerContainer.getIndexOfMarkerNameInStringContainer( marker ) ) );
|
|
RAKI_OUTPUT("marker %d - offset %d - name <%s>", marker, markerContainer.getMarkerOffset( marker ), stringContainer.getString( markerContainer.getIndexOfMarkerNameInStringContainer( marker ) ) );
|
|
}
|
|
}
|
|
|
|
#if defined ( RAKI_USING_SOFTWARE_ENGINE )
|
|
BufferSoftwareSound bufferSound;
|
|
#else
|
|
BufferSoundNative bufferSound;
|
|
#endif
|
|
|
|
const bool isMusic = false;
|
|
SoundParams soundParams( isMusic, _isLooping );
|
|
|
|
bufferSound.createVoice( &binWaveData, soundParams );
|
|
|
|
bufferSound.setDecibelVolume( 0.f );
|
|
|
|
bufferSound.updateRouting( true );
|
|
|
|
bufferSound.start();
|
|
|
|
#ifdef RAKI_TESTBINWAVEDATA_USING_TEST_FILTER
|
|
const FilterParams filterParams( FilterParams::lowPass, 1000.f );
|
|
bufferSound.setRoutingFilterParams( filterParams );
|
|
bufferSound.updateRouting( true );
|
|
#endif //
|
|
|
|
i32 frame = 0;
|
|
|
|
#define PAUSE_FRAME_PERIOD 50
|
|
#define PAUSE_FRAME_PAUSE 30
|
|
#define PAUSE_FRAME_RESUME ( PAUSE_FRAME_PERIOD - 1 )
|
|
|
|
|
|
if ( _isLooping )
|
|
{
|
|
f32 timeBeginning = Time::getTime();
|
|
|
|
// wait 5 seconds
|
|
while ( ( Time::getTime() - timeBeginning ) < 5 )
|
|
{
|
|
#ifdef RAKI_PLATFORM_WII
|
|
VIWaitForRetrace();
|
|
#else // RAKI_PLATFORM_WII
|
|
Thread::sleep( 16 );
|
|
#endif // RAKI_PLATFORM_WII
|
|
/*
|
|
if ( ( frame % PAUSE_FRAME_PERIOD ) == PAUSE_FRAME_PAUSE )
|
|
bufferSound.pause();
|
|
|
|
if ( ( frame % PAUSE_FRAME_PERIOD ) == PAUSE_FRAME_RESUME )
|
|
bufferSound.resume();
|
|
*/
|
|
++frame;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
while( bufferSound.isPlaying() )
|
|
{
|
|
#ifdef RAKI_PLATFORM_WII
|
|
VIWaitForRetrace();
|
|
#else // RAKI_PLATFORM_WII
|
|
Thread::sleep( 16 );
|
|
#endif // RAKI_PLATFORM_WII
|
|
/*
|
|
if ( ( frame % PAUSE_FRAME_PERIOD ) == PAUSE_FRAME_PAUSE )
|
|
bufferSound.pause();
|
|
|
|
if ( ( frame % PAUSE_FRAME_PERIOD ) == PAUSE_FRAME_RESUME )
|
|
bufferSound.resume();
|
|
*/
|
|
++frame;
|
|
}
|
|
}
|
|
|
|
bufferSound.destroyVoice();
|
|
|
|
// wait for destroy command to be processed on async systems
|
|
while ( !bufferSound.isVoiceDestroyed() )
|
|
{
|
|
Thread::sleep( 5 );
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
} // namespace raki
|
|
|
|
|
|
|
|
int rakimain();
|
|
int rakimain()
|
|
{
|
|
|
|
#if defined ( RAKI_PLATFORM_WII )
|
|
DVDInit();
|
|
VIInit();
|
|
|
|
raki::SystemAllocator_Initialize();
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
raki::SimpleHeap_Cafe::init();
|
|
|
|
#elif defined ( RAKI_PLATFORM_WIN32 ) || defined ( RAKI_PLATFORM_SCARLETT )
|
|
|
|
raki::CoInitializeInitObject coInitializeInitObject;
|
|
|
|
#endif
|
|
|
|
|
|
raki::TestInitializer initializer;
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_WIN32 )
|
|
|
|
#if defined ( RAKI_USING_SOFTWARE_ENGINE )
|
|
const char path_stereo[] = "../../../../TestData/TestStereo.wav.w32pcm";
|
|
const char path_mono[] = "../../../../TestData/Sfx_ChangeCostume_01.wav.w32pcm";
|
|
const char path_loop[] = "../../../../TestData/TestSineLoop.wav.w32pcm";
|
|
const char path_loop1152[] = "../../../../TestData/TestSineLoop1152.wav.w32pcm";
|
|
#else // defined ( RAKI_USING_SOFTWARE_ENGINE )
|
|
const char path_stereo[] = "../../../../TestData/TestStereo.wav.w32adpcm";
|
|
const char path_mono[] = "../../../../TestData/Sfx_ChangeCostume_01.wav.w32adpcm";
|
|
const char path_loop[] = "../../../../TestData/TestSineLoop.wav.w32adpcm";
|
|
const char path_loop1152[] = "../../../../TestData/TestSineLoop1152.wav.w32adpcm";
|
|
#endif // defined ( RAKI_USING_SOFTWARE_ENGINE )
|
|
|
|
#elif defined ( RAKI_PLATFORM_XB360 )
|
|
|
|
const char path_stereo[] = "game:\\TestStereo.wav.x360";
|
|
const char path_mono[] = "game:\\Sfx_ChangeCostume_01.wav.x360";
|
|
const char path_loop[] = "game:\\TestSineLoop.wav.x360";
|
|
const char path_loop1152[] = "game:\\TestSineLoop1152.wav.x360";
|
|
|
|
#elif defined ( RAKI_PLATFORM_PS3 )
|
|
|
|
const char path_stereo[] = "/app_home/Y:/JD5/JD/main/extern/Raki/TestData/TestStereo.wav.ps3";
|
|
const char path_mono[] = "/app_home/Y:/JD5/JD/main/extern/Raki/TestData/Sfx_ChangeCostume_01.wav.ps3";
|
|
const char path_loop[] = "/app_home/Y:/JD5/JD/main/extern/Raki/TestData/TestSineLoop.wav.ps3";
|
|
const char path_loop1152[] = "/app_home/Y:/JD5/JD/main/extern/Raki/TestData/TestSineLoop1152.wav.ps3";
|
|
|
|
#elif defined ( RAKI_PLATFORM_WII )
|
|
|
|
const char path_stereo[] = "_raki_/TestStereo.wav.wii";
|
|
const char path_mono[] = "_raki_/Sfx_ChangeCostume_01.wav.wii";
|
|
const char path_loop[] = "_raki_/TestSineLoop.wav.wii";
|
|
const char path_loop1152[] = "_raki_/TestSineLoop1152.wav.wii";
|
|
|
|
#elif defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
const char path_stereo[] = "/vol/content/_raki_/TestStereo.wav.cafe";
|
|
const char path_mono[] = "/vol/content/_raki_/Sfx_ChangeCostume_01.wav.cafe";
|
|
const char path_loop[] = "/vol/content/_raki_/TestSineLoop.wav.cafe";
|
|
const char path_loop1152[] = "/vol/content/_raki_/TestSineLoop1152.wav.cafe";
|
|
|
|
#elif defined ( RAKI_PLATFORM_ORBIS )
|
|
|
|
const char path_stereo[] = "/hostapp/_raki_/TestStereo.wav.orbis";//Y:/JD5/JD/playground/JD6/extern/Raki/TestData/TestStereo.wav.orbis";
|
|
const char path_mono[] = "/hostapp/_raki_/Sfx_ChangeCostume_01.wav.orbis";
|
|
const char path_loop[] = "/hostapp/_raki_/TestSineLoop.wav.orbis";
|
|
const char path_loop1152[] = "/hostapp/_raki_/TestSineLoop1152.wav.orbis";
|
|
|
|
#elif defined ( RAKI_PLATFORM_PROSPERO )
|
|
|
|
const char path_stereo[] = "/app0/TestStereo.wav.prospero";
|
|
const char path_mono[] = "/app0/Sfx_ChangeCostume_01.wav.prospero";
|
|
const char path_loop[] = "/app0/TestSineLoop.wav.prospero";
|
|
const char path_loop1152[] = "/app0/TestSineLoop1152.wav.prospero";
|
|
|
|
#elif defined ( RAKI_PLATFORM_SCARLETT )
|
|
|
|
const char path_stereo[] = "TestStereo.wav.scarlett";
|
|
const char path_mono[] = "Sfx_ChangeCostume_01.wav.scarlett";
|
|
const char path_loop[] = "TestSineLoop.wav.scarlett";
|
|
const char path_loop1152[] = "TestSineLoop1152.wav.scarlett";
|
|
|
|
#endif
|
|
|
|
bool playedOK;
|
|
|
|
playedOK = raki::TestBinWaveData( path_stereo, false );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
playedOK = raki::TestBinWaveData( path_loop, true );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
playedOK = raki::TestBinWaveData( path_loop1152, true );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
playedOK = raki::TestBinWaveData( path_mono, false );
|
|
if ( !playedOK )
|
|
return -1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if defined ( RAKI_PLATFORM_CAFE )
|
|
|
|
int run_demo (int /*intArg*/, void */*ptrArg*/)
|
|
{
|
|
return rakimain();
|
|
}
|
|
|
|
u32 running_core;
|
|
u32 main_core;
|
|
u32 first_subcore;
|
|
u32 second_subcore;
|
|
u32 wait_main_core;
|
|
u32 wait_first_subcore;
|
|
u32 wait_second_subcore;
|
|
OSRendezvous rendezvous;
|
|
|
|
void
|
|
SetupCoreIds(void)
|
|
{
|
|
running_core = OSGetCoreId();
|
|
main_core = OSGetMainCoreId();
|
|
|
|
first_subcore = 0;
|
|
second_subcore = 2;
|
|
wait_main_core = OS_WAIT_CORE_MAIN;
|
|
wait_first_subcore = OS_WAIT_CORE_SUB1;
|
|
wait_second_subcore = OS_WAIT_CORE_SUB2;
|
|
|
|
if (main_core == 0)
|
|
{
|
|
first_subcore = 1;
|
|
second_subcore = 2;
|
|
wait_main_core = OS_WAIT_CORE_SUB1;
|
|
wait_first_subcore = OS_WAIT_CORE_MAIN;
|
|
wait_second_subcore = OS_WAIT_CORE_SUB2;
|
|
}
|
|
else
|
|
if (main_core == 2)
|
|
{
|
|
first_subcore = 0;
|
|
second_subcore = 1;
|
|
wait_main_core = OS_WAIT_CORE_SUB2;
|
|
wait_first_subcore = OS_WAIT_CORE_SUB1;
|
|
wait_second_subcore = OS_WAIT_CORE_MAIN;
|
|
}
|
|
}
|
|
|
|
int main( int /*argc*/, char * /*argv[]*/ )
|
|
{
|
|
|
|
u32 gx2InitAttribs[] =
|
|
{
|
|
GX2_INIT_ATTRIB_NULL // terminates the list
|
|
};
|
|
GX2Init(gx2InitAttribs);
|
|
|
|
// launch test on Core 0 if present
|
|
if (OSGetCoreCount() == 3)
|
|
{
|
|
OSThread* defaultThread0;
|
|
|
|
SetupCoreIds();
|
|
|
|
OSReport("Running Core == %d\n", running_core);
|
|
OSReport("OS Main Core == %d\n\n", main_core);
|
|
|
|
OSInitRendezvous(&rendezvous);
|
|
|
|
//
|
|
// Restart default thread on 1st subcore, core0
|
|
//
|
|
|
|
defaultThread0 = OSGetDefaultThread(first_subcore);
|
|
OSRunThread(defaultThread0,
|
|
run_demo,
|
|
0,
|
|
(void*) 0x23232323);
|
|
|
|
OSWaitRendezvous(&rendezvous, wait_first_subcore);
|
|
}
|
|
else
|
|
{
|
|
run_demo(0, NULL);
|
|
}
|
|
|
|
GX2Shutdown();
|
|
|
|
return 0;
|
|
}
|
|
|
|
#elif defined ( RAKI_USING_XAUDIO2 )
|
|
int _tmain(int /*argc*/, _TCHAR* /*argv[]*/)
|
|
{
|
|
rakimain();
|
|
|
|
return 0;
|
|
}
|
|
#elif defined ( RAKI_PLATFORM_ORBIS ) || defined ( RAKI_PLATFORM_PROSPERO )
|
|
int main( int /*argc*/, char ** /*argv[]*/ )
|
|
{
|
|
rakimain();
|
|
|
|
return 0;
|
|
}
|
|
#else
|
|
int main( int /*argc*/, char * /*argv[]*/ )
|
|
{
|
|
rakimain();
|
|
|
|
return 0;
|
|
}
|
|
#endif // RAKI_USING_XAUDIO2
|