3d sounds sometimes not playing?
by Doyoon Kim · in Torque Game Engine · 10/14/2001 (5:42 pm) · 7 replies
I tried adding sounds to the weapons using statesound, but I noticed that the 3d sounds don't play sometimes.
Anyways, I tracked down the problem to the approximate3DVolume() function called from alxCreateSource(). The
alGetListener3f(AL_POSITION, &p1.x, &p1.y, &p1.z);
for some reason, returns 0 0 0 for p1 xyz sometimes causing the distance calculation to be way off making the volume 0.
So, if I set the orientation of the listener right before calling approximate3dVolume like:
connection->getControlCameraTransform(0, mat);
alxListenerMatrixF(&mat);
volume *= approximate3DVolume(desc, position);
it works. I'm not sure why it wouldn't work since the listener orientation is set in clientprocess, and I've never used openal before so maybe there is another way to fix this.
Anyways, I tracked down the problem to the approximate3DVolume() function called from alxCreateSource(). The
alGetListener3f(AL_POSITION, &p1.x, &p1.y, &p1.z);
for some reason, returns 0 0 0 for p1 xyz sometimes causing the distance calculation to be way off making the volume 0.
So, if I set the orientation of the listener right before calling approximate3dVolume like:
connection->getControlCameraTransform(0, mat);
alxListenerMatrixF(&mat);
volume *= approximate3DVolume(desc, position);
it works. I'm not sure why it wouldn't work since the listener orientation is set in clientprocess, and I've never used openal before so maybe there is another way to fix this.
#2
Other than that: thanks for the great 3D sound implementation in the new release, guys! :)
10/16/2001 (7:41 pm)
Found it. AmbientAudioManager::updateEnvironment() does thisPoint3F pos; alxListenerPoint3F(AL_POSITION, &pos);which I believe is supposed to be
alxGetListenerPoint3F(AL_POSITION, &pos);Doing the strange Set with an uninitialized pos messes up the listener position. I guess it's supposed to be a Get for the follwing waterblock submerge check. That way it works, anyway.
Other than that: thanks for the great 3D sound implementation in the new release, guys! :)
#3
10/17/2001 (7:23 am)
Checked in the fix, at least that looked like a bug to me. Thanks for finding that Matthes :) Doyoon, did that clear up your problem?
#4
I just updated that checkin and the AudioDefault3d is now working to some degree.
It gives me a sound everytime I fire the wepon but its still acting a little odd.
Its getting louder when I shoot straight up in the air.
// Clocks out.
10/17/2001 (7:50 am)
@TimI just updated that checkin and the AudioDefault3d is now working to some degree.
It gives me a sound everytime I fire the wepon but its still acting a little odd.
Its getting louder when I shoot straight up in the air.
// Clocks out.
#5
Also I noticed sounds seem to be backwards. For example, if you hear a sound directly in front of you, it will sound muffled. But if you turn away, the sound will sound clear and louder. It looks like the orientation of the listener got mixed up in alxListenerMatrixF().
This:
orientation[0] = p1.x;
orientation[1] = p1.y;
orientation[2] = p1.z;
orientation[3] = -p2.x;
orientation[4] = -p2.y;
orientation[5] = -p2.z;
should be changed to this:
orientation[0] = -p1.x;
orientation[1] = -p1.y;
orientation[2] = -p1.z;
orientation[3] = p2.x;
orientation[4] = p2.y;
orientation[5] = p2.z;
10/17/2001 (1:50 pm)
Yup, that's it right there. Thanks. Should've noticed the warning message it gave off too. heh.Also I noticed sounds seem to be backwards. For example, if you hear a sound directly in front of you, it will sound muffled. But if you turn away, the sound will sound clear and louder. It looks like the orientation of the listener got mixed up in alxListenerMatrixF().
This:
orientation[0] = p1.x;
orientation[1] = p1.y;
orientation[2] = p1.z;
orientation[3] = -p2.x;
orientation[4] = -p2.y;
orientation[5] = -p2.z;
should be changed to this:
orientation[0] = -p1.x;
orientation[1] = -p1.y;
orientation[2] = -p1.z;
orientation[3] = p2.x;
orientation[4] = p2.y;
orientation[5] = p2.z;
#6
// Clocks out.
10/17/2001 (1:53 pm)
That would also explain why the sound is louder when you look straight up, since you will be hearing a mix of the sound in front off- and behind you.// Clocks out.
#7
10/17/2001 (2:44 pm)
Ok, integrated the orientation fix as well. Thanks Doyoon :) Rick's gone for a few days, so were on our as far as audio goes.
Torque Owner Tim Gift