[SOLVED] stop sound completely after some distance
I have this code
OgreOggSound::OgreOggISound* forkLiftSound = mSoundMngr->createSound("FORKLIFT_SOUND", "FORKLIFT.wav", false, true);
The code works fine. But I do not know how to stop this sound completely after some distance. setMaxDistance does not works as i expected. Lets say I have to stop sound after distance of 30. But setMaxDistance(30) does not do this?. I can notice a sound level reduction when I move away from the object but at very long distace still i hear this sound at very low volume. How to stop this?
The easiest way is to use the linear distance model, otherwise you'll have to experiment with the max distance / roll off factor / reference distance values. The max distance value merely specifies the distance at which attenuation is no longer applied therefore the current volume at that point will remain no matter how far away you get...
See here: http://msdn.microsoft.com/en-us/library/bb318697%28VS.85%29.aspx
hmmm... I can understand. That article is really useful. Thank you
And sticky I have done that experiment.
This is it
the rollofffactor make troubles. It has to be 1. If it 1.01 problem, if it 0.99 again problem Do not know why. But above is fine for my application.
Any way what is that linear model. I have searched all methods and forum. none found.
OpenAL has several algorithms for calculating attenuation, the default is AL_INVERSE_DISTANCE_CLAMPED. You can set another algorithm using OgreOggSoundManager::setDistanceModel() and pass AL_LINEAR_DISTANCE to use linear attenuation, this should fade the volume to min at maxDistance.
See the OpenAL programmers guide.pdf file for details..
Sorry for late reply. I was bit busy.
You can set another algorithm using OgreOggSoundManager::setDistanceModel() and pass AL_LINEAR_DISTANCE to use linear attenuation, this should fade the volume to min at maxDistance.
That is good. Otherwise I have to adjust all the sounds in my project.
Is the final answer for my question
Thank you again stickymango
first off thank you very much, I was able to install and get sound up and running. However I can't get past the same issue as the original poster (I hear the sound however it never falls silent).
mSoundManager->setDistanceModel(AL_LINEAR_DISTANCE); //Sounds become quiet after max distance
I'm using the linear model and tweaking the sound options but still no help, another post said to be sure to use stereo sounds so I tried to download some with no effect. I'm not sure if the code is the issue or if its the sound file. I tried using the 6chan.ogg file from the demo and the issue is the same, not sure where my problem is.
another post said to be sure to use stereo sounds
another post said to be sure NOT to use stereo sounds
according to sticky
Stereo sounds cannot be positioned in 3D space, if you want spatialisation you MUST use MONO sounds only, open it in Sound recorder and try to change the properties, it will tell you its current properties...
thanks, after a bit more searching (using your quote of sticky's about stereo versus mono) I found that the line below solved my problem, it works now. Yay! I thank you and my wife thanks you (less annoying sounds now).
Glad its sorted, although I have to admit I've found "Generic Software" to be the most reliable option when setting up 3d sounds, quite often it seems hardware implementations differ wildly in their final output. I use software by default in the majority of cases, and as there seems to be no noticeable performance difference, it seems a safer option.