views:

29

answers:

1

Hello,

For the 3D iPad app I am writing I want audio to increase/decrease in volume as a single virtual listener turns towards/away-from sound sources. The listener is always stationary. The listener can only rotate. The sounds are always stationary. The sounds fill a sphere of directions around the user. The sounds are all of equal distance from the listener.

I think of the sounds as analogous to light sources in 3D graphics. For each sound there is a vector pointing from the listener to that sound source. The listener has an outgoing directional vector. I want to weight the contribution of each audio source by the dotProduct of the listener vector and each of the audio source vectors. So as the listener's "head" rotates around sound contributions change directionally.

How much of what I describe can be handled by OpenAL and how much do I need to write myself?

Thanks,
Doug

+2  A: 

Yes, you can do this in OpenAL. In fact you can do better! With the dot-product you would simply get full volume when they are parallel and zero when they are perpendicular, using OpenAL you can define a cone of sound coming from your source.

On the source you need to set the AL_CONE_INNER_ANGLE to be smaller than the AL_CONE_OUTER_ANGLE so you get full volume within the inner cone angle and it attenuates to zero outside the outer cone angle. You also need to set the AL_DIRECTION of course.

It's been a while, and I'm not sure if you can set the cone/direction of the listener, but that doesn't really matter since all your objects are static anyway, you can simply rotate the direction of the sources instead, to simulate it :D

jhabbott
Very cool. Thanks.
dugla