[SOLVED] Sound doesn't change volume when moving around

Xenomorph

06-10-2009 19:49:38

Hi guys,
I have been messing around with this for a while and can't get it to work properly. I'm attaching the listener to the camera node and attach a sound source to a object. When I move my object around the sound doesn't get updated. Here is my code:
mSoundManager = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
mSoundManager->init();

Now I'm adding it to the camera node
SceneNode *node = mSceneMgr->getRootSceneNode()->createChildSceneNode("camNode1", Vector3(0,0,500));
node->lookAt(Vector3::ZERO, Node::TS_WORLD);
node->attachObject(mCamera);
node->attachObject(mSoundManager->getListener());

Adding the sound to the object
OgreOggSound::OgreOggISound *newSound = OgreOggSound::OgreOggSoundManager::getSingletonPtr()->createSound("testSound", "test2.ogg", true, false, false);
mAvatarNode->attachObject(newSound);
newSound->setMaxDistance(250);
newSound->setReferenceDistance(50);
newSound->play();

And in frameStarted I call the update method
mSoundManager->update(evt.timeSinceLastFrame);
Did I do something wrong or did I miss something?

stickymango

06-10-2009 21:33:06

That all looks okay, does the sound pan at all?

The test demo does this and works fine, however I've had a problem in the past with dodgy drivers causing this issue on a 'Generic Hardware' device, 'Generic Software' always worked, what is the default device being used?

The other obvious thing would be using a stereo sound instead of a mono sound.

I'd guess that using the values you have there you wouldn't get much attenuation, as the reference distance seems quite high and the max distance quite low in comparison, attenuation stops at the max distance value so whatever the current volume value is, it will remain no matter how far away you get. You could change the attenuation model to AL_LINEAR_DISTANCE_CLAMPED as a quick check, this should fade from max volume at 50 units to zero at 250 units.

Other then those things, its just a case of tweaking the various attenuation values, ref distance, max distance, roll-off factor, velocity, cone angles until you find a nice balance.

Xenomorph

06-10-2009 23:48:46

Generic Software is being used. Here is my log file:
16:51:44: *****************************************
16:51:44: *** --- Initialising OgreOggSound --- ***
16:51:44: *** --- OgreOggSound v1.12 --- ***
16:51:44: *****************************************
16:51:44: *** --- OpenAL version 1.1
16:51:44: *** --- AVAILABLE DEVICES --- ***
16:51:44: *** --- Generic Software
16:51:44: *** --- Choosing: Generic Software (Default device)
16:51:44: *** --- OpenAL Device successfully created
16:51:44: *** --- OpenAL Context successfully created
16:51:44: *** --- SUPPORTED FORMATS
16:51:44: *** --- AL_FORMAT_MONO16 -- Monophonic Sound
16:51:44: *** --- AL_FORMAT_STEREO16 -- Stereo Sound
16:51:44: *** --- AL_FORMAT_QUAD16 -- 4 Channel Sound
16:51:44: *** --- AL_FORMAT_51CHN16 -- 5.1 Surround Sound
16:51:44: *** --- AL_FORMAT_61CHN16 -- 6.1 Surround Sound
16:51:44: *** --- AL_FORMAT_71CHN16 -- 7.1 Surround Sound
16:51:44: *** --- EFX Detected
16:51:44: *** --- 1 Auxiliary Effect Slot(s)
16:51:44: *** --- 1 Auxiliary Send(s) per Source
16:51:44: *** --- EFFECTS SUPPORTED:
16:51:44: *** --- 'Reverb' Support: YES
16:51:44: *** --- 'EAX Reverb' Support: YES
16:51:44: *** --- 'Chorus' Support: NO
16:51:44: *** --- 'Distortion' Support: NO
16:51:44: *** --- 'Echo' Support: NO
16:51:44: *** --- 'Flanger' Support: NO
16:51:44: *** --- 'Frequency shifter' Support: NO
16:51:44: *** --- 'Vocal Morpher' Support: NO
16:51:44: *** --- 'Pitch shifter' Support: NO
16:51:44: *** --- 'Ring modulator' Support: NO
16:51:44: *** --- 'Autowah' Support: NO
16:51:44: *** --- 'Compressor' Support: NO
16:51:44: *** --- 'Equalizer' Support: NO
16:51:44: *** --- FILTERS SUPPORTED:
16:51:44: *** --- 'Low Pass' Support: YES
16:51:44: *** --- 'High Pass' Support: NO
16:51:44: *** --- 'Band Pass' Support: NO
16:51:44: *** --- XRAM NOT Detected
16:51:44: *** --- EAX 2.0 Detected
16:51:44: *** --- Created 100 sources for simultaneous sounds
16:51:44: *** --- Using BOOST threads for streaming
16:51:44: *** --- Recording devices available:
16:51:44: ***--- 'Microphone (2- High Definition '
16:51:44: ***--- 'Line In (2- High Definition Aud'
16:51:44: *****************************************
16:51:44: *** --- OgreOggSound Initialised --- ***
16:51:44: *****************************************

The sound doesn't pan at all. I also tried AL_LINEAR_DISTANCE_CLAMPED, but it doesn't change a thing. The sound is playing, but it doesn't matter where I'm at with my object. It's always the same volume.

stickymango

07-10-2009 20:32:29

The sound is mono?

Xenomorph

07-10-2009 22:13:01

The sound seems to be stereo, but I'm not sure how I can check it a 100%. Can you give me a stereo sound track that I could test out. If that's not the problem, what else could it be?

stickymango

07-10-2009 23:18:10

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...

Xenomorph

08-10-2009 06:10:35

That was the problem. Now it is working just fine. Thanks!

stickymango

09-10-2009 17:19:31

Great news! :D