/// <summary> /// Applies the transformation to any audio. /// </summary> /// <param name="matrix3x4"></param> public void SetTransformation(Matrix3x4 matrix3x4) { using (AudioObjectTransformation audioObjectTransformation = new AudioObjectTransformation(matrix3x4)) // can safely dispose this as the C++ implementation uses a copy { NativeAudioSystem.SetAudioListenerTransformation(_cPtr.Handle, audioObjectTransformation.NativePtr); } }
internal AudioListener() { Matrix3x4 matrix3x4 = Matrix3x4.Identity; AudioObjectTransformation audioObjectTransformation = new AudioObjectTransformation(matrix3x4); _cPtr = new System.Runtime.InteropServices.HandleRef(this, NativeAudioSystem.CreateAudioListener(audioObjectTransformation.NativePtr)); }
/// <summary> /// Sets the transformation of the audio object /// </summary> /// <param name="matrix"></param> public void SetTransformation(Matrix3x4 matrix) { if (_audioTransformation != null) { _audioTransformation.Dispose(); _audioTransformation = null; } _audioTransformation = new AudioObjectTransformation(matrix); NativeAudioSystem.SetAudioTransformation(_cPtr.Handle, _audioTransformation.NativePtr); }
/// <summary> /// Sets the transformation of the audio object /// </summary> /// <param name="position"></param> /// <param name="forward"></param> /// <param name="up"></param> public void SetTransformation(Vector3 position, Vector3 forward, Vector3 up) { // create managed matrix and once done call native method if (_audioTransformation != null) { _audioTransformation.Dispose(); _audioTransformation = null; } _audioTransformation = new AudioObjectTransformation(new Matrix3x4( 0, forward.x, up.x, position.x, 0, forward.y, up.y, position.y, 0, forward.z, up.z, position.z )); NativeAudioSystem.SetAudioTransformation(_cPtr.Handle, _audioTransformation.NativePtr); }
private void Dispose(bool isDisposing) { if (_isDisposed) { return; } if (isDisposing) { _audioTransformation.Dispose(); _audioTransformation = null; } if (_cPtr.Handle != System.IntPtr.Zero) { NativeAudioSystem.ReleaseAudioObject(_cPtr.Handle); _cPtr = new System.Runtime.InteropServices.HandleRef(null, IntPtr.Zero); } _isDisposed = true; }