Setting 3D audio

hez

01-12-2010 10:44:19

Hi,
I'm new into OgreOggSound and I have 5 intensive months of experience in Ogre3D.
I'm developing an Augmented Reality application with a colleague using Ogre.
My problem is that we need to add 3D sound to make the experience more realistic, but I've been working with that for 8hours with no results.
I found a post with some example lines but i don't get any 3D effect ("plain" sound only).

My scene is something like this:
(tipical AR) One node placed into the marker (what we use to put te scene over the background webcam plane), one 3d object placed over it with animations and simple sounds made with windows' playSound (completely useless, the reason why i'm looking into your project). I've made a dummy object with the robot.mesh wich walks around the other "main" model, and i've made a child for attaching the 3D sound into the "dummy".

I don't really know if i've missed something or i've set the incorrect parameters.
And there's something I don't actually understand: if you attach a sound to a sceneNode and you move around the scene, it should get the distance to the observer (ogre's camera) and do the correspondant calculations for the attenuation of the sound, isn't it?

This is part of my code:

// => in createScene
if (gavilan = mSoundManager->createSound("Gavilan", "Gavilan.wav", false, true, true) )
{
//set 3D properties
gavilan ->setRolloffFactor(2.f);
gavilan ->setReferenceDistance(10.f);
}
//Attenuation algorithm
mSoundManager->setDistanceModel(AL_LINEAR_DISTANCE);

...

soundNode->attachObject(gavilan);

...
// => in frameStarted
//If marker detected
gavilan->play();
//pause if not

...
// => in frameRenderingQueued
// Sound 3D timing
mSoundManager->update(evt.timeSinceLastFrame);


Any clues?
Thanx

chaosavy

01-12-2010 15:36:35

I don't see any OgreOggSound listener in there, however I don't see you initalize the sound manager so maybe you do both somewhere else.

This is how I do it:

ftpCamera->getHeadNode()->attachObject(mSoundManager->getListener());

stickymango

01-12-2010 15:50:09

As above plus ensure sound file is single channel.

hez

03-12-2010 09:24:06

Sorry, I missed the initialization:
/* AUDIO: OGRE OGG SOUND */
// Load plugin
mRoot->loadPlugin("OgreOggSound_d");

// Setup pointer to sound manager
mSoundManager = OgreOggSound::OgreOggSoundManager::getSingletonPtr();
// Init Sound Manager
mSoundManager->init() ;


After that, i've tried the line you gave me, but i can't find getHeadNode() anywhere! It's something that i have to do myself?
in my code: Ogre::Camera * mCamera doesn't have any getHeadNode. I've tried using getParentSceneNode() but i recieve only null.
I think i should get position and orientation and set it to a scenenode ...

What do you mean one channel audio? can't it be stereo?

hez

03-12-2010 10:04:30

I did it!
Thank you both.
I passed camera position and orientation to a sceneNode, and attached the soundManager Listener to it

earNode= mSceneMgr->getRootSceneNode()->createChildSceneNode (Vector3(0,0,0), Quaternion::IDENTITY);
earNode->setPosition(mCamera->getPosition());
earNode->setOrientation(mCamera->getOrientation());
earNode->attachObject(mSoundManager->getListener());


after that, i update it in frameRenderingQueued:
//Update earNode
earNode->setPosition(mCamera->getPosition());
earNode->setOrientation(mCamera->getOrientation());


And finally i tried a mono audio sample. It's working! now when the robot walks behind you, you hear him coming.

Thing to try: i don't know how to manage the parameters. I want to exagerate it a lot! And the distance attenuation too.

I've set the parameters as above. Any suggestions?

Anyway, thank you a lot for this great plugin stickymango and for your help, chaosavy.

stickymango

03-12-2010 10:30:08

No Problem,

some light reading... 3D parameters