[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.6.7 Mix_SetPosition

int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)

channel
Channel number to register this effect on.
Use MIX_CHANNEL_POST to process the postmix stream.
angle
Direction in relation to forward from 0 to 360 degrees. Larger angles will be reduced to this range using angles % 360.
0 = directly in front.
90 = directly to the right.
180 = directly behind.
270 = directly to the left.
So you can see it goes clockwise starting at directly in front.
This ends up being similar in effect to Mix_SetPanning.
distance
The distance from the listener, from 0(near/loud) to 255(far/quiet).
This is the same as the Mix_SetDistance effect.

This effect emulates a simple 3D audio effect. It's not all that realistic, but it can help improve some level of realism. By giving it the angle and distance from the camera's point of view, the effect pans and attenuates volumes. If you are looking for better positional audio, using OpenAL is suggested.
NOTE: Using angle and distance of 0, will cause the effect to unregister itself from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.

Returns: Zero on errors, such as an invalid channel, or if Mix_RegisterEffect failed.

 
// set channel 2 to be behind and right, and 100 units away
if(!Mix_SetPosition(2, 135, 100)) {
    printf("Mix_SetPosition: %s\n", Mix_GetError());
    // no position effect, is it ok?
}

See Also:
4.6.5 Mix_SetPanning, 4.6.6 Mix_SetDistance, 4.6.3 Mix_UnregisterAllEffects



This document was generated on November, 13 2009 using texi2html