I'm getting IndexOutOfRange exception on the "engine.Calculate3DAudio(listener, emitter)" line below. Anyone managed to do anything like this I want my sound to come from a particular point. I understand with my code below that as theplayer moves, the listener isn't updating position (so sounds already started will be wrong), but I need to get the sound playing first!
public
class Sound{
private static AudioEngine engine; private static WaveBank wavebank; private static SoundBank soundbank; private static Audio3DEmitter emitter; private static Audio3DListener listener; public static Cue Play(string name, Vector3 playerLocation, Vector3 soundLocation){
// Set sound location, and where to listen for itemitter.Position = soundLocation;
listener.Position = playerLocation;
Audio3DDspSettings settings = engine.Calculate3DAudio(listener, emitter); Cue returnValue = soundbank.GetCue(name);engine.Apply3DAudio(returnValue, settings);
returnValue.Play();
return returnValue;}
public static void Stop(Cue cue){
cue.Stop(
AudioStopOptions.Immediate);}
/// <summary> /// Starts up the sound code /// </summary> public static void Initialize(){
engine =
new AudioEngine("Sounds\\Beeth5th.xgs");wavebank =
new WaveBank(engine, "Sounds\\Wave Bank.xwb");soundbank =
new SoundBank(engine, "Sounds\\Sound Bank.xsb");emitter =
new Audio3DEmitter();listener =
new Audio3DListener();}
public static void Update() // Added{
engine.Update();
}
/// <summary> /// Shuts down the sound code tidily /// </summary> public static void Shutdown(){
soundbank.Dispose();
wavebank.Dispose();
engine.Dispose();
}
}

Struggling with 3D sound - Anyone got this working?
Stefan Gabriel Georgescu
This fixed it:
emitter.ChannelCount = 2;
Setting it to 1 still gives the error, so not sure exactly what I'm supposed to set it to!
Moving away from my sound source doesn't seem to change the volume (I've changed my Update() method to take the player location), though :(
I'm just adding a way to update the listener.Forward vector, so I can see if left/right channels make any difference!
ChrisVienna
Chibi-Acer
Bump
Ayman Osman
Laurence Hunter
Bill Reiss
I have been trying to get 3D sound working recently but the problem I am experiencing is that Calculate3DAudio() always returns exactly the same object (I have checked in debugging, and the internal values are exactly the same), regardless of the positions of my listener and emitter. Therefore, I get no change in sound volume or balance, as my camera viewpoint changes location.
My code is included below; Is there an additional property that I am overlooking, that needs to be set for this to work
Audio3DListener listener = new Audio3DListener();listener.Position =
new Vector3(x, y, z);listener.Up =
Vector3.Up;listener.Forward =
Vector3.Forward;
Audio3DEmitter emitter = new Audio3DEmitter();emitter.Position =
new Vector3(0f, 0.5f, 0.5f);emitter.Up =
Vector3.Up;emitter.Forward =
Vector3.Forward;emitter.ChannelCount = 2;
emitter.ChannelRadius = 10f;
Audio3DDspSettings settings = m_AudioEngine.Calculate3DAudio(listener, emitter);m_AudioEngine.Apply3DAudio(cue, settings);
cue.Play();
BigOldSofty
Well, after playing with some stuff in XACT, I can get this to work properly by setting the variable myself, eg:
if (cue != null)
cue.SetVariable("Distance", thirdPersonCamera1.PlayerLocation.Y * 5);
But to me this looks like the whole point of having Location stuff on the emitter/listener is to do this for us. I could set the distance variable (which is mapped to a colume line/curve in XACT) without using any of the emitter/listener stuff. And of course, this still doesn't support fading between left and right (only volume with distance), so that would involve some mad calculations to work out direction, etc. that I'm sure we shouldn't need to do :(
Anyone know anything about this
J. Ho
3D sound is matricial surround system is not true multichanel system.. but work 2 chanels !!!.
..test your code with headphones!!!..
Current XNA beta don't support 5.1 chanel!!! !!
the final XNA cand do only Matricial Surround
About XACT but :
( the XACT creators know nothing about XNA == XNA creators do not know anything on XACT )
Good luck!
roisaonua
Ok, thanks for the feedback.
If it's of any help, it seems that changes in the Listener aren't properly accounted for. I tried modifying the Emitter position instead of the Listener, and the output from Calculate3DAudio() did actually change. At a glance, it seems that regardless of what Listener you feed into the function, it is treated as though a Listener with position (0,0,0) is used.
Paul Carruthers
Ejele012
Surely the listener is very common in 3D audio in pocicion (0.0.0) and the emitter moves. But the test show me that the volume matrix tends to be unitary and for that reason the sound objects seemed to be static (1°Bug) . For the Calculate3DAudio () it is important to enter some data on the amount of channels of exit available and this cannot be read well in XNA-XACT (but possible with MDX 1,0) (2° Bug) . Without these ingredients nothing can be done and apparently the best thing is to hope to than they fix the Bug.
^^ It is possible that this XNA BETA the SOUND 3D Does not work suitably. ! ! X_X
macupryk
Final test
dedicate my time to this answer so that also I have interest..
Conclusions:
1. Cue does not change make their ....matrix
Audio3DDspSettings settings = m_AudioEngine.Calculate3DAudio (to listener, to emitter);
It calculated the same matrix without mattering as they are the vectors that enter or if it modifies the parameters of the emitter and listening
surely there are other parameters but without volume matrix it did not notice the change in the position of the sound source...
provicional solution:
to assign the matrices manually
SrcChannelCount × DstChannelCount
For 2 chanels
Output Lef Input Right Input
Left 1 (leve) 0
Right 0 1(level)
Example:
float[] matrix = new float[4] { x, xy, y, yx };
MyCue.SetMatrixCoefficients(2, 2, matrix);
This dirty work is of XACT but it still does not make it well and not be the reason !!
2. AudioSpeakers e = Engine.Speakers; //it always gives stereo
" I have problems with the values of the mixture matrix and I have not found the form to know as the present configuration of sound in XACT - XNA"
Provicional solution: XNA o XACT team fix the bug
3. I that is single so that we do not have an official example and we are in an absurd problem!! ^_^
Good Louk!!
MojoRising