Discussion:
Units for position?
t***@pegnsean.net
2012-12-30 00:12:37 UTC
Permalink
Hey all!

I hope you are in the midst of having a great holiday season!

I've been working on a demo, and it occurs to me that I have no idea what
units are used in the position coordinates, nor how to set or change them
if I need to use something different.

Is there an explanation of that available somewhere?

I've been using relatively small numbers -- object A at (1, 0, 0), object
B at (0, 2, 0), etc... and sounds move where I expect them to... but I
tried using for example actual real-room dimensions in inches, and things
didn't work...

For example, with the listener at (0, 0, 0), I placed the front center of
my test layout at (0, 0, 10), the back center at (0, 0, 36), left center
at (-21, 0, 23) and right center at (+21, 0, 23)... based on the distances
in inches if the listener was 10 inches in front of the front/center of
the layout.

(Matt: I've rotated these values to account for your rotation of the
coordinate system within JMRI. The numbers in this email assume X=side to
side, Y = up/down, Z=ahead/behind).

So what surprised me is that these distances seem to be "too far away" -
the volume attenuation basically shuts the sounds off. If I use arbitrary
but small numbers FC=(0, 0, 1) BC=(0,0,3), LT=(-1,0,2), RT=(1,0,2) it
seems to work OK.

I know there's some parameters that can be set to adjust this sort of
thing, but I don't really understand well what they mean or what they do.

Any explanatory help would be much appreciated!

Thanks,

Mark
Chris Robinson
2012-12-30 02:16:13 UTC
Permalink
Post by t***@pegnsean.net
Hey all!
I hope you are in the midst of having a great holiday season!
Hi! :)
Post by t***@pegnsean.net
I've been working on a demo, and it occurs to me that I have no idea what
units are used in the position coordinates, nor how to set or change them
if I need to use something different.
In practical terms, unextended OpenAL uses scale-invariant units. That
is to say, it doesn't matter whether you're using meters, feet,
centimeters, inches, etc... as long as /all/ distance values use the
same scale, you'll get the same output.

A common pitfall, however, is to ignore or set an improper value for
AL_REFERENCE_DISTANCE on sources. This is essentially the distance from
the sound that the audio was originally recorded at, or more basically,
the in-game distance where the source should not be attenuated. So for
example, if you had this set to 1 when using a scale of 1 unit = 1
meter, you'd want to set it to 100 if using 1 unit = 1 centimeter to
keep the scale correct.


When using EFX, there is a setting to specify the unit scale. This
setting applies to certain effects, like the air absorption effect which
defines high-frequency attenuation in meters rather than units. This
scale can be set using the listener's AL_METERS_PER_UNIT property, and
it defaults to 1.
Post by t***@pegnsean.net
So what surprised me is that these distances seem to be "too far away" -
the volume attenuation basically shuts the sounds off. If I use arbitrary
but small numbers FC=(0, 0, 1) BC=(0,0,3), LT=(-1,0,2), RT=(1,0,2) it
seems to work OK.
Then you'll want to increase the source's AL_REFERENCE_DISTANCE until
you get good attenuation levels. Every doubling of the distance from the
reference distance halves the gain, so at a distance of 10 with a ref
distance of 1, you'll basically have an attenuation of 1/10, or 0.1.
Increase the ref distance to 5 and you'll get an attenuation of 5/10, or
0.5, at the same distance.
t***@pegnsean.net
2012-12-31 00:41:02 UTC
Permalink
Ah-hah!

That would appear to be EXACTLY what I needed to know.

Hmm... I'll have to provide a way to set the reference distance, so that
it matches the measurement units my user will use to describe their
layout, but that shouldn't be too hard.

Thanks!!

