Day: June 17, 2009

How to stream an ogg file using DirectSound in SlimDX.

With a nudge in the right direction from the SlimDX devs, I’ve finally got a working streaming solution for DirectSound in SlimDX. This will be a part of the 1.007 release of AI War, improving performance in the game, but I also wanted to share the code for this since it isn’t out there anywhere else.

First of all, let me note that this entire solution is really just an adaptation of an MDX Directsound streaming solution by Dr Gary. Secondly, it uses the wonderful Ogg Vorbis Decoder (a C# wrapper for the standard ogg dlls) by Atachiants Roman. And, lastly, of course this uses the SlimDX library.

Here’s the code, including a compiled test executable. Do with it what you will. If you want a deep explanation of what is going on there, you want to read Dr Gary’s article above. This is basically his work, after all, and he explains it very nicely.

Here are the major things I added/changed:

1. SlimDX is used instead of MDX, which obviously necessitated a lot of changes.

2. Rather than use Dr Gary’s wav stream class, I’m using the ogg stream class. This required even more changes, especially since the ogg calls are apparently not threadsafe (Dr. Gary was using his wav stream object from multiple threads, which the ogg library did not like one bit).

3. The way I am pulling data off of the ogg stream is a bit different from how the original code was pulling data off of the wav stream. In the original, the stream was seeking every time, to prevent data skips and loss. In my version, I’m using a loop to make sure that this isn’t neccessary, and thus there’s a minor performance gain.

4. I took out support for looping. This code was originally being adapted for AI War, which doesn’t need looping in the same sense. If you want to loop the file, just do like I’m doing in the sample and start playing it again after it completes. My goal was to keep this simple.

5. There are a variety of other minor changes, just switching it to be more in line with the AI War codebase. This was for my own purposes, but since I wanted to make the code public these changes are also seen here.

That’s it! Happy coding.

AI War 1.006 Released (Free DLC & Player Suggestions)

Arcen Games is pleased to announce the release of AI War: Fleet
Command version 1.006. You can download a trial version
of the game, as well as purchase
a license key
to unlock the full version. If you already have the
game or demo installed, just hit “Check For Updates” inside the game to
get the latest patch.  

Note:  some people were having some
trouble with the 1.005 installer, but that should be resolved with this
release without the need for any external workarounds.  Thanks to
everyone affected for their patience with that issue.

 

More Free DLC: Four new ships are now available for your use:
Engineer II, and three new kinds of Orbital Command Stations: Mark II,
Mark III, and Warp Jammer.  These four new ship types greatly expand the
economic options for players who want to customize their civilizations
in that direction.  The higher-level command stations provide extra
resources, while the Warp Jammer command station provides a way to
prevent all enemy warps into a few select systems (but at a steep
ongoing resource cost).

In addition to the
new ships, this release also contains even more dozens of improvements,
tweaks, and extensions based on player suggestions. This week’s offering
exceeds even last week’s, we think.  Thanks again to everyone who took
the time to offer feedback — and as a reminder for everyone whose
suggestion made it onto the official to-be-done-in-DLC list, but didn’t
make it into this release, you should be seeing your ideas in play over
the coming weeks.

Here are some of the highlights:

– New graphs in the scores display shows player progress on a number
of metrics over time.

– The online mini strategy guide has become a more comprehensive
wiki.

– Various improvements to the score screen display.

– Tooltips for starting ship types in the lobby, and other minor
lobby enhancements.

– Even more galaxy map display modes, filters, and control options.

– Holding the I key now shows the Hit Percent and Damage for all
selected ships.

– Savegame performance improved 5x for large games (60,000+ ships)
in particular.

– AI Progress now uses a scale 10x higher than it was previously,
and Astro Train Station and Special Forces Command Post destruction now
has a minor increase to AI Progress.

– Several AI behaviorlets have been added for making it more
intelligent in a few specific cases.

– Several improvements have been made to make the game more friendly
to Turn-Based Strategy (TBS) players.

– Dozens more smaller improvements, tweaks, and extensions suggested
by players.  See full release notes for details.

The above list is just a sampling, however, so be sure to check out the
full release notes to see everything (attached at the end of this post).
 More free DLC will be heading your way next week. Enjoy!