//* * * * * * * * * * * * * // Private functions //* * * * * * * * * * * * * /// <summary> /// Aquire resources for spatialization /// </summary> private void Aquire() { if (!audioSource) { return; } // Cache pan and spread #if (!UNITY5) panLevel = audioSource.spatialBlend; #else panLevel = audioSource.spatialBlend; #endif spread = audioSource.spread; // override to use simple spatializer bool prevUseSimple = OSPManager.GetUseSimple(); if (useSimple == true) { OSPManager.SetUseSimple(useSimple); } // Reserve a context in OSP that will be used for spatializing sound // (Don't grab a new one if is already has a context attached to it) if (context == sNoContext) { context = OSPManager.AquireContext(); } OSPManager.SetUseSimple(prevUseSimple); // reset // We don't have a context here, so bail if (context == sNoContext) { return; } // Set pan to full (spread at 180 will keep attenuation curve working, but all 2D // panning will be removed) // We want to remove FMod curve attenuation if we are doing our // own internal calc float pl = sSetPanLevel; if (OSPManager.GetUseInverseSquareAttenuation() == true) { pl = sSetPanLevelInvSq; } #if (!UNITY5) audioSource.spatialBlend = pl; #else audioSource.spatialBlend = pl; #endif // set spread to 180 audioSource.spread = sSetSpread; }