OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

osgAudio Sound Position


 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [3rdparty]
View previous topic :: View next topic  
Author Message
mcindafizzy
User


Joined: 24 Sep 2010
Posts: 27

PostPosted: Tue Oct 26, 2010 5:17 pm    Post subject:
osgAudio Sound Position
Reply with quote

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]
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Tue Oct 26, 2010 5:45 pm    Post subject:
osgAudio Sound Position
Reply with quote

On 10/26/2010 11:17 AM, Matt Caron wrote:
Quote:
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:

First question -- do the demos work ok? I thought there was a demo that did moving sound
that ought to confirm this.

--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen


------------------
Post generated by Mail2Forum
Back to top
mcindafizzy
User


Joined: 24 Sep 2010
Posts: 27

PostPosted: Tue Oct 26, 2010 5:56 pm    Post subject:
Reply with quote

The demos work fine - I have tried the occlusion demo and it seems to be working for both sound intensity and doppler shift...
Back to top
View user's profile Send private message
Chris 'Xenon' Hanson
Guest





PostPosted: Tue Oct 26, 2010 6:13 pm    Post subject:
osgAudio Sound Position
Reply with quote

On 10/26/2010 11:56 AM, Matt Caron wrote:
Quote:
The demos work fine - I have tried the occlusion demo and it seems to be working for both sound intensity and doppler shift...

Can you start with that and modify it incrementally to be what you want and make sure it
works at each step? I can't immediately spot problems in your code, but I don't really
have the time to compile it and mess with it.

--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen


------------------
Post generated by Mail2Forum
Back to top
Chris 'Xenon' Hanson
Guest





PostPosted: Wed Oct 27, 2010 1:57 pm    Post subject:
osgAudio Sound Position
Reply with quote

On 10/26/2010 12:13 PM, Chris 'Xenon' Hanson wrote:
Quote:
On 10/26/2010 11:56 AM, Matt Caron wrote:
Quote:
The demos work fine - I have tried the occlusion demo and it seems to be working for both sound intensity and doppler shift...
Can you start with that and modify it incrementally to be what you want and make sure it
works at each step? I can't immediately spot problems in your code, but I don't really
have the time to compile it and mess with it.

Also, consider using the osgAudio list itself.

--
Chris 'Xenon' Hanson, omo sanza lettere. http://www.alphapixel.com/
Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting.
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen


------------------
Post generated by Mail2Forum
Back to top
Samppa2005
Newbie


Joined: 12 Apr 2011
Posts: 6

PostPosted: Mon May 30, 2011 10:11 am    Post subject:
Reply with quote

Hi,


Did you make sure your audio source is mono? If the file is in stereo format OpenAL won't use it as a positional sound.

Cheers,
Sami
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General [3rdparty] All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts How do I continuously read the mouse ... kornerr General 9 Wed Feb 06, 2019 2:02 pm View latest post
No new posts setViewMatrixAsLookAt not working to ... Rodrigo General 4 Tue Jan 08, 2019 2:48 am View latest post
No new posts Absolute final world position matrix ... Steal General 1 Mon Sep 24, 2018 11:25 am View latest post
No new posts How to create a 3D ray from cursor po... Waaayoff General 2 Mon Jul 16, 2018 3:34 pm View latest post
No new posts OSG & QtQuick(QML) & setMirro... karcios General 0 Wed Apr 11, 2018 12:45 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP