[osgaudio-users] Change: SoundRoot init, Listener position

7 views
Skip to first unread message

Paul Martz

unread,
May 10, 2010, 6:31:06 PM5/10/10
to osgaudi...@googlegroups.com
Hi all --

In response to issue 3
http://code.google.com/p/osgaudio/issues/detail?id=3
...there has been a change to how an application should create and init the
SoundRoot node. This affects the Listener position.

SoundRoot now uses an update callback to do the tasks formerly done in cull,
such as process queued sound events and update the Listener position.

Previously, SoundRoot obtained the Camera view matrix from the CullVisitor, and
used it to update the Listener position. This behavior was ill-defined in the
case of multiple views.

Current svn head (as of r42) requires an application to specify a Camera to the
SoundRoot using the setCamera() method. Typically, an app will do this
immediately after creating the SoundRoot, or as soon as the Camera is available
(such as after viewer.realize()), and usually before the first frame. SoundRoot
will then use this Camera's view matrix to determine and update the Listener
position during the update traversal.

If your app has a single view, you would typically specify that view's Camera.

If your app has multiple views, you will need to decide which view you'd like to
use for the Listener position, and specify that view's Camera.

If you don't specify a Camera, SoundRoot will specify the Listener's position as
Vec3( 0, 0, 0 ).

This new paradigm allows the application to specify the Listener position
explicitly. To do this, don't bother setting a Camera in the SoundRoot. Go ahead
and leave this NULL, and the Listener position will be set to the default 0,0,0
during update. Then, after the update traversal, and before cull/draw,
explicitly set the Listener position as follows:

osgAudio::SoundManager::instance()->setListenerMatrix( m );

The osg::Matrix 'm' is a view matrix representing the Listener's position and
orientation.

Possible modification: Not sure about this, but perhaps it's wrong for the
SoundRoot to set the Listener position to 0,0,0 every frame (when the Camera is
NULL). After all, this prevents an application from setting the Listener
position just once and leaving it there. So, we might want to consider changing
SoundRoot to not modify the Listener position at all if the Camera is NULL.

What do you think? Feedback appreciated.

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

--
You received this message because you are subscribed to the Google Groups "osgAudio-users" group.
To post to this group, send email to osgaudi...@googlegroups.com.
To unsubscribe from this group, send email to osgaudio-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/osgaudio-users?hl=en.

Chris 'Xenon' Hanson

unread,
May 11, 2010, 3:15:47 PM5/11/10
to osgaudi...@googlegroups.com
On 5/10/2010 4:31 PM, Paul Martz wrote:
> Previously, SoundRoot obtained the Camera view matrix from the
> CullVisitor, and used it to update the Listener position. This behavior
> was ill-defined in the case of multiple views.
>
> What do you think? Feedback appreciated.

I think this is a good and necessary change. We'll need to make it prominently known
that this is different from osgAL in the porting notes, and make sure any current osgAudio
people know to make this change otherwise their positional audio will stop positioning,
correct?

--
Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen

Paul Martz

unread,
May 11, 2010, 3:50:44 PM5/11/10
to osgaudi...@googlegroups.com
Chris 'Xenon' Hanson wrote:
> On 5/10/2010 4:31 PM, Paul Martz wrote:
>> Previously, SoundRoot obtained the Camera view matrix from the
>> CullVisitor, and used it to update the Listener position. This behavior
>> was ill-defined in the case of multiple views.
>>
>> What do you think? Feedback appreciated.
>
> I think this is a good and necessary change. We'll need to make it prominently known
> that this is different from osgAL in the porting notes, and make sure any current osgAudio
> people know to make this change otherwise their positional audio will stop positioning,
> correct?

Correct. Positioning the Listener requires an app change. Sorry, but I don't see
any way to prevent this; osgAL was taking a shortcut to provide the
auto-positioned Listener functionality, and that shortcut was causing crashes in
multi-view situations.

Also, osgAL allowed you to write out a scene graph containing a SoundRoot, and
load it later and the Listener was positioned automatically. Now, an app will
have to run some kind of NodeVisitor on the loaded scene graph to find the
SoundRoot, then specify the Camera. So, there's no OOTB load-display-play like
there used to be.

Finally, I think I really do want to remove the "set Listener position to
origin" code that I put into place. This needs to be the default Listener
position, and I believe it is, but there's no need for the code I just added to
set this every frame when the Camera is NULL. So I'll fix this today.

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

