Audio Problem
by Daniel Neilsen · in Torque Game Engine · 05/04/2002 (2:29 pm) · 11 replies
Hey guys,
Having a small problem in my game in that my 3D audio sounds are not fading over a distance in the latest HEAD build.
The sounds are mono sounds and the datablocks look like this..
The sound is at 100% volume until I get to the 300 meter mark, then nothing. There is no fade out....
Anyone had the same problem or have any ida of how to get around it?
Having a small problem in my game in that my 3D audio sounds are not fading over a distance in the latest HEAD build.
The sounds are mono sounds and the datablocks look like this..
datablock AudioProfile(BombExplosionSound)
{
filename = "~/data/sound/game/default_Explosion_1.wav";
description = AudioFar3d;
preload = true;
};
datablock AudioDescription(AudioFar3d)
{
volume = 5.0;
isLooping= false;
is3D = true;
referenceDistance = 20.0;
MaxDistance= 300.0;
type = $EffectAudioType;
};The sound is at 100% volume until I get to the 300 meter mark, then nothing. There is no fade out....
Anyone had the same problem or have any ida of how to get around it?
About the author
#2
When I get done with work I'm going to try and trace my sound through the audio system to see if the sound is getting its position changed correctly, if at all.
07/17/2002 (2:23 pm)
Actually I'm having the same problem with projectiles. I've talked a little bit with Tim Gift about it and we are all kind of clueless as to whats happening.When I get done with work I'm going to try and trace my sound through the audio system to see if the sound is getting its position changed correctly, if at all.
#3
I went to the extent of echoing sound locations and determinations of volume modifiers (eg 60%, etc) to the console and all of the calculations were working correctly, but the sound always stayed at 100% volume.
This led me to believe that it was either a hardware or openal driver issue.
07/17/2002 (10:16 pm)
I went nuts with this and in the end gave up.I went to the extent of echoing sound locations and determinations of volume modifiers (eg 60%, etc) to the console and all of the calculations were working correctly, but the sound always stayed at 100% volume.
This led me to believe that it was either a hardware or openal driver issue.
#4
I'm moved my focus over to determining whether the actual volume of those sounds are getting set correctly now.. which I have a hunch that they may not be.
I noticed that in the function approximate3DVolume, it is only getting called once, on the creation of alxPlay or through alxCreateSource. Interesting indeed, but I also noticed that else where the audio is getting updated without this function call, so I'm still kind of confused :/
07/17/2002 (11:04 pm)
Yes, I went through the debugger line by line and all the positions and everything are getting set correctly.I'm moved my focus over to determining whether the actual volume of those sounds are getting set correctly now.. which I have a hunch that they may not be.
I noticed that in the function approximate3DVolume, it is only getting called once, on the creation of alxPlay or through alxCreateSource. Interesting indeed, but I also noticed that else where the audio is getting updated without this function call, so I'm still kind of confused :/
#5
The 3D audio works decently on the notebook, but on the desktop it does exactly what you all describe: the volume remains the same until you reach the MaxDistance point, at which the sound cannot be heard at all. Very strange, since I figured the Creative board would be the one working properly.
With my project due in 2 weeks, I don't have time to do a lot of research on this right now. I am, however, interested in any findings you fellas may come across.
-rob
07/18/2002 (1:17 pm)
There's definitely a hardware/driver issue going on here too. I ran an identical build of my game on two systems, both of which are running Win2K. The first is my Toshiba Satellite notebook with Crystal Audio sound built in, and my desktop with a SoundBlaster Live! (the old model, not 5.1).The 3D audio works decently on the notebook, but on the desktop it does exactly what you all describe: the volume remains the same until you reach the MaxDistance point, at which the sound cannot be heard at all. Very strange, since I figured the Creative board would be the one working properly.
With my project due in 2 weeks, I don't have time to do a lot of research on this right now. I am, however, interested in any findings you fellas may come across.
-rob
#6
01/07/2003 (10:27 pm)
Is there any news on this?
#7
01/07/2003 (11:15 pm)
I posted a temp fix for the looping 3d sounds here www.garagegames.com/index.php?sec=mg&mod=forums&page=result.thread&qt=3852
#8
Just replace the explode() function with this one and add the updateSound below it.
01/08/2003 (2:37 am)
And here is a fix for the explosionsJust replace the explode() function with this one and add the updateSound below it.
bool Explosion::explode()
{
mActive = true;
launchDebris( mInitialNormal );
spawnSubExplosions();
updateSound();
if (bool(mDataBlock->explosionShape) && mDataBlock->explosionAnimation != -1) {
mExplosionInstance = new TSShapeInstance(mDataBlock->explosionShape, true);
mExplosionThread = mExplosionInstance->addThread();
mExplosionInstance->setSequence(mExplosionThread, mDataBlock->explosionAnimation, 0);
mExplosionInstance->setTimeScale(mExplosionThread, mDataBlock->playSpeed);
mCurrMS = 0;
mEndingMS = U32(mExplosionInstance->getScaledDuration(mExplosionThread) * 1000.0f);
mObjScale.convolve(mDataBlock->explosionScale);
mObjBox = mDataBlock->explosionShape->bounds;
resetWorldBox();
}
if (mDataBlock->particleEmitter) {
ParticleEmitter* emitter = new ParticleEmitter;
emitter->setDataBlock(mDataBlock->particleEmitter);
emitter->registerObject();
emitter->emitParticles(mInitialPosition, mInitialNormal, mDataBlock->particleRadius,
Point3F(0, 0, 0), U32(mDataBlock->particleDensity * mFade));
emitter->deleteWhenEmpty();
}
for( int i=0; i<ExplosionData::EC_NUM_EMITTERS; i++ )
{
if( mDataBlock->emitterList[i] != NULL )
{
ParticleEmitter * pEmitter = new ParticleEmitter;
pEmitter->setDataBlock( mDataBlock->emitterList[i] );
if( !pEmitter->registerObject() )
{
Con::warnf( ConsoleLogEntry::General, "Could not register emitter for particle of class: %s", mDataBlock->getName() );
delete pEmitter;
pEmitter = NULL;
}
mEmitterList[i] = pEmitter;
}
}
return true;
}
void Explosion::updateSound()
{
if(mDataBlock->soundProfile)
{
Point3F listener;
alGetListener3f(AL_POSITION, &listener.x, &listener.y, &listener.z);
Point3F pos = mInitialPosition - listener;
F32 dist = pos.magnitudeSafe();
AudioDescription * desc = mDataBlock->soundProfile->mDescriptionObject;
F32 max = desc->getDescription()->mMaxDistance;
F32 min = desc->getDescription()->mReferenceDistance;
F32 vol;
if(dist > max)
vol = 0.0f;
else if(dist > min)
vol = desc->getDescription()->mVolume * (min / dist);
else
vol = desc->getDescription()->mVolume;
F32 level = desc->getDescription()->mVolume * mMasterVolume * vol;
AUDIOHANDLE setup = alxPlay(mDataBlock->soundProfile, &getTransform());
F32 gain = mClampF(vol, 0.0, 1.0);
alxSourcef(setup, AL_GAIN, gain);
}
}Sam
#9
01/08/2003 (3:15 am)
Hey, that's great, thanks!
#10
Note that you have to declade updateSound in the explosion.h file too, as well as F32 mMasterVolume = 1.f; within the updateSound function!
01/08/2003 (10:16 am)
I just dropped this into the latest head, it works like a charm.Note that you have to declade updateSound in the explosion.h file too, as well as F32 mMasterVolume = 1.f; within the updateSound function!
#11
tone
01/08/2003 (11:41 am)
I believe that SB Lives have buggy drivers as to setting the output volume, sometimes. I find that my SB Live system did exactly this with World War II Online (and perhaps other games). 100% was all it knew.tone
Torque Owner Robert Garrett
-rob