I am making a simple game in Visual C++ 2008 Express and using DirectX 9 for graphics and XACT for audio rendering.
I used the simplest method - initialize the engine, load the sound and wave banks, and call soundbank->Play(...) whenever I want to play a cue.
I tried to make a sound with two waves attached to it by following the steps described in this article:
http://msdn.microsoft.com/en-us/library/bb172312(VS.85).aspx and it plays fine in the XACT Tool, but when I try to use the cue in my game, I get this error: Unhandled exception at 0x65dfb745 in Arkandroid.exe: 0xC0000005: Access violation writing location 0x009e011f.
I have no idea what is the cause of this error. I used the same method to play this sound that I use to play the other ones.
I tried to make other changes in the XACT Tool - like setting the loop count, attaching more waves to one sound in separate tracks, etc. - and everything is working as expected in the XACT Tool as well as in the game. The only thing to cause the crash is multiple waves in the same track set to play randomly.
I appraciate any help, I really have no idea what I did wrong. I tried to search online, but found nothing. Also it seems like most people use XACT with C#, and it's different in some ways (well, mostly the initialization part).
Update: OK, so it turned out that you cannot use the CreateFileMapping(...) / MapViewOfFile(...) method to load the sound bank, if you want to use sounds with multiple waves attached to them. I changed the loading code to allocate memory for the sound bank data (sb_data = new BYTE[fileSize]) and use LoadFile(...) to load the xsb file, and now it's working.
One question, though: If using MapViewOfFile causes errors like this, then why are the XACT samples written with it? It's confusing for newcomers (like me), because I thought they used it in the tutorials for a reason so I used this method in my game, but it only caused not-so-obvious errors.