SSpSource_CalcLocalization
You can use theSSpSource_CalcLocalization
function to determine the relative positions and velocities of a sound source and its listener.
OSStatus SSpSource_CalcLocalization ( SSpSourceReference inSourceReference, SSpListenerReference inListenerReference, SSpLocalizationData *outLocalization);
inSourceReference
- A source reference.
inListenerReference
- A listener reference.
outLocalization
- On entry, a pointer to a 3D sound information structure. On exit, the structure is filled in with current information about the relative positions and velocities of the sound source and the listener.
- function result
- A result code.
DESCRIPTION
TheSSpSource_CalcLocalization
function returns, in the 3D sound information structure specified by theoutLocalization
parameter, the current relative positions and velocities of the sound source specified by theinSourceReference
parameter and the listener specified by theinListenerReference
parameter.
SSpSource_CalcLocalization
computes the actual velocity vectors of the source and listener independently, based on the most recent calls toSSpSource_SetVelocity
andSSpListener_SetVelocity
, and then combines those vectors to obtain a relative velocity. If you calledSSpSource_SetVelocity
for the specified source after the most recent call toSSpSource_CalcLocalization
, then the new velocity is transformed (using the source transform matrix) to obtain the actual velocity of the source. If you calledSSpSource_SetPosition
orSSpSource_SetTransform
but notSSpSource_SetVelocity
after the most recent call toSSpSource_CalcLocalization
, then the actual velocity is set to the difference in transformed positions divided by the interval since the most recent call toSSpSource_CalcLocalization
. In you haven't called any of these functions since the most recent call toSSpSource_CalcLocalization
, then the actual source velocity is left unchanged. The listener's actual velocity is calculated in a similar manner.If
SSpSource_CalcLocalization
completes successfully, you should then execute the following code to change the sound being played:
SndSetInfo(myChannel, siSSpLocalization, &mySSpLocalizationData);