- Mark
Post by Chris Robinson
Post by t***@pegnsean.net
Hey all!
I hope you are in the midst of having a great holiday season!
Hi! :)
Post by t***@pegnsean.net
I've been working on a demo, and it occurs to me that I have no idea what
units are used in the position coordinates, nor how to set or change them
if I need to use something different.
In practical terms, unextended OpenAL uses scale-invariant units. That
is to say, it doesn't matter whether you're using meters, feet,
centimeters, inches, etc... as long as /all/ distance values use the
same scale, you'll get the same output.
A common pitfall, however, is to ignore or set an improper value for
AL_REFERENCE_DISTANCE on sources. This is essentially the distance from
the sound that the audio was originally recorded at, or more basically,
the in-game distance where the source should not be attenuated. So for
example, if you had this set to 1 when using a scale of 1 unit = 1
meter, you'd want to set it to 100 if using 1 unit = 1 centimeter to
keep the scale correct.
When using EFX, there is a setting to specify the unit scale. This
setting applies to certain effects, like the air absorption effect which
defines high-frequency attenuation in meters rather than units. This
scale can be set using the listener's AL_METERS_PER_UNIT property, and
it defaults to 1.
Post by t***@pegnsean.net
So what surprised me is that these distances seem to be "too far away" -
the volume attenuation basically shuts the sounds off. If I use arbitrary
but small numbers FC=(0, 0, 1) BC=(0,0,3), LT=(-1,0,2), RT=(1,0,2) it
seems to work OK.
Then you'll want to increase the source's AL_REFERENCE_DISTANCE until
you get good attenuation levels. Every doubling of the distance from the
reference distance halves the gain, so at a distance of 10 with a ref
distance of 1, you'll basically have an attenuation of 1/10, or 0.1.
Increase the ref distance to 5 and you'll get an attenuation of 5/10, or
0.5, at the same distance.
_______________________________________________
Openal mailing list
http://opensource.creative.com/mailman/listinfo/openal
t***@pegnsean.net
2013-01-01 07:01:38 UTC
Permalink
Turns out I have a follow-up distance.

I presume the reference distance is treated as a radius from the Listener
position, yes? so (1, 0, 0) is the same distance as (0,1,0) is the same
distance as (sqrt(2), sqrt(2), 0)?

- Mark
Post by t***@pegnsean.net
Ah-hah!
That would appear to be EXACTLY what I needed to know.
Hmm... I'll have to provide a way to set the reference distance, so that
it matches the measurement units my user will use to describe their
layout, but that shouldn't be too hard.
Thanks!!
- Mark
Post by Chris Robinson
Post by t***@pegnsean.net
Hey all!
I hope you are in the midst of having a great holiday season!
Hi! :)
Post by t***@pegnsean.net
I've been working on a demo, and it occurs to me that I have no idea what
units are used in the position coordinates, nor how to set or change them
if I need to use something different.
In practical terms, unextended OpenAL uses scale-invariant units. That
is to say, it doesn't matter whether you're using meters, feet,
centimeters, inches, etc... as long as /all/ distance values use the
same scale, you'll get the same output.
A common pitfall, however, is to ignore or set an improper value for
AL_REFERENCE_DISTANCE on sources. This is essentially the distance from
the sound that the audio was originally recorded at, or more basically,
the in-game distance where the source should not be attenuated. So for
example, if you had this set to 1 when using a scale of 1 unit = 1
meter, you'd want to set it to 100 if using 1 unit = 1 centimeter to
keep the scale correct.
When using EFX, there is a setting to specify the unit scale. This
setting applies to certain effects, like the air absorption effect which
defines high-frequency attenuation in meters rather than units. This
scale can be set using the listener's AL_METERS_PER_UNIT property, and
it defaults to 1.
Post by t***@pegnsean.net
So what surprised me is that these distances seem to be "too far away" -
the volume attenuation basically shuts the sounds off. If I use arbitrary
but small numbers FC=(0, 0, 1) BC=(0,0,3), LT=(-1,0,2), RT=(1,0,2) it
seems to work OK.
Then you'll want to increase the source's AL_REFERENCE_DISTANCE until
you get good attenuation levels. Every doubling of the distance from the
reference distance halves the gain, so at a distance of 10 with a ref
distance of 1, you'll basically have an attenuation of 1/10, or 0.1.
Increase the ref distance to 5 and you'll get an attenuation of 5/10, or
0.5, at the same distance.
_______________________________________________
Openal mailing list
http://opensource.creative.com/mailman/listinfo/openal
_______________________________________________
Openal mailing list
http://opensource.creative.com/mailman/listinfo/openal
Chris Robinson
2013-01-01 07:05:33 UTC
Permalink
Post by t***@pegnsean.net
Turns out I have a follow-up distance.
I presume the reference distance is treated as a radius from the Listener
position, yes? so (1, 0, 0) is the same distance as (0,1,0) is the same
distance as (sqrt(2), sqrt(2), 0)?
As far as distance attenuation goes, yes. Though that should be
(sqrt(0.5), sqrt(0.5), 0) for the last one. :)
t***@pegnsean.net
2013-01-01 22:33:25 UTC
Permalink
Post by Chris Robinson
Post by t***@pegnsean.net
Turns out I have a follow-up distance.
I presume the reference distance is treated as a radius from the Listener
position, yes? so (1, 0, 0) is the same distance as (0,1,0) is the same
distance as (sqrt(2), sqrt(2), 0)?
As far as distance attenuation goes, yes. Though that should be
(sqrt(0.5), sqrt(0.5), 0) for the last one. :)
Touche'

