Jump to content
  • Advertisement
Sign in to follow this  
Stephane DAVID

Programming Sound in XNA

This topic is 3746 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Now that my graphic engine (based on XNA) is almost working, I'd like to add the sound... But I have a problem. My game is based on an editor that allows scenarios makers to easily add resources (like unit animation) to the game, from simple and standatd formats (png files in the case of graphics). For the sounds, I wantto use wav files, with a small tool to help synchronizing them with the graphics (ex: display a unit animation, and then say "start the explosion.wav at frame 3). But apparently, XNA doesn't support wav file directly, it is necessary to go through XACT. So I have some questions: - Is XACT easy to install and use by a scenario maker (ie someone without programming knowledge?) - Is there a way to use wav files directly in XNA? - Is there another recommended solution to use sounds in C#? My constraints are: - Being able to play sounds from files in a resource folder - Being able to play music in the background - Being able to play several sound effects at the same time, and possibly the same one (ie two units are running, I want to be able to play the "run.wav" file twice, with desynchronization). I have never programmed sounds yet, so any advice is welcomed.

Share this post


Link to post
Share on other sites
Advertisement

To answer your questions in order:


  • Installing shouldn't be a problem, but sharing and working on large wavebanks may be a bit of a challenge

  • In 3.0 you can reportedly just drop wavs into your content folder and they'll automatically get built into a XACT wavebank. It might be worth considering moving to 3.0, but if there are any breaking changes I doubt it's worth the effort.

  • For XNA, XACT is recommended since it's probably the only thing that will work on a 360. Other alternatives would be to use System.Media.SoundPlayer, grab the DirectSound assembly in MDX from an older DirectX SDK or see what SlimDX has to offer. All these alternatives should fit your constraints I think.

Share this post


Link to post
Share on other sites
Thanks for the answer.

Quote:
Original post by remigius
  • In 3.0 you can reportedly just drop wavs into your content folder and they'll automatically get built into a XACT wavebank. It might be worth considering moving to 3.0, but if there are any breaking changes I doubt it's worth the effort.

  • Does it work at run time, or at compile time? I need it at run time.

    Quote:
    Original post by remigius
  • For XNA, XACT is recommended since it's probably the only thing that will work on a 360.

  • I don't plan to make something for 360 ever, so not a big issue.

    Quote:
    Original post by remigius
    Other alternatives would be to use System.Media.SoundPlayer, grab the DirectSound assembly in MDX from an older DirectX SDK or see what SlimDX has to offer. All these alternatives should fit your constraints I think.

    Using DirectSound was one of my possible solution.



    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by Stephane DAVID
    Does it work at run time, or at compile time? I need it at run time.


    I haven't worked with 3.0 myself yet, but IIRC it construct the wavebank at compile time. As I understand, it's basically just a usability improvement to save people the trouble of creating the wavebank through XACT. Please correct me if I'm wrong though.

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by remigius
    Quote:
    Original post by Stephane DAVID
    Does it work at run time, or at compile time? I need it at run time.


    I haven't worked with 3.0 myself yet, but IIRC it construct the wavebank at compile time. As I understand, it's basically just a usability improvement to save people the trouble of creating the wavebank through XACT. Please correct me if I'm wrong though.


    No, you're right. If you wanted to do this at runtime it would require using the Content Pipeline classes, which are only available on machines that have the full XNA SDK installed. This probably isn't a problem for a map editor, though.

    As for XACT being easy to use by non-programmers...I have no idea since I've never used it, but AFAIK the GUI app is designed to be used by audio designers so I'd think it wouldn't be too hard to work with. If you don't want to go through XACT and you're not worried about the XBOX, you might want to check out FMOD. It's a great sound library (free for non-commercial use) that can handle things like streaming music playback and decoding of compressed formats, and it has a managed wrapper making it easy to use from C#.

    Share this post


    Link to post
    Share on other sites
    Sign in to follow this  

    • Advertisement
    ×

    Important Information

    By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

    We are the game development community.

    Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

    Sign me up!