Paul Martz

unread,
May 11, 2010, 4:27:20 PM5/11/10
to osgaudi...@googlegroups.com
Paul Martz wrote:
> Finally, I think I really do want to remove the "set Listener position
> to origin" code that I put into place. This needs to be the default
> Listener position, and I believe it is, but there's no need for the code
> I just added to set this every frame when the Camera is NULL. So I'll
> fix this today.

OK, this is checked in (r45). If the SoundRoot Camera is NULL (the app didn't
specify it), SoundRoot will not set the Listener matrix to identity. It'll be up
to the app to set the Listener matrix, whenever the Listener position changes.

Doug McCorkle

unread,
May 24, 2010, 2:29:42 PM5/24/10
to osgaudi...@googlegroups.com

On May 11, 2010, at 2:15 PM, Chris 'Xenon' Hanson wrote:

> On 5/10/2010 4:31 PM, Paul Martz wrote:
>> Previously, SoundRoot obtained the Camera view matrix from the
>> CullVisitor, and used it to update the Listener position. This
>> behavior
>> was ill-defined in the case of multiple views.
>>
>> What do you think? Feedback appreciated.
>
> I think this is a good and necessary change. We'll need to make it
> prominently known
> that this is different from osgAL in the porting notes, and make
> sure any current osgAudio
> people know to make this change otherwise their positional audio
> will stop positioning,
> correct?

Did either Chris or Paul update the wiki notes regarding the recent
changes to listener position and file IO changes?

Doug

Paul Martz

unread,
May 24, 2010, 3:42:46 PM5/24/10
to osgaudi...@googlegroups.com
Doug McCorkle wrote:
> Did either Chris or Paul update the wiki notes regarding the recent
> changes to listener position and file IO changes?

This hasn't been documented yet (other than this group's archives). Looking at
the wiki, I don't see a "porting from osgAL" page; should I create one, and
cover this topic as well as the update callback enhancement?

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

Paul Martz

unread,
May 24, 2010, 6:58:46 PM5/24/10
to osgaudi...@googlegroups.com
Paul Martz wrote:
> Doug McCorkle wrote:
>> Did either Chris or Paul update the wiki notes regarding the recent
>> changes to listener position and file IO changes?
>

The other task I was working on today was driving me nuts, so I took a break and
added this documentation. There's now a new wiki page, PortingNotes, that
describes the API differences between osgAL and osgAudio, and advises developers
on how to proceed.

Chris 'Xenon' Hanson

unread,
May 24, 2010, 11:18:40 PM5/24/10
to osgaudi...@googlegroups.com
On 5/24/2010 4:58 PM, Paul Martz wrote:
The other task I was working on today was driving me nuts, so I took a
> break and added this documentation. There's now a new wiki page,
> PortingNotes, that describes the API differences between osgAL and
> osgAudio, and advises developers on how to proceed.

I was pretty sure I had written some porting notes, maybe in a .txt file.

--
Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com
PixelSense Landsat processing now available! http://www.alphapixel.com/demos/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen

Doug McCorkle

unread,
May 24, 2010, 11:34:37 PM5/24/10
to osgaudi...@googlegroups.com

On May 24, 2010, at 10:18 PM, Chris 'Xenon' Hanson wrote:

> On 5/24/2010 4:58 PM, Paul Martz wrote:
> The other task I was working on today was driving me nuts, so I took a
>> break and added this documentation. There's now a new wiki page,
>> PortingNotes, that describes the API differences between osgAL and
>> osgAudio, and advises developers on how to proceed.
>
> I was pretty sure I had written some porting notes, maybe in a .txt
> file.

Please see if Paul has everything up there that are in your notes if
you have a spare minute. Thanks.

Doug

Paul Martz

unread,
May 25, 2010, 9:38:26 AM5/25/10
to osgaudi...@googlegroups.com
Chris 'Xenon' Hanson wrote:
> On 5/24/2010 4:58 PM, Paul Martz wrote:
> The other task I was working on today was driving me nuts, so I took a
>> break and added this documentation. There's now a new wiki page,
>> PortingNotes, that describes the API differences between osgAL and
>> osgAudio, and advises developers on how to proceed.
>
> I was pretty sure I had written some porting notes, maybe in a .txt file.

Please add anything I missed. I know I didn't mention the namespace change at
all, nor the change to .h extension headers. I probably missed other info too.

--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/

Reply all
Reply to author
Forward
0 new messages