PDA

View Full Version : Anyone using the new XAct audio API in DirectX?


PaulModz
05-26-2006, 02:24 PM
It seems kinda rude to drop a new acronym and split, so here’s a quick view of XAct from 10,000 feet that took me a while to wrestle out of the docs. The whole project seems kinda stealthy for an MS release, and I even heard that the first game to use XAct was almost released without MS even knowing about it.

High concept, XAct provides a much higher level of abstraction than DirectSound, making it both easier to use and more powerful. Rather than dealing with sounds as individual streams of bits to be shuffled back and forth between buffers, XAct presents you with 3 major, high level components; WaveBanks, SoundBanks, and Cues (there are more, but these 3 are the only ones germane to grokking XAct.)

Sounds are defined in two different files, separating the raw audio data from the configurable parameters that determine how that audio is rendered (Pitch, Volume, Looping, etc). The configurable parameters are data driven, so you can open a project in the XAct GUI tool, change its pitch, and hear the new sound without having to recompile. WaveBanks and SoundBanks are both classes in the XAct object model and data files produced by the functional (if slightly obtuse) XAct GUI tool, and there's a command line version as well.

WaveBanks (xwb files) are collections of individual wavs that are bundled into a single file. WaveBanks support ADPCM compression, but not mp3. ADPCM creates files roughly 25% of the original wav size, while mp3’s are closer to 10%.

SoundBanks (xsb files) contain both individual Sounds which are pointers to a Wave in a WaveBank, and Cues which are pointers to Sounds in the same SoundBank. Cues are your main interface with XAct, since playing sounds is done by triggering a Cue. Individual Sounds and Cues can point to multiple objects, and some of their properties determine how the sounds are played when a Cue is triggered. Some of the properties you can set for sounds and/or cues are volume, pitch, reverb, priority and a bunch of other stuff that I haven’t come to terms with yet.

Some of the more useful features I’ve found so far are:


A Cue can randomly vary the pitch and volume of a sound within a given range each time a sound is played. This is great for making small, frequently used sounds seem less repetitive.

The maximum number of concurrent instances of a Cue can be limited, and how the engine handles running into that limit is also configurable.

A Sound can be configured to loop a set or infinite number of times each time its Cue is triggered, and when stopping a looping sound you can choose to stop it immediately or have it play to the end of the current iteration.

When a Cue containing multiple sounds is triggered there are a few ways things can go down:

All the sounds are played at once
All the sounds are played, but each sound can be offset by a fixed or variable amount from when the Cue is triggered.
Only one sound is played, and each sound is given a weighting that determines the probability of its being chosen
Only one sound is played in random or sequential order regardless of weighting.


You can create your own named variables that are mapped to various aspects of playback, either per Cue instance or globally. You can then get/set those variables at runtime, linking audio rendering to any program specific variable in your app.

Waves, Sounds, and Cues are accessed by their index values, and the tools create a C++ header file each time the XAct project is built. The header contains enums that map each item’s index value to an enum entry with the name you gave the item in the GUI.


There’s lots of other stuff I either don’t understand yet or don’t have bandwidth to get into. If anyone is trying to use the Managed interface, I’d be happy to share my working C# code. The docs for the managed interface are almost non-existent, and I don’t think I could have gotten it to work without Reflector. (I think the Managed interface is actually still in Beta)

Applewood
05-30-2006, 03:30 PM
I tried to use this for its intended purpose - cross platform sound for PC and 360.

After about 20 hours of dicking about just trying to set the volume of a cue, I fucked it off and wrote my own engine in day and a half - and that's on both platforms that don't share an underlying system.

It truly sux. I think the player is probably ok, but the authoring tools are an object lesson in crapness. Couple that with almost no docs about how to do stuff and they can keep it, thanks.

Sounds like you got better mileage

PaulModz
05-31-2006, 08:48 PM
I can’t argue with your post. The docs are crappy, and figuring out how the WaveBanks, SoundBanks, Sounds, Cues, Tracks, Events, Variables, Categories, Presets, etc… all work together is a real chore. The GUI tool is cryptic, and the Managed interface is even worse. My guess is the people who wrote the documentation were either A) clueless interns or B) hardcore coders who’ve been working with it so long they forgot how to explain it.

Once I worked out the basics though, it’s the BEST audio engine I’ve ever used, and I still haven’t figured out half the doo-dads. It has features that are perfect for real world scenarios (MS APIs are often lacking in this area), and the command line tool is great for incorporating XAct project builds into project Pre/Post build events.

This API is slated to replace DirectSound at some point. If anyone else plans to take the plunge, I’ll be happy to share what I’ve learned.