AudioBeamSubFrame.cs 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. using RootSystem = System;
  2. using System.Linq;
  3. using System.Collections.Generic;
  4. namespace Windows.Kinect
  5. {
  6. //
  7. // Windows.Kinect.AudioBeamSubFrame
  8. //
  9. public sealed partial class AudioBeamSubFrame : RootSystem.IDisposable, Helper.INativeWrapper
  10. {
  11. internal RootSystem.IntPtr _pNative;
  12. RootSystem.IntPtr Helper.INativeWrapper.nativePtr { get { return _pNative; } }
  13. // Constructors and Finalizers
  14. internal AudioBeamSubFrame(RootSystem.IntPtr pNative)
  15. {
  16. _pNative = pNative;
  17. Windows_Kinect_AudioBeamSubFrame_AddRefObject(ref _pNative);
  18. }
  19. ~AudioBeamSubFrame()
  20. {
  21. Dispose(false);
  22. }
  23. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  24. private static extern void Windows_Kinect_AudioBeamSubFrame_ReleaseObject(ref RootSystem.IntPtr pNative);
  25. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  26. private static extern void Windows_Kinect_AudioBeamSubFrame_AddRefObject(ref RootSystem.IntPtr pNative);
  27. private void Dispose(bool disposing)
  28. {
  29. if (_pNative == RootSystem.IntPtr.Zero)
  30. {
  31. return;
  32. }
  33. __EventCleanup();
  34. Helper.NativeObjectCache.RemoveObject<AudioBeamSubFrame>(_pNative);
  35. if (disposing)
  36. {
  37. Windows_Kinect_AudioBeamSubFrame_Dispose(_pNative);
  38. }
  39. Windows_Kinect_AudioBeamSubFrame_ReleaseObject(ref _pNative);
  40. _pNative = RootSystem.IntPtr.Zero;
  41. }
  42. // Public Properties
  43. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  44. private static extern Windows.Kinect.AudioBeamMode Windows_Kinect_AudioBeamSubFrame_get_AudioBeamMode(RootSystem.IntPtr pNative);
  45. public Windows.Kinect.AudioBeamMode AudioBeamMode
  46. {
  47. get
  48. {
  49. if (_pNative == RootSystem.IntPtr.Zero)
  50. {
  51. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  52. }
  53. return Windows_Kinect_AudioBeamSubFrame_get_AudioBeamMode(_pNative);
  54. }
  55. }
  56. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  57. private static extern int Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations(RootSystem.IntPtr pNative, [RootSystem.Runtime.InteropServices.Out] RootSystem.IntPtr[] outCollection, int outCollectionSize);
  58. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  59. private static extern int Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations_Length(RootSystem.IntPtr pNative);
  60. public RootSystem.Collections.Generic.IList<Windows.Kinect.AudioBodyCorrelation> AudioBodyCorrelations
  61. {
  62. get
  63. {
  64. if (_pNative == RootSystem.IntPtr.Zero)
  65. {
  66. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  67. }
  68. int outCollectionSize = Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations_Length(_pNative);
  69. var outCollection = new RootSystem.IntPtr[outCollectionSize];
  70. var managedCollection = new Windows.Kinect.AudioBodyCorrelation[outCollectionSize];
  71. outCollectionSize = Windows_Kinect_AudioBeamSubFrame_get_AudioBodyCorrelations(_pNative, outCollection, outCollectionSize);
  72. Helper.ExceptionHelper.CheckLastError();
  73. for(int i=0;i<outCollectionSize;i++)
  74. {
  75. if(outCollection[i] == RootSystem.IntPtr.Zero)
  76. {
  77. continue;
  78. }
  79. var obj = Helper.NativeObjectCache.CreateOrGetObject<Windows.Kinect.AudioBodyCorrelation>(outCollection[i], n => new Windows.Kinect.AudioBodyCorrelation(n));
  80. managedCollection[i] = obj;
  81. }
  82. return managedCollection;
  83. }
  84. }
  85. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  86. private static extern float Windows_Kinect_AudioBeamSubFrame_get_BeamAngle(RootSystem.IntPtr pNative);
  87. public float BeamAngle
  88. {
  89. get
  90. {
  91. if (_pNative == RootSystem.IntPtr.Zero)
  92. {
  93. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  94. }
  95. return Windows_Kinect_AudioBeamSubFrame_get_BeamAngle(_pNative);
  96. }
  97. }
  98. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  99. private static extern float Windows_Kinect_AudioBeamSubFrame_get_BeamAngleConfidence(RootSystem.IntPtr pNative);
  100. public float BeamAngleConfidence
  101. {
  102. get
  103. {
  104. if (_pNative == RootSystem.IntPtr.Zero)
  105. {
  106. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  107. }
  108. return Windows_Kinect_AudioBeamSubFrame_get_BeamAngleConfidence(_pNative);
  109. }
  110. }
  111. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  112. private static extern long Windows_Kinect_AudioBeamSubFrame_get_Duration(RootSystem.IntPtr pNative);
  113. public RootSystem.TimeSpan Duration
  114. {
  115. get
  116. {
  117. if (_pNative == RootSystem.IntPtr.Zero)
  118. {
  119. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  120. }
  121. return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamSubFrame_get_Duration(_pNative));
  122. }
  123. }
  124. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  125. private static extern uint Windows_Kinect_AudioBeamSubFrame_get_FrameLengthInBytes(RootSystem.IntPtr pNative);
  126. public uint FrameLengthInBytes
  127. {
  128. get
  129. {
  130. if (_pNative == RootSystem.IntPtr.Zero)
  131. {
  132. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  133. }
  134. return Windows_Kinect_AudioBeamSubFrame_get_FrameLengthInBytes(_pNative);
  135. }
  136. }
  137. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  138. private static extern long Windows_Kinect_AudioBeamSubFrame_get_RelativeTime(RootSystem.IntPtr pNative);
  139. public RootSystem.TimeSpan RelativeTime
  140. {
  141. get
  142. {
  143. if (_pNative == RootSystem.IntPtr.Zero)
  144. {
  145. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  146. }
  147. return RootSystem.TimeSpan.FromMilliseconds(Windows_Kinect_AudioBeamSubFrame_get_RelativeTime(_pNative));
  148. }
  149. }
  150. // Public Methods
  151. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  152. private static extern void Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToArray(RootSystem.IntPtr pNative, RootSystem.IntPtr frameData, int frameDataSize);
  153. public void CopyFrameDataToArray(byte[] frameData)
  154. {
  155. if (_pNative == RootSystem.IntPtr.Zero)
  156. {
  157. throw new RootSystem.ObjectDisposedException("AudioBeamSubFrame");
  158. }
  159. var frameDataSmartGCHandle = new Helper.SmartGCHandle(RootSystem.Runtime.InteropServices.GCHandle.Alloc(frameData, RootSystem.Runtime.InteropServices.GCHandleType.Pinned));
  160. var _frameData = frameDataSmartGCHandle.AddrOfPinnedObject();
  161. Windows_Kinect_AudioBeamSubFrame_CopyFrameDataToArray(_pNative, _frameData, frameData.Length);
  162. Helper.ExceptionHelper.CheckLastError();
  163. }
  164. [RootSystem.Runtime.InteropServices.DllImport("KinectUnityAddin", CallingConvention=RootSystem.Runtime.InteropServices.CallingConvention.Cdecl, SetLastError=true)]
  165. private static extern void Windows_Kinect_AudioBeamSubFrame_Dispose(RootSystem.IntPtr pNative);
  166. public void Dispose()
  167. {
  168. if (_pNative == RootSystem.IntPtr.Zero)
  169. {
  170. return;
  171. }
  172. Dispose(true);
  173. RootSystem.GC.SuppressFinalize(this);
  174. }
  175. private void __EventCleanup()
  176. {
  177. }
  178. }
  179. }