Previous Book Contents Book Index Next

Inside Macintosh: Apple Game Sprockets Guide /
Chapter 1 - SoundSprocket / SoundSprocket Reference
SoundSprocket Functions / Creating and Managing 3D Sound Sources


SSpSource_CalcLocalization

You can use the SSpSource_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
The SSpSource_CalcLocalization function returns, in the 3D sound information structure specified by the outLocalization parameter, the current relative positions and velocities of the sound source specified by the inSourceReference parameter and the listener specified by the inListenerReference parameter.

SSpSource_CalcLocalization computes the actual velocity vectors of the source and listener independently, based on the most recent calls to SSpSource_SetVelocity and SSpListener_SetVelocity, and then combines those vectors to obtain a relative velocity. If you called SSpSource_SetVelocity for the specified source after the most recent call to SSpSource_CalcLocalization, then the new velocity is transformed (using the source transform matrix) to obtain the actual velocity of the source. If you called SSpSource_SetPosition or SSpSource_SetTransform but not SSpSource_SetVelocity after the most recent call to SSpSource_CalcLocalization, then the actual velocity is set to the difference in transformed positions divided by the interval since the most recent call to SSpSource_CalcLocalization. In you haven't called any of these functions since the most recent call to SSpSource_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);

Previous Book Contents Book Index Next

© Apple Computer, Inc.
2 JUL 1996