Game Development Community

Getting Sound..

by Will O-Reagan · in Torque X 2D · 02/24/2007 (7:30 pm) · 15 replies

Ok, so whats the best way to get sound into the game in TorqueX? Keep in mind, I have no idea how it is done in TankBuster or SpaceShooter, even though i have read it over extensively..

About the author

I have a degree in dramatic art, and literature, from UC Santa Barbara. I've worked for a few studios, also at Animax Ent in 2008, and some smaller studios. Currently studying Computer Science at CSU Channel Islands.


#1
02/25/2007 (5:43 am)
One acronym: XACT. It's been cursed by everyone I've ever met who's used it, but there's no other way to get sound into an XNA game. The truth is that once you get used to the interface, It's actually not so bad to work with. The trouble is that it takes a hell of a lot of restraint to get used to in the first place (without smashing your hardware, that is). Look through the MSDN XACT docs first and try to familiarize yourself with the tool. If you come into the process with any amount of sound assets you will most likely want to recreate your sound banks, so try to enter the process in a 'student' mindset with the attitude that you will redo everything properly once you understand how it works. The one upshot of working with XACT is that you will without a doubt gain some understanding or respect for software with well crafted user interfaces.

I wish there were a better answer, but unfortunately there isn't. If in familiarizing yourself with the XACT system you find yourself asking the question "why can't I just play this sound when I want to.. why do I need X banks at all?" just know that that's the natural reaction to the interface.

Sorry if this sounds a little negative, but XACT has been the cause of many hair-pulling moments for me personally, and when I've looked to my seniors (in terms of XBox programming exp) for advice with XACT they typically suffer what could be compared to a Vietnam flashback.

That said, don't fear XACT, just be prepared for an unpleasant experience. It's definitely something that most people should be able to tackle and harness.
#2
02/25/2007 (8:03 am)
Great! I found the software. I have no idea what I am in for, this should be interesting.
#3
02/25/2007 (8:07 am)
I just read the XACT Docs on Wikipedia and MSDN, at a gance. Thats exactly what I was looking for, thanks!
#4
02/25/2007 (7:45 pm)
I just got sound into my game!! TGBX open Forums are awesome.. hopefully this thread helps somebody!!
#5
02/25/2007 (8:06 pm)
No problem. Good luck! :)
#6
02/26/2007 (12:41 pm)
Can't you just use .net to play sounds? I don't think you are limited to XACT.

www.publicjoe.f9.co.uk/csharp/csharp17.html

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#7
02/26/2007 (1:10 pm)
Will that work on the Xbox?
#8
02/26/2007 (4:31 pm)
Not sure if it will work on the xbox, but we windows developers are more important anyway *ducks*

www.linkedin.com/img/webpromo/btn_viewmy_160x25.gif

www.mmogamedev.info/images/imgdc_ad1.gif
#9
04/16/2007 (7:17 pm)
My sound effects seem to be working ok, but when I try to play music (background music during the menu screens, for example) it only plays for a quick second, then stops. Is there some parameter in XACT that I'm forgetting to set?

Anyone that's gotten music to work ever run into this?
#10
04/16/2007 (8:18 pm)
There is indeed. You need to loop the track. I don't recall what to set off my head and wont be able to look until tomorrow, so hopefully someone will chime in. In the meantime, look at tankbuster as I believe there is an 'enginenoise' type sound which you can check out that plays on a loop.
#11
04/17/2007 (4:04 pm)
OK, I took a look at the "planeEngine" sound in the Tank Buster demo, and I figured out I need to set the LoopEvent parameter to "infinite." It seems like this was the only difference, but the sound file still only plays for a moment.
#12
04/17/2007 (4:41 pm)
How are you starting the sound in code?
#13
04/17/2007 (5:06 pm)
Wooo...I found it. In the interest of saving someone time in the future, here's what happened...I have a Sound class that handles the starting and stopping of my various sound files, with this Play function:
public static Cue Play(string name)
{
    Cue returnValue = soundbank.GetCue(name);
    returnValue.Play();
    return returnValue;
}

which I was mistakenly calling without saving the Cue that was returned, like so:
Sound.Play("menumusic");

When I changed it to this:
Cue _menuMusic = Sound.Play("menumusic");
everything worked itself out. I don't know how I planned to stop the music from playing without doing that, but that issue never presented itself since the music would just stop on its own immediately.

And for anyone just starting with sound in XNA, here's the tutorial I used. It'll walk you through it:
xbox360homebrew.com/blogs/audio/archive/2006/09/01/119.aspx

Edit: Thanks for the help Jonathan.
#14
10/21/2007 (3:54 am)
Thanks Tracey that tutorial helped me out allot!

Incidentally there was a comment about changing the Play Method to this:

public static void Play(string name)
{
soundbank.PlayCue(name);
}

Which seemed to resolve some of my sounds cutting each other off.

To stop the sound I would image you could simply do this:

Cue cueName = soundbank.GetCue(name);
cueName.Stop();
#15
10/21/2007 (5:32 am)
Thanks Tracey that tutorial helped me out allot!

Incidentally there was a comment about changing the Play Method to this:

public static void Play(string name)
{
soundbank.PlayCue(name);
}

Which seemed to resolve some of my sounds cutting each other off.

To stop the sound I would image you could simply do this:

Cue cueName = soundbank.GetCue(name);
cueName.Stop();