Re: position

Erik Hofman <[email protected]> Thu, 13 Oct 2011 13:43:42 +0200
Newsgroups gmane.comp.lib.openal
Message-ID <1318506222.13113.9.camel@Raptor>
On Thu, 2011-10-13 at 12:24 +0100, Christina Fuentes wrote:
> Hi,
> 
> I'm trying to use OpenAL to create 3D sound clips where the source is
> at different distances from the listener. Here are my settings for the
> listener:
> % Static listener, facing forward
> forward = [0,0,1];
> up = [0,1,0];

This is actually setting the listener to face backwards, forward (for
the listener) it should be [0,0,-1]

> orient = [forward, up];
> alListenerfv(AL.ORIENTATION, orient);
> alListenerfv(AL.POSITION, [0, 0, -1])
> alListenerfv(AL.VELOCITY, [0, 0, 0]);
> 
> What I want to vary is the position of the source. I'm trying to use
> alSource3f(source, AL.POSITION, x, y, z)
> but I can't figure out the coordinate system. More specifically, I
> found in the OpenAL specifications that it uses a right-handed
> Cartesian system, where in a frontal view X (thumb) points right, Y
> (index finger) points up, and Z (middle finger) points towards the
> listener. What I can't sort out is where the origin is and what the

Is not specified the origin is at [0,0,0] for both the listener and the
sources. You could set the sources RELATIVE to the listener, then the
source positions and orientation are specified as a relative distance
and angle to the listener.

>  units are. With the above settings for the listener, if I set the

Units are unspecified and are calculated only for the Doppler effect.
Defining the unit for Doppler is done by setting the SPEED_OF_SOUND.

>  source's Y position as 0 and the X position as 0, increasing the Z
> position decreases the sound's intensity, which is good (the source is
> moving farther away). Is there any reference to how far it's moving
> (i.e., if Z is 1 versus 3, does this equate to any distance units or
> is the absolute perception of distance just relative for each
> listener)? Moreover, if I keep Z at 1 and try adjusting X, which

The distance perception is influenced by which Distance attenuation
model you select, and by the REFERENCE distance and ROLLOFF_FACTOR

>  should move the sound from the left to the right, I can't hear much
> of any difference, and if I try to adjust both X and Z all bets are
> off.

Note that to get a linear movement from left to right you need to use
sine and cosine to calculate the proper location, like this:

   deg = 0;
   while(deg < 360)
   {
       nanoSleep(5e7);

       ang = (float)deg / 180.0f * GMATH_PI;
       SourcePos[0] =  r * sinf(ang);       /* x: right positive */
       SourcePos[2] = -r * cosf(ang);       /* z: back positive  */
       alSourcefv(source[0], AL_POSITION, SourcePos);
       deg += 1;
   }


Hope this helps,

Erik

_______________________________________________
Openal mailing list
[email protected]
http://opensource.creative.com/mailman/listinfo/openal