Discussion:
AL_DIRECTION // rotating source
mike4linux
2012-06-14 06:42:58 UTC
Permalink
Hi
pPsi is the heading angle in degrees. I set soundpositions:

float hdgPv = fmod(pPsi + 180, 360);//front x position
float hdgPh = fmod(pPsi, 360);//back

alSource3f(Sources[2], AL_POSITION, hdgPv/10, lY/10, lZ/10); //front


now attenuation is fine for back but for front I get a interruption
when angle goes from 360 - 0. Any
idea on how to fix that? I was also looking for AL_DIRECTION but
couldn't find any solution.
Many thanks
--
View this message in context: http://old.nabble.com/AL_DIRECTION----rotating-source-tp34010052p34010052.html
Sent from the OpenAL - User mailing list archive at Nabble.com.
Chris Robinson
2012-06-14 09:03:58 UTC
Permalink
Post by mike4linux
Hi
float hdgPv = fmod(pPsi + 180, 360);//front x position
float hdgPh = fmod(pPsi, 360);//back
alSource3f(Sources[2], AL_POSITION, hdgPv/10, lY/10, lZ/10); //front
now attenuation is fine for back but for front I get a interruption
when angle goes from 360 - 0. Any
idea on how to fix that? I was also looking for AL_DIRECTION but
couldn't find any solution.
Many thanks
Hi.

I'm a bit confused about what you're trying to do. Are you trying to move the
sound around a certain point, or are you trying to change the direction the
sound itself is facing (for the sound cones)?

If you have the heading angle in degrees, you can get the angle vector by
converting to radians and using sin and cos:

float vec[3];
float rad = pPsi * M_PI/180.0f;
vec[0] = sin(rad);
vec[1] = 0.0f;
vec[2] = -cos(rad);

This makes it so pPsi=0 is front/forward, and incrementing goes clockwise. So
if you're trying to move the sound, you set its position:

alSourcefv(Sources[2], AL_POSITION, vec);

Or if you're trying to set it's facing direction for sound cones, set
AL_DIRECTION instead.

Hope that helps.
mike4linux
2012-06-15 06:36:39 UTC
Permalink
Great many thanks Chris.
Seems to work, although now I need the sounds to decrease more with listener
distance. Any idea about
such? But anyway I might find a solution for that, thanks again.
--
View this message in context: http://old.nabble.com/AL_DIRECTION----rotating-source-tp34010052p34016297.html
Sent from the OpenAL - User mailing list archive at Nabble.com.
Chris Robinson
2012-06-18 20:08:12 UTC
Permalink
Post by mike4linux
Great many thanks Chris.
Seems to work, although now I need the sounds to decrease more with listener
distance. Any idea about
such? But anyway I might find a solution for that, thanks again.
That should happen automatically as the listener and source positions move
away from each other. Make sure the source's AL_SOURCE_RELATIVE is set to
AL_FALSE.

Loading...