private bool disposedValue = false; // To detect redundant calls protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { //_c?.Dispose(); PCMQueue?.Clear(); DirectUrls?.Clear(); FillCacheTask?.Dispose(); } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposedValue = true; } }
void Start() { _Listener = FindObjectOfType(typeof(AudioListener)) as AudioListener; _PCMBuffer = new PCMQueue(1); if (_HRIR == null) Debug.LogWarning("No HRIR specified. Binaural audio processing disabled.", this); if (GetComponent<AudioSource>() == null) Debug.LogWarning(string.Format("There is no AudioSource attached to {0}. Binaural audio processing disabled.", this.name), this); if (GetComponent<AudioSource>() && GetComponent<AudioSource>().clip != null && GetComponent<AudioSource>().clip.channels != 2) Debug.LogWarning("This script can only run on 2 channel audio clips. Binaural audio processing disabled.", this); if (_Listener == null) Debug.LogWarning("No Listener in scene. Binaural audio processing disabled.", this); Update(); }
void UpdateHRIR() { if (_HRIR == null) { _FilterEnabled = false; return; } if (_PCMBuffer.Length != _HRIR.Samples) { _FilterEnabled = false; _PCMBuffer = new PCMQueue(_HRIR.Samples); } int newIAzimuth = _HRIR.GetNearestAzimuthIndex(_Azimuth); int newIElevation = _HRIR.GetNearestElevationIndex(_Elevation); if (newIAzimuth != _IAzimuth || newIElevation != _IElevation) { _IAzimuth = newIAzimuth; _IElevation = newIElevation; _LeftHRIR = _HRIR.GetLeftHrir(_IAzimuth, _IElevation); _RightHRIR = _HRIR.GetRightHrir(_IAzimuth, _IElevation); } _FilterEnabled = true; }