Advertisement

XAudio2 Xbox360 play a sound .XMA files

Started by February 04, 2022 11:42 PM
0 comments, last by godzhand 2 years, 9 months ago

Hello, I amtrying to simply play a sound through the XAudio2 library on the xbox 360

the problem is, the documentation on XAudio2 library for the xbox 360 is minimum, the xbox 360 can apparently only play sound files that are .XMA files i have an .XMA file

the following code is how far I have gotten

IXAudio2* pXAudio2 = nullptr;
if (SUCCEEDED( XAudio2Create( &pXAudio2, 0,XboxThread5 ) ) )
{
    NotifyPopup(L"success!");
}
 IXAudio2MasteringVoice* pXMaster = nullptr;
  pXAudio2->CreateMasteringVoice(&pXMaster,XAUDIO2_DEFAULT_CHANNELS,XAUDIO2_DEFAULT_SAMPLERATE,0,0,NULL);
  XMA2WAVEFORMATEX wfx = { 0 };
   XAUDIO2_BUFFER buffer = { 0 };
char* strFileName = "HDD:\\s1.xma";
 HANDLE hFile = CreateFile(
       strFileName,
       GENERIC_READ,
       FILE_SHARE_READ,
       NULL,
       OPEN_EXISTING,
       0,
       NULL);
 DWORD dwChunkSize;
   DWORD dwChunkPosition;
   //check the file type, should be fourccWAVE or 'XWMA'
   FindChunk(hFile, fourccRIFF, dwChunkSize, dwChunkPosition);
   DWORD filetype;
   ReadChunkData(hFile, &filetype, sizeof(DWORD), dwChunkPosition);
   FindChunk(hFile, fourccFMT, dwChunkSize, dwChunkPosition);
   ReadChunkData(hFile, &wfx, dwChunkSize, dwChunkPosition);
   FindChunk(hFile, fourccDATA, dwChunkSize, dwChunkPosition);
   BYTE* pDataBuffer = new BYTE[dwChunkSize];
   ReadChunkData(hFile, pDataBuffer, dwChunkSize, dwChunkPosition);

   buffer.AudioBytes = dwChunkSize;  //size of the audio buffer in bytes
   buffer.pAudioData = pDataBuffer;  //buffer containing audio data
   buffer.Flags = XAUDIO2_END_OF_STREAM; // tell the source voice not to expect any data after this buffer
   IXAudio2SourceVoice* pSourceVoice;

If i attempt to add the following code my xbox will crash

pXAudio2->CreateSourceVoice( &pSourceVoice,(WAVEFORMATEX*)(&wfx));

am i properly reading the chunks of data right from the xma2 file? this is modified code from a tutorial and was meant for .WAV files…sadly wav files dont work on the 360

This topic is closed to new replies.

Advertisement