-
Since I last wrote about XACT compression over a year ago. Let's see:
- We released XNA Game Studio 2.0.
- We've built a version of XNA Game Studio that will enable the Dream Build Play winners to publish their XNA Framework based games on Xbox LIVE Arcade.
- GDC 2008 was interesting...
- We announced Community Arcade games that will allow you to share your games over Xbox LIVE Marketplace.
- We announced that XNA Game Studio 3.0 will add support for creating games for your Zune!
- We released the XNA Game Studio 3.0 CTP in May, providing an early look at the new features coming out this year.
- We released a beta of the Community Games support. If you're an XNA Creators Club member, you can try it out today over at http://creators.xna.com!
- Oh, and a completely new website too!
That's quite a lot for 12 months! Right now we're cranking away at finishing up XNA Game Studio 3.0 and getting the Community distribution system ready to go later this year. As for me, I'm primarily working on where XNA Game Studio is going beyond 3.0...what will 4.0 and 5.0 look like? What are the problems that (still) exist for our customers who are trying to create great games?
And I'm working on a few presentations for Gamefest. Oh, and I try to create some games too. :)
-
There are two pieces of feedback that I hear quite a bit related to the audio support in XNA Game Studio Express.
- It only supports WAV files. All of my sounds are in a different format, such as WMA.
- Audio binaries are too large. WAV isn't compressed, so my music tracks are huge!
We're investigating what we can do for the first issue, which would obviously help the second issue at the same time. But there is some support for compressing your audio files in the current product, using the XACT tool; it's just not easy to discover. XACT supports ADPCM compression on Windows and XMA compression on the Xbox 360. You can get about 4:1 compression with ADPCM and even better with XMA. So while perhaps not as high as some other encodings, such as WMA, it does offer quite a substantial savings.
So how do you enable compression for your Wavebanks? Let's take a look:
- Create an XACT project and a Wave Bank
Start the XACT editor by using the Start menu shortcut Microsoft XNA Game Studio Express -> Tools -> Microsoft Cross-Platform Audio Creation Tool (XACT). Create a new project and add a new Wave Bank to the project.
- Add some WAV files to the Wave Bank
While we won't be playing any sounds during this, we do want to see the results of the compression. Once your done with this, you should see something like the below screenshot.

- Create a new Compression Preset
You can create a group of compression settings via a Compression Preset. This allows you to reuse the settings across multiple Wave Banks. This is also why it's a bit hidden. Rather than adjusting the compression settings on the sounds themselves or the Wave Bank, we do it here. You can create a new Compression Preset easily by right-clicking on the Compression Presets item in the explorer.

- Tweak Settings
After you've created it, you can see the default compression settings for ADPCM and XMA. You do have the ability to change some of these settings, although we'll just leave the defaults for this exercise.

- Apply the Compression Preset to the Wave Bank.
This is as easy as selecting the Wave Bank we created earlier, and then selecting the Compression Preset we just created in the Properties window for the Wave Bank. This tells the XACT compiler that we would like it to compress the WAV files using the preset settings when it builds the Wave Bank binaries.

- Done!
If we look at the details for the WAV files that are in the Wave Bank, we see that they now indicate they are compressed and how much space is saved.