OK, another question on this... now this might be hardware dependent or
something. I noticed that with 2 speakers hooked up to the stereo audio
output of my MacBook Pro, when I put a sound off to the left (or right) of
the centerline, all of the sound comes from the left (or right) speaker,
and the opposite speaker goes silent. I verified this by piping the audio
output to Audacity.

Not saying anything's broken, just trying to understand what's going on...

This happens no matter how close to 0 the X value appears to be (well, I
didn't try smaller than +/- 0.25). To further puzzle me, these sources
are not located on the X axis, they are in front of me by 1 unit. (i.e. [
+/- 0.25, 0, 1])

Is this an artifact of being in Stereo mode as opposed to, say, 2.1 (or
higher) Surround mode? Or something else I don't understand. I'm
expecting, since it's only a little bit to one side or the other, and
mostly out front, for the sound to still come from both speakers, with
more of a cross-fade effect happening, rather than shutting off one
speaker and only coming out of the other.

Thanks,

Mark
v
Matthew Harris
2013-01-02 09:01:15 UTC
Permalink
Mark,

Been 'off-grid' for the past week or so, so have just seen this trail
of messages.

In JMRI, we have already foreseen the option to define the meaning of
units - it's defined within the JMRI AudioListener object (I know that
this isn't strictly a Listener property within the OpenAL context).

The section on the AudioListener should explain this a bit better at
the following page:

http://jmri.org/help/en/html/tools/Audio.shtml

For the attenuation question, by default we use the
AL_INVERSE_DISTANCE_CLAMPED attenuation model.

At the moment, there is no option to change this model (I hard-coded
it) - the only option is to turn-off attenuation completely (and that
isn't exposed in the GUI, purely through the scripting layer).

One thing that I did notice when initially playing with panning was to
set the listener position to, rather than being at (0, 0, 0), to be at
(0, 0, -1) <- assuming the standard OpenAL co-ordinate model (in other
words, standing 1 'unit' back from the edge of the layout.

Hopefully this helps you along the right track...

Best regards,

Matt H
t***@pegnsean.net
2013-01-02 13:46:24 UTC
Permalink
(responses inline)
Post by Matthew Harris
Mark,
Been 'off-grid' for the past week or so, so have just seen this trail
of messages.
In JMRI, we have already foreseen the option to define the meaning of
units - it's defined within the JMRI AudioListener object (I know that
this isn't strictly a Listener property within the OpenAL context).
Aah. Good. I should be able to take advantage of that, as soon as I
figure out how to use it in context...
Post by Matthew Harris
For the attenuation question, by default we use the
AL_INVERSE_DISTANCE_CLAMPED attenuation model.
I'll need to look this up and understand it.
Post by Matthew Harris
At the moment, there is no option to change this model (I hard-coded
it) - the only option is to turn-off attenuation completely (and that
isn't exposed in the GUI, purely through the scripting layer).
One thing that I did notice when initially playing with panning was to
set the listener position to, rather than being at (0, 0, 0), to be at
(0, 0, -1) <- assuming the standard OpenAL co-ordinate model (in other
words, standing 1 'unit' back from the edge of the layout.
How does this differ from having the listener at (0,0,0) and all layout
elements at (x, y, z > 1), that is, all layout elements at least one unit
in front of the listener/origin? I may have to experiment to see.
Post by Matthew Harris
Hopefully this helps you along the right track...
Thanks!!
Matthew Harris
2013-01-02 13:49:31 UTC
Permalink
Post by t***@pegnsean.net
(responses inline)
How does this differ from having the listener at (0,0,0) and all layout
elements at (x, y, z > 1), that is, all layout elements at least one unit
in front of the listener/origin? I may have to experiment to see.
Shouldn't make any difference - worth a try though.

Matt H

Loading...