Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your feedback on a survey! Each completed response supports our community and gives you a chance to win a $25 Amazon gift card!


Using XAudio2


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 Medo3337   Members   -  Reputation: 680

Like
0Likes
Like

Posted 29 March 2013 - 10:58 AM

I'm trying to use XAudio2

 

The idea I got is that I should have the following in XAudio2:

- Listener

- SourceVoice

 

In FPS game, "Listener" should be the player, while "SourceVoice" can be any other model making sound.

 

Am I right?

 

How do I setup multiple SourceVoice and play them all during the game? If a helicopter is getting close, the player should hear it, at the same time if the player is taking fire, the player should hear the sound of the bullet hitting the wall for example at the same time.

 

The player should hear EVERYTHING around at the same time.



Sponsor:

#2 turnpast   Members   -  Reputation: 928

Like
0Likes
Like

Posted 01 April 2013 - 04:23 PM

The idea I got is that I should have the following in XAudio2:
- Listener
- SourceVoice
In FPS game, "Listener" should be the player, while "SourceVoice" can be any other model making sound.
Am I right?

Sort of, but not really. As much as we might want XAudio2 to be a nice object oriented library it is simply not the case. You can set up multiple source voices to play multiple sounds simultaneously, but there is no intrinsic relationship between source voices and 3D positioning. It is probably better to think of SourceVoices as very basic PCM streams. The Listener and the Emitter are not really objects in a modern stateful sense, but collections of parameters that are passed to X3DAudio's X3DAudioCalculate method.

How do I setup multiple SourceVoice and play them all during the game? If a helicopter is getting close, the player should hear it, at the same time if the player is taking fire, the player should hear the sound of the bullet hitting the wall for example at the same time.

The player should hear EVERYTHING around at the same time.


This example shows how to setup simple 3D audio in XAudio2: http://msdn.microsoft.com/en-us/library/windows/desktop/ee415798%28v=vs.85%29.aspx
It is a serious PITA to get right. XAudio2 is quirky and in a lot of ways half-baked. If this is your first time working with 3d audio you might want to start with a higher-level library (I have heard FMOD is solid though not free, BASS is fine, but is just wrapping the older DirectSound apis).
Hope this helps.

#3 Krohm   Crossbones+   -  Reputation: 3261

Like
0Likes
Like

Posted 03 April 2013 - 04:27 AM

I'm not sure about OP's notion of "at the same time" but I'll try.

The whole deal about XAudio2 is that we should connect the various sources to a tree-like structures.

There are three kinds of voices.

  • Source voices are used to model sound emitters, those are connected to
  • Submix voices. They "blend" the various sources together. Nice submix voices I have in my systems are "music", "fx", "voice", "think". I use them for volume control.
  • Mastering voice. It's "the output".

MSDN Xaudio2 voices.

 

Once this tree is built, we don't play "the voices". We tick this tree instead, XAudio2 evolves the whole tree for us and active voices evolve their state accordinlgy. So what do we call to tick XAudio2?

Nothing! It does it everything by itself on its own thread.

This is nice and cool but being asyncronous, this implies your voices, supposed to be syncronized could start in different engine ticks. To solve this issues, look in "operation groups" and dispatch them using CommitChanges.


Edited by Krohm, 03 April 2013 - 04:27 AM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS