3D Audio Problem
by Daniel Neilsen · in Torque Game Engine · 05/10/2002 (2:59 pm) · 14 replies
I have been looking into a problem I have been finding in the HEAD version where any 3D sound is at full volume until it reaches its maximum distance whereupon it changes to a volume of 0.
This bug is not just in my game but also in another team's game as well.
I have been attempting to debug this problem and have found that alxcreatesource is calculating out the volume correctly but when the code moves into alxSourcePlay it does not seem to work.
The offending line, which I believe should be the line that determines the sound at point t in relation to the source sound, does not seem to be working. Line is:
alSource3f(source, AL_POSITION, p.x, p.y, p.z);
Has anyone got any idea on this bug cause it is really driving me nuts at this point. Any of the employees know anything about this?
This bug is not just in my game but also in another team's game as well.
I have been attempting to debug this problem and have found that alxcreatesource is calculating out the volume correctly but when the code moves into alxSourcePlay it does not seem to work.
The offending line, which I believe should be the line that determines the sound at point t in relation to the source sound, does not seem to be working. Line is:
alSource3f(source, AL_POSITION, p.x, p.y, p.z);
Has anyone got any idea on this bug cause it is really driving me nuts at this point. Any of the employees know anything about this?
About the author
#2
05/11/2002 (2:00 pm)
Anyone?
#3
05/11/2002 (6:41 pm)
Is your .wav file stereo or mono ? It needs to be mono for 3D sound use.
#4
This is what has got me stumped.
The way it is set up it SHOULD work correctly, and it used to work correctly.... but not anymore
05/11/2002 (10:15 pm)
It is a mono wavThis is what has got me stumped.
The way it is set up it SHOULD work correctly, and it used to work correctly.... but not anymore
#5
I have just tried the above in the Dev_Stable vefsion and I am getting exactly the same thing.
I am sure the dev stable version used to work correctly for me before so what have I done wrong guys?
Anyone have any ideas?
Is there some differnet command other than alxplay maybe?
05/12/2002 (2:23 am)
ok...I have just tried the above in the Dev_Stable vefsion and I am getting exactly the same thing.
I am sure the dev stable version used to work correctly for me before so what have I done wrong guys?
Anyone have any ideas?
Is there some differnet command other than alxplay maybe?
#6
I am using %object.playAudio($CloakSound, cloakOff);
The problem is, this function is designed more towards sounds emitted from a moving object or player where $Cloaksound is an integer value corressponding with a "slot" on the player, and cloakOff is a sound profile.
I really wish I could help you, but I think the last time I tried alxplay for 3d sound I got the same problem you had, which is what sent me over to playAudio in the first place.
05/12/2002 (1:44 pm)
Ah I realized why mine was working.I am using %object.playAudio($CloakSound, cloakOff);
The problem is, this function is designed more towards sounds emitted from a moving object or player where $Cloaksound is an integer value corressponding with a "slot" on the player, and cloakOff is a sound profile.
I really wish I could help you, but I think the last time I tried alxplay for 3d sound I got the same problem you had, which is what sent me over to playAudio in the first place.
#7
ie. full volume until the maximum distance is reached...then silence
I am wondering if maybe this is a winxp issue? I have tried 3 different XP computers and get the same problem.
Can someone try this under win2k or win98 please and see if you get this problem?
05/12/2002 (5:40 pm)
I have just tried realm wars and I get exactly the problem with the crossbolt bolt explosion sounds.ie. full volume until the maximum distance is reached...then silence
I am wondering if maybe this is a winxp issue? I have tried 3 different XP computers and get the same problem.
Can someone try this under win2k or win98 please and see if you get this problem?
#9
Info if you got this working would greatly be appreciated. I've been searching for a solution for the past two days :/
07/15/2002 (11:21 pm)
bump.Info if you got this working would greatly be appreciated. I've been searching for a solution for the past two days :/
#10
Anyone else know what might be the best way to solve this?
07/15/2002 (11:43 pm)
I'm not using it for explosions, just things emitted from the player.Anyone else know what might be the best way to solve this?
#11
I think the problem might reside in a moving AND a looping a sound from what I can tell. IE: for some reason a looping sound isn't getting its position changed when its told to.
However, this doesn't explain why explosions don't work because those aren't looping sounds :/
I'm baffled.
07/15/2002 (11:46 pm)
Using playAudio shouldn't work either because it taps into alxPlay, therefore the same problem would exist for it.I think the problem might reside in a moving AND a looping a sound from what I can tell. IE: for some reason a looping sound isn't getting its position changed when its told to.
However, this doesn't explain why explosions don't work because those aren't looping sounds :/
I'm baffled.
#12
07/16/2002 (12:14 am)
I had no problem with moving 3D looping sound for DoP. What are you doing exactly, can you post your code ?
#13
07/16/2002 (9:33 am)
When I was looking through the audio code, I saw that volumes were only getting clamped down to a minimum volume when it hit the edge of the bounding sphere. They were never set to zero. I fixed this in a version I was using though. The only down side was that the sound would pop a bit when you ran back and forth across the sphere boundary. I don't have the code in front of me right now, but I can take a look when I get home and post up what I did.
#14
Well there are bits and pieces within the Projectile code but I'll do my best to post what I'm doing.
Code Below Here is with regards to the ProjectileData class
-----------------------------------------------------
projectile.h
New members variables in the ProjectileData class
projectile.cc
In the ProjectileData constructor
In initPersistFields
In onAdd
In packData
In unpackData
Note that all of these things were added in the correct network order.
Code Below Here is with regards to the Projectile class
-----------------------------------------------------
projectile.h
New member variables in the Projectile class
Changed function declaration
projectile.cc
In the Projectile constructor
In onRemove
In explode
Rewrote updateSound
In interpolateTick
And thats it as far as hardcode goes. I then add
a
to the ProjectileData datablock for the crossbow in crossbow.cs and also add
before it. Also in audioProfiles.cs in fps/server/scripts I add
Now the sound plays and loops like normal until the explosion occurs. What is not normal is, the sound doesn't appear to follow the projectile.. its like its always right next to me. The only thing I can tell that changes is when I turn, the sound appears to move to the right and left speakers appropriately.. but other than that.. :/
07/16/2002 (9:56 am)
Quote:I had no problem with moving 3D looping sound for DoP. What are you doing exactly, can you post your code ?
Well there are bits and pieces within the Projectile code but I'll do my best to post what I'm doing.
Code Below Here is with regards to the ProjectileData class
-----------------------------------------------------
projectile.h
New members variables in the ProjectileData class
AudioProfile* sound; S32 soundId;
projectile.cc
In the ProjectileData constructor
sound = NULL; soundId = 0;
In initPersistFields
addNamedField(sound, TypeAudioProfilePtr, ProjectileData);
In onAdd
if (!sound && soundId != 0) if (Sim::findObject(soundId, sound) == false) Con::errorf(ConsoleLogEntry::General, "ProjectileData::onAdd: Invalid packet, bad datablockId(sound): %d", soundId);
In packData
if (stream->writeFlag(sound != NULL)) stream->writeRangedU32(sound->getId(), DataBlockObjectIdFirst, DataBlockObjectIdLast);
In unpackData
if (stream->readFlag()) soundId = stream->readRangedU32(DataBlockObjectIdFirst, DataBlockObjectIdLast);
Note that all of these things were added in the correct network order.
Code Below Here is with regards to the Projectile class
-----------------------------------------------------
projectile.h
New member variables in the Projectile class
AUDIOHANDLE soundHandle;
Changed function declaration
// void updateSound(Point3F pos, Point3F vel, bool blah); void updateSound();
projectile.cc
In the Projectile constructor
soundHandle = 0;
In onRemove
if(soundHandle)
alxStop(soundHandle);In explode
// commented out // Client object //Point3F noPoint(0,0,0); //updateSound(noPoint, noPoint, false);
Rewrote updateSound
void Projectile::updateSound()
{
if(!mDataBlock->sound)
return;
if(mHidden)
{
if(soundHandle)
{
alxStop(soundHandle);
soundHandle = 0;
}
}
else
{
if(!soundHandle)
{
soundHandle = alxPlay(mDataBlock->sound, &getRenderTransform());
}
alxSourceMatrixF(soundHandle, &getRenderTransform());
}
}In interpolateTick
// changed call to updateSound to reflect no params updateSound();
And thats it as far as hardcode goes. I then add
a
sound = CrossbowProjectileSound;
to the ProjectileData datablock for the crossbow in crossbow.cs and also add
datablock AudioProfile(CrossbowProjectileSound)
{
filename = "~/data/shapes/crossbow/crossbow_projectile";
description = ProjectileLooping3d;
preload = true;
};before it. Also in audioProfiles.cs in fps/server/scripts I add
datablock AudioDescription(ProjectileLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance = 5.0;
MaxDistance= 20.0;
type = $EffectAudioType; // $SimAudioType doesnt work either
environmentLevel = 1.0;
};Now the sound plays and loops like normal until the explosion occurs. What is not normal is, the sound doesn't appear to follow the projectile.. its like its always right next to me. The only thing I can tell that changes is when I turn, the sound appears to move to the right and left speakers appropriately.. but other than that.. :/
Torque Owner Daniel Neilsen
I just checked out a completely raw version of HEAD from the cvs.
I added the following so that I could test sound
datablock AudioProfile(BombExplosionSound) { filename = "~/data/sound/bomb_explosion.wav"; description = AudioDefault3d; preload = true; };and in RifleProjectile::onCollision I added
Once again, the sound is full volume until the max distance and then just disappears....there is no fadeout due to the distance.