public float ApplyCustom3DCurve(float distance) { Audio3DSetting settings = m_audioClipSource.Get3DSettings(); if (settings != null) { if (settings.GetRolloffMode() == AudioRolloffMode.Custom) { return(settings.EvaluateCustom(distance)); } } return(1.0f); }
void Update() { bool queueEnableAndPlay = false; if (m_currentAudioSource == null) { // don't bother stealing if we're going to be silent anyway... if (GetTheoreticalVolume() > 0) { m_currentAudioSource = WingroveRoot.Instance.TryClaimPoolSource(this); } if (m_currentAudioSource != null) { m_currentAudioSource.m_audioSource.clip = m_audioClipSource.GetAudioClip(); if (!m_isPaused) { m_currentAudioSource.m_audioSource.loop = m_audioClipSource.GetLooping(); queueEnableAndPlay = true; } } else { if (!m_isPaused) { if (m_hasStartedEver) { m_currentPosition += (int)(WingroveRoot.GetDeltaTime() * m_audioClipSource.GetAudioClip().frequency *GetMixPitch()); } if (m_currentPosition > m_audioClipSource.GetAudioClip().samples) { if (m_audioClipSource.GetLooping()) { m_currentPosition -= m_audioClipSource.GetAudioClip().samples; } else { StopInternal(); } } } } } else { if (!m_isPaused) { m_currentPosition = m_currentAudioSource.m_audioSource.timeSamples; } } if (!m_isPaused) { switch (m_currentState) { case CueState.Initial: break; case CueState.Playing: m_fadeT = 1; break; case CueState.PlayingFadeIn: m_fadeT += m_fadeSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT >= 1) { m_fadeT = 1.0f; m_currentState = CueState.Playing; } break; case CueState.PlayingFadeOut: m_fadeT -= m_fadeSpeed * WingroveRoot.GetDeltaTime(); if (m_fadeT <= 0) { m_fadeT = 0.0f; StopInternal(); // early return!!!! return; } break; } if (!m_audioClipSource.GetLooping()) { if (m_currentPosition > m_audioClipSource.GetAudioClip().samples - 1000) { StopInternal(); return; } } } SetMix(); if (queueEnableAndPlay) { if (m_currentAudioSource != null) { m_currentAudioSource.m_audioSource.enabled = true; m_currentAudioSource.m_audioSource.timeSamples = m_currentPosition; Audio3DSetting settings = m_audioClipSource.Get3DSettings(); if (settings == null) { WingroveRoot.Instance.SetDefault3DSettings(m_currentAudioSource.m_audioSource); } else { AudioRolloffMode rolloffMode = settings.GetRolloffMode(); if (rolloffMode != AudioRolloffMode.Custom) { m_currentAudioSource.m_audioSource.rolloffMode = rolloffMode; m_currentAudioSource.m_audioSource.minDistance = settings.GetMinDistance(); m_currentAudioSource.m_audioSource.maxDistance = settings.GetMaxDistance(); } else { m_currentAudioSource.m_audioSource.rolloffMode = AudioRolloffMode.Linear; m_currentAudioSource.m_audioSource.minDistance = float.MaxValue; m_currentAudioSource.m_audioSource.maxDistance = float.MaxValue; } } if ((m_hasDSPStartTime) && (m_dspStartTime > AudioSettings.dspTime)) { m_currentAudioSource.m_audioSource.timeSamples = m_currentPosition = 0; m_currentAudioSource.m_audioSource.PlayScheduled(m_dspStartTime); } else { m_currentAudioSource.m_audioSource.Play(); } } } m_hasStartedEver = true; }