ONSPPropagationInterface.cs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. /************************************************************************************
  2. Filename : ONSPPropagationInterface.cs
  3. Content : Interface into the Oculus Audio propagation functions
  4. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  5. Licensed under the Oculus SDK Version 3.5 (the "License");
  6. you may not use the Oculus SDK except in compliance with the License,
  7. which is provided at the time of installation or download, or which
  8. otherwise accompanies this software in either electronic or hard copy form.
  9. You may obtain a copy of the License at
  10. https://developer.oculus.com/licenses/sdk-3.5/
  11. Unless required by applicable law or agreed to in writing, the Oculus SDK
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. ************************************************************************************/
  17. using System;
  18. using System.Runtime.InteropServices;
  19. using UnityEngine;
  20. using Oculus.Spatializer.Propagation;
  21. namespace Oculus
  22. {
  23. namespace Spatializer
  24. {
  25. namespace Propagation
  26. {
  27. /***********************************************************************************/
  28. // ENUMS and STRUCTS
  29. /***********************************************************************************/
  30. public enum FaceType : uint
  31. {
  32. TRIANGLES = 0,
  33. QUADS
  34. }
  35. public enum MaterialProperty : uint
  36. {
  37. ABSORPTION = 0,
  38. TRANSMISSION,
  39. SCATTERING
  40. }
  41. // Matches internal mesh layout
  42. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  43. public struct MeshGroup
  44. {
  45. public UIntPtr indexOffset;
  46. public UIntPtr faceCount;
  47. [MarshalAs(UnmanagedType.U4)]
  48. public FaceType faceType;
  49. public IntPtr material;
  50. }
  51. }
  52. }
  53. }
  54. class ONSPPropagation
  55. {
  56. static PropagationInterface CachedInterface;
  57. public static PropagationInterface Interface { get { if (CachedInterface == null) CachedInterface = FindInterface(); return CachedInterface; } }
  58. static PropagationInterface FindInterface()
  59. {
  60. IntPtr temp;
  61. try
  62. {
  63. WwisePluginInterface.ovrAudio_GetPluginContext(out temp, ClientType.OVRA_CLIENT_TYPE_WWISE_UNKNOWN);
  64. Debug.Log("Propagation initialized with Wwise Oculus Spatializer plugin");
  65. return new WwisePluginInterface();
  66. }
  67. catch(System.DllNotFoundException)
  68. {
  69. // this is fine
  70. }
  71. try
  72. {
  73. FMODPluginInterface.ovrAudio_GetPluginContext(out temp, ClientType.OVRA_CLIENT_TYPE_FMOD);
  74. Debug.Log("Propagation initialized with FMOD Oculus Spatializer plugin");
  75. return new FMODPluginInterface();
  76. }
  77. catch (System.DllNotFoundException)
  78. {
  79. // this is fine
  80. }
  81. Debug.Log("Propagation initialized with Unity Oculus Spatializer plugin");
  82. return new UnityNativeInterface();
  83. }
  84. public enum ovrAudioScalarType : uint
  85. {
  86. Int8,
  87. UInt8,
  88. Int16,
  89. UInt16,
  90. Int32,
  91. UInt32,
  92. Int64,
  93. UInt64,
  94. Float16,
  95. Float32,
  96. Float64
  97. }
  98. public class ClientType
  99. {
  100. // Copied from AudioSDK\OVRAudio\OVR_Audio_Internal.h
  101. public const uint OVRA_CLIENT_TYPE_NATIVE = 0;
  102. public const uint OVRA_CLIENT_TYPE_WWISE_2016 = 1;
  103. public const uint OVRA_CLIENT_TYPE_WWISE_2017_1 = 2;
  104. public const uint OVRA_CLIENT_TYPE_WWISE_2017_2 = 3;
  105. public const uint OVRA_CLIENT_TYPE_WWISE_2018_1 = 4;
  106. public const uint OVRA_CLIENT_TYPE_FMOD = 5;
  107. public const uint OVRA_CLIENT_TYPE_UNITY = 6;
  108. public const uint OVRA_CLIENT_TYPE_UE4 = 7;
  109. public const uint OVRA_CLIENT_TYPE_VST = 8;
  110. public const uint OVRA_CLIENT_TYPE_AAX = 9;
  111. public const uint OVRA_CLIENT_TYPE_TEST = 10;
  112. public const uint OVRA_CLIENT_TYPE_OTHER = 11;
  113. public const uint OVRA_CLIENT_TYPE_WWISE_UNKNOWN = 12;
  114. }
  115. public interface PropagationInterface
  116. {
  117. /***********************************************************************************/
  118. // Settings API
  119. int SetPropagationQuality(float quality);
  120. int SetPropagationThreadAffinity(UInt64 cpuMask);
  121. /***********************************************************************************/
  122. // Geometry API
  123. int CreateAudioGeometry(out IntPtr geometry);
  124. int DestroyAudioGeometry(IntPtr geometry);
  125. int AudioGeometryUploadMeshArrays(IntPtr geometry,
  126. float[] vertices, int vertexCount,
  127. int[] indices, int indexCount,
  128. MeshGroup[] groups, int groupCount);
  129. int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  130. int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  131. int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  132. int AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  133. int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  134. /***********************************************************************************/
  135. // Material API
  136. int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  137. int CreateAudioMaterial(out IntPtr material);
  138. int DestroyAudioMaterial(IntPtr material);
  139. int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  140. int AudioMaterialReset(IntPtr material, MaterialProperty property);
  141. }
  142. /***********************************************************************************/
  143. // UNITY NATIVE
  144. /***********************************************************************************/
  145. public class UnityNativeInterface : PropagationInterface
  146. {
  147. // The name used for the plugin DLL.
  148. public const string strOSPS = "AudioPluginOculusSpatializer";
  149. /***********************************************************************************/
  150. // Context API: Required to create internal context if it does not exist yet
  151. IntPtr context_ = IntPtr.Zero;
  152. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_UNITY); } return context_; } }
  153. [DllImport(strOSPS)]
  154. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  155. /***********************************************************************************/
  156. // Settings API
  157. [DllImport(strOSPS)]
  158. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  159. public int SetPropagationQuality(float quality)
  160. {
  161. return ovrAudio_SetPropagationQuality(context, quality);
  162. }
  163. [DllImport(strOSPS)]
  164. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  165. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  166. {
  167. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  168. }
  169. /***********************************************************************************/
  170. // Geometry API
  171. [DllImport(strOSPS)]
  172. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  173. public int CreateAudioGeometry(out IntPtr geometry)
  174. {
  175. return ovrAudio_CreateAudioGeometry(context, out geometry);
  176. }
  177. [DllImport(strOSPS)]
  178. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  179. public int DestroyAudioGeometry(IntPtr geometry)
  180. {
  181. return ovrAudio_DestroyAudioGeometry(geometry);
  182. }
  183. [DllImport(strOSPS)]
  184. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  185. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  186. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  187. MeshGroup[] groups, UIntPtr groupCount);
  188. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  189. float[] vertices, int vertexCount,
  190. int[] indices, int indexCount,
  191. MeshGroup[] groups, int groupCount)
  192. {
  193. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  194. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  195. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  196. groups, (UIntPtr)groupCount);
  197. }
  198. [DllImport(strOSPS)]
  199. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  200. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  201. {
  202. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  203. }
  204. [DllImport(strOSPS)]
  205. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  206. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  207. {
  208. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  209. }
  210. [DllImport(strOSPS)]
  211. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  212. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  213. {
  214. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  215. }
  216. [DllImport(strOSPS)]
  217. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  218. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  219. {
  220. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  221. }
  222. [DllImport(strOSPS)]
  223. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  224. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  225. {
  226. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  227. }
  228. /***********************************************************************************/
  229. // Material API
  230. [DllImport(strOSPS)]
  231. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  232. public int CreateAudioMaterial(out IntPtr material)
  233. {
  234. return ovrAudio_CreateAudioMaterial(context, out material);
  235. }
  236. [DllImport(strOSPS)]
  237. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  238. public int DestroyAudioMaterial(IntPtr material)
  239. {
  240. return ovrAudio_DestroyAudioMaterial(material);
  241. }
  242. [DllImport(strOSPS)]
  243. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  244. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  245. {
  246. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  247. }
  248. [DllImport(strOSPS)]
  249. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  250. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  251. {
  252. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  253. }
  254. [DllImport(strOSPS)]
  255. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  256. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  257. {
  258. return ovrAudio_AudioMaterialReset(material, property);
  259. }
  260. }
  261. /***********************************************************************************/
  262. // WWISE
  263. /***********************************************************************************/
  264. public class WwisePluginInterface : PropagationInterface
  265. {
  266. // The name used for the plugin DLL.
  267. public const string strOSPS = "OculusSpatializerWwise";
  268. /***********************************************************************************/
  269. // Context API: Required to create internal context if it does not exist yet
  270. IntPtr context_ = IntPtr.Zero;
  271. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_WWISE_UNKNOWN); } return context_; } }
  272. [DllImport(strOSPS)]
  273. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  274. /***********************************************************************************/
  275. // Settings API
  276. [DllImport(strOSPS)]
  277. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  278. public int SetPropagationQuality(float quality)
  279. {
  280. return ovrAudio_SetPropagationQuality(context, quality);
  281. }
  282. [DllImport(strOSPS)]
  283. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  284. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  285. {
  286. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  287. }
  288. /***********************************************************************************/
  289. // Geometry API
  290. [DllImport(strOSPS)]
  291. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  292. public int CreateAudioGeometry(out IntPtr geometry)
  293. {
  294. return ovrAudio_CreateAudioGeometry(context, out geometry);
  295. }
  296. [DllImport(strOSPS)]
  297. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  298. public int DestroyAudioGeometry(IntPtr geometry)
  299. {
  300. return ovrAudio_DestroyAudioGeometry(geometry);
  301. }
  302. [DllImport(strOSPS)]
  303. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  304. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  305. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  306. MeshGroup[] groups, UIntPtr groupCount);
  307. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  308. float[] vertices, int vertexCount,
  309. int[] indices, int indexCount,
  310. MeshGroup[] groups, int groupCount)
  311. {
  312. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  313. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  314. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  315. groups, (UIntPtr)groupCount);
  316. }
  317. [DllImport(strOSPS)]
  318. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  319. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  320. {
  321. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  322. }
  323. [DllImport(strOSPS)]
  324. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  325. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  326. {
  327. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  328. }
  329. [DllImport(strOSPS)]
  330. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  331. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  332. {
  333. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  334. }
  335. [DllImport(strOSPS)]
  336. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  337. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  338. {
  339. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  340. }
  341. [DllImport(strOSPS)]
  342. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  343. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  344. {
  345. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  346. }
  347. /***********************************************************************************/
  348. // Material API
  349. [DllImport(strOSPS)]
  350. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  351. public int CreateAudioMaterial(out IntPtr material)
  352. {
  353. return ovrAudio_CreateAudioMaterial(context, out material);
  354. }
  355. [DllImport(strOSPS)]
  356. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  357. public int DestroyAudioMaterial(IntPtr material)
  358. {
  359. return ovrAudio_DestroyAudioMaterial(material);
  360. }
  361. [DllImport(strOSPS)]
  362. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  363. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  364. {
  365. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  366. }
  367. [DllImport(strOSPS)]
  368. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  369. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  370. {
  371. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  372. }
  373. [DllImport(strOSPS)]
  374. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  375. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  376. {
  377. return ovrAudio_AudioMaterialReset(material, property);
  378. }
  379. }
  380. /***********************************************************************************/
  381. // FMOD
  382. /***********************************************************************************/
  383. public class FMODPluginInterface : PropagationInterface
  384. {
  385. // The name used for the plugin DLL.
  386. public const string strOSPS = "OculusSpatializerFMOD";
  387. /***********************************************************************************/
  388. // Context API: Required to create internal context if it does not exist yet
  389. IntPtr context_ = IntPtr.Zero;
  390. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_FMOD); } return context_; } }
  391. [DllImport(strOSPS)]
  392. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  393. /***********************************************************************************/
  394. // Settings API
  395. [DllImport(strOSPS)]
  396. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  397. public int SetPropagationQuality(float quality)
  398. {
  399. return ovrAudio_SetPropagationQuality(context, quality);
  400. }
  401. [DllImport(strOSPS)]
  402. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  403. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  404. {
  405. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  406. }
  407. /***********************************************************************************/
  408. // Geometry API
  409. [DllImport(strOSPS)]
  410. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  411. public int CreateAudioGeometry(out IntPtr geometry)
  412. {
  413. return ovrAudio_CreateAudioGeometry(context, out geometry);
  414. }
  415. [DllImport(strOSPS)]
  416. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  417. public int DestroyAudioGeometry(IntPtr geometry)
  418. {
  419. return ovrAudio_DestroyAudioGeometry(geometry);
  420. }
  421. [DllImport(strOSPS)]
  422. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  423. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  424. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  425. MeshGroup[] groups, UIntPtr groupCount);
  426. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  427. float[] vertices, int vertexCount,
  428. int[] indices, int indexCount,
  429. MeshGroup[] groups, int groupCount)
  430. {
  431. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  432. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  433. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  434. groups, (UIntPtr)groupCount);
  435. }
  436. [DllImport(strOSPS)]
  437. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  438. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  439. {
  440. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  441. }
  442. [DllImport(strOSPS)]
  443. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  444. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  445. {
  446. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  447. }
  448. [DllImport(strOSPS)]
  449. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  450. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  451. {
  452. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  453. }
  454. [DllImport(strOSPS)]
  455. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  456. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  457. {
  458. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  459. }
  460. [DllImport(strOSPS)]
  461. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  462. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  463. {
  464. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  465. }
  466. /***********************************************************************************/
  467. // Material API
  468. [DllImport(strOSPS)]
  469. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  470. public int CreateAudioMaterial(out IntPtr material)
  471. {
  472. return ovrAudio_CreateAudioMaterial(context, out material);
  473. }
  474. [DllImport(strOSPS)]
  475. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  476. public int DestroyAudioMaterial(IntPtr material)
  477. {
  478. return ovrAudio_DestroyAudioMaterial(material);
  479. }
  480. [DllImport(strOSPS)]
  481. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  482. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  483. {
  484. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  485. }
  486. [DllImport(strOSPS)]
  487. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  488. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  489. {
  490. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  491. }
  492. [DllImport(strOSPS)]
  493. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  494. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  495. {
  496. return ovrAudio_AudioMaterialReset(material, property);
  497. }
  498. }
  499. }