mixSetTrack3DPosition function mixer
Set a track's position in 3D space.
(Please note that SDL_mixer is not intended to be a extremely powerful 3D API. It lacks 3D features that other APIs like OpenAL offer: there's no doppler effect, distance models, rolloff, etc. This is meant to be Good Enough for games that can use some positional sounds and can even take advantage of surround-sound configurations.)
If position
is not NULL, this track will be switched into 3D positional
mode. If position
is NULL, this will disable positional mixing (both the
full 3D spatialization of this function and forced-stereo mode of
MIX_SetTrackStereo()).
In 3D positional mode, SDL_mixer will mix this track as if it were positioned in 3D space, including distance attenuation (quieter as it gets further from the listener) and spatialization (positioned on the correct speakers to suggest direction, either with stereo outputs or full surround sound).
For a mono speaker output, spatialization is effectively disabled but distance attenuation will still work, which is all you can really do with a single speaker.
The coordinate system operates like OpenGL or OpenAL: a "right-handed" coordinate system. See MIX_Point3D for the details.
The listener is always at coordinate (0,0,0) and can't be changed.
The track's input will be converted to mono (1 channel) so it can be rendered across the correct speakers.
\param track the track for which to set 3D position. \param position the new 3D position for the track. May be NULL. \returns true on success or false on failure; call SDL_GetError() for more information.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL_mixer 3.0.0.
\sa MIX_GetTrack3DPosition \sa MIX_SetTrackStereo
extern SDL_DECLSPEC bool SDLCALL MIX_SetTrack3DPosition(MIX_Track *track, const MIX_Point3D *position)
Implementation
bool mixSetTrack3DPosition(
Pointer<MixTrack> track,
Pointer<MixPoint3D> position,
) {
final mixSetTrack3DPositionLookupFunction = _libMixer
.lookupFunction<
Uint8 Function(Pointer<MixTrack> track, Pointer<MixPoint3D> position),
int Function(Pointer<MixTrack> track, Pointer<MixPoint3D> position)
>('MIX_SetTrack3DPosition');
return mixSetTrack3DPositionLookupFunction(track, position) == 1;
}