Saturday, April 24, 2010

Visual Studio and Xact Compression Issue Workaround

Are you having issues with Visual Studio Freezing or Hanging when building your project. Caused by the fact you changed your Xact project to use XWMA compression? I did and it has caused me a number of issues, namely, I can use a big audio wavbank file (uncompressed), or I can build them and copy them to their destinations etc and stop the XactBld3.exe file with the windows Task manager.

Well it was time to put this thing to bed. My games when published have been way too large. Annoyingly large in my opinion. So I decided to look and see if anyone had a fix for this yet. I first ran into the problem more than 6 months ago i believe. What follows is a workaround to deal with this issue. And now my game is about a 4th of the size it was!

Steps i took to work around the Xact Compression in VS problem...
Important Fact:-
My Xact file will create my sound files all in the same directory it is in. I will use this to my advantage as Xact does not have a problem exporting the files locally. It is Only the VS integration that is broken.

1. I removed my Xact file from the project.
2. I added the XGS, XSB and XWB files into the content\audio folder (this was where my Xact file once resided.
3. You must then alter the 'Properties\Build Action' on all three of these files and select 'None'. Or you will get compile errors on these assets.
4. You then have to alter the 'Properties\Copy to Output directory' and set it to 'Copy if newer' (if you do not do this step, if you publish the game it will not copy your audio files.
5. I then created a Batch file to do the donkeywork for me (the copying). This was so much easier than trying to get VS or Xact to do the right thing with all the files. Believe me when i tell ya that i tried :S Following this is an example batch file.

rem windows version to Release and Debug
copy soundbank.xsb ..\..\bin\x86\Release\content\audio\soundbank.xsb /Y
copy ashooter.xgs ..\..\bin\x86\Release\content\audio\ashooter.xgs /Y
copy wavbank.xwb ..\..\bin\x86\Release\content\audio\wavbank.xwb /Y

copy soundbank.xsb ..\..\bin\x86\Debug\content\audio\soundbank.xsb /Y
copy ashooter.xgs ..\..\bin\x86\Debug\content\audio\ashooter.xgs /Y
copy wavbank.xwb ..\..\bin\x86\Debug\content\audio\wavbank.xwb /Y

rem xbox
copy xbox\ashooter.xgs "..\..\bin\xbox 360\Release\content\audio\ashooter.xgs" /Y
copy xbox\soundbank.xsb "..\..\bin\xbox 360\Release\content\audio\soundbank.xsb" /Y
copy xbox\wavbank.xwb "..\..\bin\xbox 360\Release\content\audio\wavbank.xwb" /Y

copy xbox\ashooter.xgs "..\..\bin\xbox 360\Debug\content\audio\ashooter.xgs" /Y
copy xbox\soundbank.xsb "..\..\bin\xbox 360\Debug\content\audio\soundbank.xsb" /Y
copy xbox\wavbank.xwb "..\..\bin\xbox 360\Debug\content\audio\wavbank.xwb" /Y
As you can see the batch file is very simple. all it does is copy the local files to the bin directories for both the Xbox and PC. You can have these things anywhere which is nice.

There might be a more pleasant workaround, i am not sure. I always export what i alter in Xact, so adding a single extra step when I am happy with the alterations is easy enough. Double clicking the batch file ain't no big thing. Yet, I would like it to be more automatic, so later I believe I will add this batch file to the pre-build steps of my project.

I hope this writeup helps other people stuck on this annoying bug.

If anyone has a better solution I would love to hear it, as i searched the web and found more annoying and cumbersome ways to fix this. Extra projects and the like.


1 comment:

  1. I'll try it out when I get near to releasing my game. Thanks.