Greetings, I am trying to hack together the simplest example possible of sound intensity changing by distance from the sound source with osgAudio. From the example source code I have hacked together the following commands:
Code: osgAudio::SoundManager::instance()->init(32); osgAudio::SoundManager::instance()->getEnvironment()->setGain(0.5); osgAudio::SoundManager::instance()->getEnvironment()->setDistanceModel(osgAudio::InverseDistance); osgAudio::SoundManager::instance()->getEnvironment()->setDopplerFactor(1); osgAudio::SoundState *musicSoundState;// = osgAudio::SoundManager::instance()->findSoundState("music"); musicSoundState = new osgAudio::SoundState("music"); // ALlocate a hw source so we can loop it musicSoundState->allocateSource( 10 ); // Create a new filestream that streams samples from a ogg-file. osgAudio::FileStream *musicStream = new osgAudio::FileStream("FILEPATH/44100_1chan.ogg"); // Associate the stream with the sound state musicSoundState->setStream( musicStream ); // Loop the sound forever musicSoundState->setLooping( true ); musicSoundState->setRelative(true); musicSoundState->setPosition(osg::Vec3(0,0,0)); musicSoundState->setReferenceDistance(10); musicSoundState->setRolloffFactor(1); // Start playing the music! musicSoundState->setPlay( true ); // Add the soundstate to the sound manager so we can find it later on. osgAudio::SoundManager::instance()->addSoundState( musicSoundState ); //} osgAudio::SoundNode *sound_node = new osgAudio::SoundNode; sound_node->setSoundState(musicSoundState); root->addChild(sound_node); Then later I have Code: osg::ref_ptr<osgAudio::SoundRoot> sound_root = new osgAudio::SoundRoot; viewer->setCameraManipulator(new TrackballManipulator()); sound_root->setCamera( viewer->getCamera() ); However, when I run this the audio sounds ambient. I don't know if the audio is somehow sticking to the camera, or if it is actually running in ambient mode, but distance from (0,0,0) has no effect on sound volume. I have tried setting ambient to false with no affect. Does anyone see where I am going wrong? Thanks. Matt[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=33096#33096 _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org