MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / SetupSpatial

Function SetupSpatial

Source/Engine/Audio/OpenAL/AudioBackendOAL.cpp:115–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113 namespace Source
114 {
115 void SetupSpatial(uint32 sourceID, float pan, bool spatial)
116 {
117 alSourcei(sourceID, AL_SOURCE_RELATIVE, !spatial); // Non-spatial sounds use AL_POSITION for panning
118#ifdef AL_SOFT_source_spatialize
119 alSourcei(sourceID, AL_SOURCE_SPATIALIZE_SOFT, spatial || Math::Abs(pan) > ZeroTolerance ? AL_TRUE : AL_FALSE); // Fix multi-channel sources played as spatial or non-spatial sources played with panning
120#endif
121 if (spatial)
122 {
123#ifdef AL_EXT_STEREO_ANGLES
124 const float panAngle = pan * PI_HALF;
125 const ALfloat panAngles[2] = { (ALfloat)(PI / 6.0 - panAngle), (ALfloat)(-PI / 6.0 - panAngle) }; // Angles are specified counter-clockwise in radians
126 alSourcefv(sourceID, AL_STEREO_ANGLES, panAngles);
127#endif
128 }
129 else
130 {
131 alSource3f(sourceID, AL_POSITION, pan, 0, -sqrtf(1.0f - pan * pan));
132 }
133 }
134
135 void Rebuild(uint32& sourceID, const Vector3& position, const Quaternion& orientation, float volume, float pitch, float pan, bool loop, bool spatial, float attenuation, float minDistance, float doppler)
136 {

Callers 3

RebuildFunction · 0.85
Source_PanChangedMethod · 0.85

Calls 1

AbsFunction · 0.50

Tested by

no test coverage detected