[osg-users] osgal with multiple sounds

Joe Lyga jdlyga at gmail.com
Wed Sep 10 13:40:54 PDT 2008


I found a solution!

In the osgAL multiple sounds example's createSound function, the
allocateSource function needs to be called before setPlay instead of after
setPlay.  The allocateSource funciton is important, since it allocates a
hardware soundsource for each sound being added to the scenegraph.

Anyway, here is how the fixed code looks in createSound.  This is at or near
line 386 in osgalmultiple.cpp:

        osg::ref_ptr<osgAL::SoundState> sound_state = new
osgAL::SoundState(file);
        sound_state->setSample(sample.get());
        sound_state->setGain(1.0f);
        sound_state->setReferenceDistance(60);
        sound_state->setRolloffFactor(3);
        sound_state->allocateSource(10);
        sound_state->setPlay(true);
        sound_state->setLooping(true);

The two sounds now play simultaneously, as intended.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080910/00abf48b/attachment-0003.htm>


More information about the osg-users mailing list