In case this is helpful to anyone, I wrote up a few things about what I’ve learned so far … reposted from my blog since few probably roam there:
After reading this very useful post-mortem and working with XNA and XACT for a bit, I decided to do a bit of a pre-mortem to share what I’ve learned so far.
- You should only have one instance of AudioEngine. You can have as many sound and wave banks loaded into the same engine as the hardware will support, but the only restriction is that they all share the same global settings data. This leads me to deduce that the best practice is to have one XACT project for your entire title.
- XACT is already multithreaded. Apparently, the heavy lifting of playing audio on Xbox happens on hardware thread 4 (the second thread of core #2). Calling AudioEngine.Update on a different thread is not likely to bring any performance gains unless you “have millions of crazy curves and variables and things”.
- Despite my initial confusion, XNA does in fact support streaming wave banks. All you have to do is designate the wave bank’s Type property asStreaming, then call the WaveBank class constructor that takes the offset and packetsize arguments.
The main issue I have with this is that it is not documented very well. They try to provide guidance on what to set the packetsize argument to, but the guidance is for streaming from a DVD (something XNA doesn’t support quite yet). The documentation should also provide guidance for a title running from the HDD.
Also, it’s important to note that you must call Update at least once and check the Isprepared property to make sure it’s true before attempting to play any sound that uses one of those waves. Thankfully, this is documented in the streaming constructor topic, but I think there should be a “how to” article on how to stream audio.
- According to the docs, XACT supports in-game auditioning using a special development-only API. I have not seen that these APIs are available in XNA … this would be a pretty cool feature 🙂
The toolchain in Superman Returns: The Videogame had a very similar feature where the console would run a tcp/ip server that would change audio properties at run-time. The tool running on the audio designer’s PC would then send messages when its knobs and switches were manipulated. I wrote the piece that ran on the PC (using C#, winforms, and .NET Remoting) … based on the feedback I got from the audio guys, this really helped them nail the audio mix. So I would love to see similar functionality be available to XNA titles in development.
All in all, I think XNA and XACT does a pretty good job of leading people into a Pit of Success. I’ve still got a lot to learn, but I’m really enjoying audio programming so far. Hopefully that will be reflected in myDream.Build.Play entry.