Get the latest Education e-news
 

Go Back   Game Career Guide Forums > Programming
Forum Home Register Members List Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 03-23-2009, 10:31 PM   #1
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default What audio content/instance to use with XNA?

I am not sure where to post this, but here!

So, I am at the stage, where I am planning ahead to add sounds to my game. As of now, I just want to learn what all options I have and be ready with the code to integrate it.

I was going through a bunch of tutorials, but from a programmer's perspective, I could not decide what to use and to what extent.

Broadly speaking; here are the effects that I have in mind:
- background in-game sound
- sound effects like whenever a player takes a hit or an enemy fires a bullet.
- (if I can make it happen tho..) I have a enemy unit called frogger. I want the volume to grow as I approach it( some would recognise it as doppler effect), the way u have the noise of flies/ croaking of a frog in a swamp.

The options, that I am aware of are::
- SoundEffectInstance
- MediaPlayer.Play(Song)
- using XACT

The first two options let me use mp3, while XACT only allows wav format.

My concern is: I dont know which one is good from a memory perspective. Both can play the sound..but what would be a better way...are there any memory leaks that I need to think about or what? I am also interested in exploring the intent behind these three ways, as in, are they custom made with something specific in mind.

I would appreciate any suggestions as to what should i go ahead with..

Thanks
brainydexter is offline   Reply With Quote
Old 03-24-2009, 02:43 AM   #2
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
2/11 sssss2255
Location: UK
Default

(Guessing from experience with other APIS)

MediaPlayer is mainly used for background music (ie long tracks that are played in the background) and it should be streaming the music from disk rather then decoding the entire song in one go.

SoundEffectInstance and XACT will decompress all the audio data into a memory ready format so it can played at a moments notice with minimal delay (the audio backend is usually on a separate thread).
yaustar is offline   Reply With Quote
Old 04-03-2009, 03:36 PM   #3
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

Thanks yaustar for the insights. I finally tried it out and it works without much effort. I also see the purpose of each of these constructs..

But, you got me inquisitive there about using a different thread for running sounds. I did google to find out something, but couldn't find a reasonable answer. I am still looking for it, but if you can guide me or provide me some leads which could get me going, that would be great!

Thanks a lot
__________________
Twitter ~ Blog
brainydexter is offline   Reply With Quote
Old 04-04-2009, 07:51 AM   #4
yaustar
Administrator
 
yaustar's Avatar

Activity Longevity
2/20 19/20
Today Posts
2/11 sssss2255
Location: UK
Default

Since you are using XNA, my guess is that the multithreading is done for you so you shouldn't need to do anything beyond what the API supplies you.
yaustar is offline   Reply With Quote
Old 04-05-2009, 01:15 PM   #5
Adrir
Administrator
 
Adrir's Avatar

Activity Longevity
2/20 20/20
Today Posts
0/11 sssss1464
Location: London, UK
Default

Quote:
Originally Posted by yaustar View Post
Since you are using XNA, my guess is that the multithreading is done for you so you shouldn't need to do anything beyond what the API supplies you.
If you find that it doesn't then using threads is really easy in C# anyway.
__________________
Michael 'Adrir' Scott :: Games, Virtual Worlds, Education
Networking | Current Project | Research | Teaching
Adrir is offline   Reply With Quote
Old 04-05-2009, 07:41 PM   #6
brainydexter
Member

Activity Longevity
0/20 16/20
Today Posts
0/11 sssssss77
Location: N. America
Default

After trying out a few things and more googling, I came to this conclusion that XACT should be used as much as possible, since it compresses for you, thereby reducing the load-time. Well, that limits me to .wav files, but I think its worth it. Xact also provides a lot of configuration options. Not familiar with a lot of sound editing utilities, I dint delve much into it. But, I see using Xact is the preferred way to go.

Also, I am still trying to find out about multi-threading and xact. I know multi-threading from java, and am familiar with the concepts. Actually, this makes me want even more to try it out in my game

If I dont find anything, I will try to post a scheme, on my own, for the same and would really appreciate if you guys can comment on that also.

Thanks
__________________
Twitter ~ Blog
brainydexter is offline   Reply With Quote
Old 04-06-2009, 05:29 AM   #7
Gshonk
Moderator

Activity Longevity
0/20 20/20
Today Posts
0/11 ssssss831
Location: Philadelphia, PA
Default

Quote:
Originally Posted by brainydexter View Post
But, I see using Xact is the preferred way to go.
Yup Xact is preferred way for XNA for sure.
__________________
Grant Shonkwiler()
"I would love to fix the world if someone would just give me the source code"
Website Industry blog LinkedIn
Gshonk is offline   Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Powered by vBulletin® Version 3.6.9
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
All times are GMT -8. The time now is 06:46 AM.






UBM Tech