Game Development Community

3D audio problem/bug

by Javier Otaegui · in Torque Game Engine · 10/29/2008 (6:32 am) · 2 replies

I've run into a bug-problem in torque's audio system or my own use of it. I'll try to describe it accurately, and the whole testing process I've been through.

The problem'd be best described as: 3D audio source doesn't pan properly.

This is the thing: I have an object, a geyser, and it makes a woosh sound when it goes off. This is some code

datablock AudioDescription(AudioDefaultLooping3d)
{
   volume   = 1.0;
   isLooping= true;

   is3D     = true;
   ReferenceDistance= 3;
   MaxDistance= 35.0;
   type     = $SimAudioType;
};

datablock AudioProfile(CraterSound)
{
   filename    = "~/data/sound/lavaSfx/geiser-agua-lava.wav";
   description = AudioDefaultLooping3d;
   preload = true;
};


function SmallCrater::start(%this, %obj)
{
   [...]
   %obj.soundHandle = alxPlay(CraterSound,%obj.position);

   %this.schedule(%this.pusherDuration, stop, %obj);
}

the thing is that I spot that from some positions, the sound doesn't come from the right side. For example, if I'm standing down the Y axis from the object and looking towards it, that is, the lookat vector would be about (0 -1 0) and the up vector (0 0 1). In this situation, the geyser will sound as if it was coming from behind, and if I turn to the left, so the sound comes from my right, the sound will pan to the left channel.

Actually, the only situation when the sound comes from the right place, is when the lookat is forward in y (0 1 0) or something in that general direction. If I stand like this in front of the geyser, and turn to the sides, the sound keeps coming from the correct side, but if I stand on it's right, looking down the y axis, the sound still comes from the front, and if I turn to the left to look at it, then it comes from the right, as if I was standing in front of it down the y axis.

Basically, it's as if it's always down the positive y from where the camera is standing. The distance/volume factor works fine.

So I go down to the engine code, and I find this:

void alxListenerMatrixF(const MatrixF *transform)
{
   Point3F p1, p2;
   transform->getColumn(3, &p1);
   alListener3f(AL_POSITION, p1.x, p1.y, p1.z);

   transform->getColumn(2, &p1);    // Up Vector
   transform->getColumn(1, &p2);    // Forward Vector

   F32 orientation[6];
   orientation[0] = -p1.x;
   orientation[1] = -p1.y;
   orientation[2] = -p1.z;
   orientation[3] = p2.x;
   orientation[4] = p2.y;
   orientation[5] = p2.z;

   alListenerfv(AL_ORIENTATION, orientation);
}

This is weird per se. The AL specification says that alListenerfv(AL_ORIENTATION,...) takes the forward vector first and the up vector afterwards. transform there is the matrix as returned from GameGetCameraTransform() so the comments are right.. so I wonder why oh why are they the wrong way around, and why oh why is the supposed up vector negated? So I start tweaking.

I took out the negation, and I turned around the vectors. Neither gave results. I mean, the sound DID change, but instead of sounding right when I'm towards -y from the object, it sounded right when I was towards +y, or towards +x. Another weird thing is that I had expected that if I interchanged the up and forward vectors of the listener, then panning the camera up and down would give a right-left panning effect, but it didn't do that either.

So, anyone has run into this? am I doing something utterly wrong? is this an OpenAL bug? or what the heck is going on here?

Thanks

#1
10/29/2008 (9:19 am)
Nevermind.. apparently it's an issue on my computer =(
#2
09/04/2009 (8:20 pm)
I think I'm experiencing the exact same problems you described on my own computer. What was the problem? A driver issue or something??? :-/