I hope this was helpful for those that didn't know about the ability to compress your audio binaries using XACT. While not as compressed as some other formats, it should provide for smaller game sizes, especially when including audio assets for background music.
-
The native XACT APIs have added the support for programmatic wave playback. I.e. at runtime, you can load *.wav files into a Wavebank and play them from there, without needing to create a project and compile the binaries. This is something we're looking at supporting in our next release, but I want to gauge how much interest there is in this feature? Keep in mind that implementing this feature may very well mean we can't do some other feature.
So how important is this to you? Is using the XACT editor and precompiling your audio a big issue? Is it just a learning curve for the editor, and then you move on?
Please vote here: http://forums.xna.com/7198/ShowThread.aspx#7198
-
As detailed here, we've released an update to XNA Game Studio Express today. You can get an idea of what's in it by reading this announcement post. The primary goal of this release was to get official Vista support into the product. We also took the opportunity to fix a bunch of bugs and add a few new features. Many of the bugs we've fixed and features we added came directly from you, so I hope you enjoy this release and thanks!
Now on to the next release!
-
XNA Game Studio Express is now available for download.
http://msdn.microsoft.com/directx/XNA
This includes the Xbox 360 side of things as well. You can set up your Xbox 360 via the Xbox Live Marketplace.
So let's see what you got! Your game may even make it to Xbox Live Arcade!
http://www.dreambuildplay.com
-
You've probably seen the post announcing we're releasing a Beta 2 of XNA Game Studio Express. This release contains lots of fixes and tweaks based on feedback and it includes the much anticipated Content Pipeline! As we get closer to release, I'll have a post that explains some of the changes.
If you want to get a sneak peak at what's coming in the beta, then you should stop by the Seattle Code Camp v2.0 that is happening this weekend. There are a lot of great sessions, including 3 XNA related sessions:
- Making an XNA Game for the Xbox 360
- Introduction to the Programmable Pipeline in XNA
- Exploring the XNA Framework
I'm giving the last session where we'll be looking at new features and changes in the XNA Framework, a little peak into the Content Pipeline and our support for the Xbox 360!
-
Ohio State 24 Texas 7
-
I was originally going to create a tutorial that walks you through creating a custom GameComponent, perhaps the Framerate component from my demo or an event driven Keyboard component, but I’ve actually seen several of these pop up over the last few days so perhaps you’ve got the hang of it. J
What I have seen are a few questions about are game services and particularly IGraphicsDeviceService. So I thought I’d write up a quick description of game services as well as the proper way to query and use the IGraphicsDeviceService.
GameServices
A game service can be thought of as a service that is available to anyone that has a reference to a Game. The idea behind it was there are certain types, or services, that a component should be able to depend on for its functionality. If that service isn’t available, then the component can’t operate correctly. The first one we thought of (and one of the reasons behind introducing services) was making a GraphicsDevice reference available across a game. Originally we had the Game own the GraphicsDevice and expose it via a property like Game.GraphicsDevice. The problem with this was that this tightly bound the GraphicsDevice to the Game, not allowing someone else to “own” the device (such as a renderer) and preventing someone from using a future updated GraphicsDevice without shipping a new version of Game that wouldn’t be backwards compatible. So to achieve the loose coupling of a GraphicsDevice and a Game, we factored the device management and ownership into a GameComponent, which is how GraphicsComponent came to be. We still needed to make the GraphicsDevice available across a Game or even outside of the Game. As long as someone has a reference to a Game, they should be able to get a hold of a GraphicsDevice, if it’s available. That’s the idea behind a game service. The GraphicsComponent “publishes” an interface, IGraphicsDeviceService, as a service that others can query for and obtain a reference to. In this sense, a service is a singleton that is keyed off the type of the service itself. So a component that needs to render using a GraphicsDevice, doesn’t have to be tied to a GraphicsComponent, it can just query for the IGraphicsDeviceService instead. Imagine if someone wanted to create a high-level renderer that owned the GraphicsDevice itself, rather than use the GraphicsComponent. They could create the renderer as a GameComponent and publish an instance of the IGraphicsDeviceService themselves and now the Game has use of a new renderer and all game components that depended on a GraphicsDevice will still work too!
One other benefit of services is that Game.GameServices can be passed to the ContentManager so the type loaders in the content manager can query for services (this is how textures load for instance). Because the container is passed one can add additional content types to the content manager (via a custom type loader) that relies on a custom game service without any intervention on our part.
So that was a quick explanation of a game service (complete with a GraphicsComponent history!) but it should help convey what the purpose of a service is and when you’d use them. They really are meant to be a system wide service that something can query for.
IGraphicsDeviceService
As mentioned above, game components that wish to render something on the screen need to get a reference to a GraphicsDevice. They could expose a property that is of type GraphicsComponent, but this would cause them to not work if a Game used something else to manage the GraphicsDevice, such as a custom renderer. Instead a GameComponent that wishes to make use of the GraphicsDevice should query for the IGraphicsDeviceService from Game with the following line of code:
IGraphicsDeviceService graphicsService = Game.GameServices.GetService<IGraphicsDeviceService>();
Here’s what the IGraphicsDeviceService interface looks like:
// Summary:
// Defines a mechanism for retrieving GraphicsDevice objects.
public interface IGraphicsDeviceService
{
// Summary:
// Retrieves a graphcs device.
//
// Returns:
// A graphics device.
GraphicsDevice GraphicsDevice { get; }
// Summary:
// The event that occurs when a graphics device is created.
event EventHandler DeviceCreated;
//
// Summary:
// The event that occurs when a graphics device is disposing.
event EventHandler DeviceDisposing;
//
// Summary:
// The event that occurs when a graphics device is reset.
event EventHandler DeviceReset;
//
// Summary:
// The event that occurs when a graphics device is in the process of resetting.
event EventHandler DeviceResetting;
}
As you can see the interface provides a reference to the GraphicsDevice as well as several events that you should use to properly detect when you need to load and unload your graphic resources such as textures, vertex buffers, index buffers and effects. It’s also important to note that you should only cache a reference to the interface, not a reference to the GraphicsDevice. This is because the reference to the GraphicsDevice can (and most likely will) change over the course of a Game due to window resizing, changing monitors, etc. The reference to the service, however, will remain the same throughout the game.
So you should typically query for the service and hook up the events you care about inside of the Start method of a GameComponent like so:
public override void Start()
{
this.graphics = this.Game.GameServices.GetService<IGraphicsDeviceService>();
this.graphics.DeviceReset += new EventHandler(graphics_DeviceReset);
this.graphics.DeviceResetting += new EventHandler(graphics_DeviceResetting);
this.graphics.DeviceCreated += new EventHandler(graphics_DeviceCreated);
this.graphics.DeviceDisposing += new EventHandler(graphics_DeviceDisposing);
LoadContent();
}
And provide event handlers like so:
void graphics_DeviceDisposing(object sender, EventArgs e)
{
ReleaseContent();
}
void graphics_DeviceCreated(object sender, EventArgs e)
{
LoadContent();
}
void graphics_DeviceResetting(object sender, EventArgs e)
{
ReleaseContent();
}
void graphics_DeviceReset(object sender, EventArgs e)
{
LoadContent();
}
And lastly it’s a good practice to put your loading and unloading of resources into a couple of common functions:
private void LoadContent()
{
this.font = new Font(this.graphics.GraphicsDevice, "Components", "Comic Sans MS_16");
}
private void ReleaseContent()
{
if (this.font != null)
{
this.font.Dispose();
this.font = null;
}
}
So I hope this was a helpful explanation of what game services are, why they are important and also what the IGraphicsDeviceService is for and how to use it. Please let us know what you think over at the XNA Framework forum.
-
I put my video for the Game Component demo up on the XNA Team Blog and forgot to mention it here. Oops! :)
http://blogs.msdn.com/xna/archive/2006/08/31/734204.aspx
-
You can grab it here.
This is obviously a beta, so there are a few rough edges here and there that we are working on. If you have how-to or general questions, please go to the forums at http://msdn.com/xna/forums/. If you find a bug or would like to make a suggestion, please go to our Connect Web: https://connect.microsoft.com/site/sitehome.aspx?SiteID=226. After you sign in with your Windows Live ID, click on Feedback. From there, you can choose to file a bug or offer a suggestion for XNA Game Studio Express and/or the XNA Framework.
I'm working on the recording of the component demos and that tutorial. More later!
:)
-
Tommorrow (morning?) the beta for XNA Game Studio Express should be available for you to download!
I'm going to do a video capture of the Gamefest demos I did so you guys can get an idea of what the component model looks like and some of the things you can do. Of course I expect to see way better components over the coming weeks from the community! As mentioned earlier I'll also post a tutorial walking you through creating a component that displays the frame rate for your game. Just drop it onto your game and you're done!
-
So you've all probably heard by now what I've been working on. It's great to finally be able to talk about this stuff. It's really exciting to read the reactions and to see that a lot of people are interested in XNA! Just a few more days and you'll be able to download our beta and start making games!
Last Friday I posted on our team blog details about the XNA Framework. Once we release the beta I'll post some tutorials and samples on my blog, including some GameComponent samples. Stay tuned!
-
The Gamefest website has been updated. You can now register as well as get conference details and agenda. I'll be giving the Creating Games with the XNA Framework talk. It should be an exciting session with a deep dive into the XNA Framework and lots of demos and code!
-
The Microsoft Gamefest website is up. Not a lot of information at the moment, but you can sign up to get updates as they happen.
-
Tomorrow will be my last day on the Windows SDK team. Monday I join the Xna team as Program Manager for the Xna Framework. I'm really excited about the opportunity and anyone that knows me knows that this is just about the perfect job for me. Working on a platform and tools that will make it easier to create games, especially using .Net. I'll still be posting on this blog, but the topics will change a bit. More later!