Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

572 lines
26 KiB

  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. public const uint OVRA_CLIENT_TYPE_WWISE_2019_1 = 13;
  115. }
  116. public interface PropagationInterface
  117. {
  118. /***********************************************************************************/
  119. // Settings API
  120. int SetPropagationQuality(float quality);
  121. int SetPropagationThreadAffinity(UInt64 cpuMask);
  122. /***********************************************************************************/
  123. // Geometry API
  124. int CreateAudioGeometry(out IntPtr geometry);
  125. int DestroyAudioGeometry(IntPtr geometry);
  126. int AudioGeometryUploadMeshArrays(IntPtr geometry,
  127. float[] vertices, int vertexCount,
  128. int[] indices, int indexCount,
  129. MeshGroup[] groups, int groupCount);
  130. int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  131. int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  132. int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  133. int AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  134. int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  135. /***********************************************************************************/
  136. // Material API
  137. int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  138. int CreateAudioMaterial(out IntPtr material);
  139. int DestroyAudioMaterial(IntPtr material);
  140. int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  141. int AudioMaterialReset(IntPtr material, MaterialProperty property);
  142. }
  143. /***********************************************************************************/
  144. // UNITY NATIVE
  145. /***********************************************************************************/
  146. public class UnityNativeInterface : PropagationInterface
  147. {
  148. // The name used for the plugin DLL.
  149. public const string strOSPS = "AudioPluginOculusSpatializer";
  150. /***********************************************************************************/
  151. // Context API: Required to create internal context if it does not exist yet
  152. IntPtr context_ = IntPtr.Zero;
  153. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_UNITY); } return context_; } }
  154. [DllImport(strOSPS)]
  155. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  156. /***********************************************************************************/
  157. // Settings API
  158. [DllImport(strOSPS)]
  159. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  160. public int SetPropagationQuality(float quality)
  161. {
  162. return ovrAudio_SetPropagationQuality(context, quality);
  163. }
  164. [DllImport(strOSPS)]
  165. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  166. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  167. {
  168. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  169. }
  170. /***********************************************************************************/
  171. // Geometry API
  172. [DllImport(strOSPS)]
  173. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  174. public int CreateAudioGeometry(out IntPtr geometry)
  175. {
  176. return ovrAudio_CreateAudioGeometry(context, out geometry);
  177. }
  178. [DllImport(strOSPS)]
  179. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  180. public int DestroyAudioGeometry(IntPtr geometry)
  181. {
  182. return ovrAudio_DestroyAudioGeometry(geometry);
  183. }
  184. [DllImport(strOSPS)]
  185. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  186. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  187. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  188. MeshGroup[] groups, UIntPtr groupCount);
  189. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  190. float[] vertices, int vertexCount,
  191. int[] indices, int indexCount,
  192. MeshGroup[] groups, int groupCount)
  193. {
  194. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  195. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  196. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  197. groups, (UIntPtr)groupCount);
  198. }
  199. [DllImport(strOSPS)]
  200. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  201. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  202. {
  203. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  204. }
  205. [DllImport(strOSPS)]
  206. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  207. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  208. {
  209. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  210. }
  211. [DllImport(strOSPS)]
  212. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  213. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  214. {
  215. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  216. }
  217. [DllImport(strOSPS)]
  218. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  219. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  220. {
  221. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  222. }
  223. [DllImport(strOSPS)]
  224. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  225. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  226. {
  227. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  228. }
  229. /***********************************************************************************/
  230. // Material API
  231. [DllImport(strOSPS)]
  232. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  233. public int CreateAudioMaterial(out IntPtr material)
  234. {
  235. return ovrAudio_CreateAudioMaterial(context, out material);
  236. }
  237. [DllImport(strOSPS)]
  238. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  239. public int DestroyAudioMaterial(IntPtr material)
  240. {
  241. return ovrAudio_DestroyAudioMaterial(material);
  242. }
  243. [DllImport(strOSPS)]
  244. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  245. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  246. {
  247. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  248. }
  249. [DllImport(strOSPS)]
  250. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  251. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  252. {
  253. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  254. }
  255. [DllImport(strOSPS)]
  256. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  257. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  258. {
  259. return ovrAudio_AudioMaterialReset(material, property);
  260. }
  261. }
  262. /***********************************************************************************/
  263. // WWISE
  264. /***********************************************************************************/
  265. public class WwisePluginInterface : PropagationInterface
  266. {
  267. // The name used for the plugin DLL.
  268. public const string strOSPS = "OculusSpatializerWwise";
  269. /***********************************************************************************/
  270. // Context API: Required to create internal context if it does not exist yet
  271. IntPtr context_ = IntPtr.Zero;
  272. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_WWISE_UNKNOWN); } return context_; } }
  273. [DllImport(strOSPS)]
  274. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  275. /***********************************************************************************/
  276. // Settings API
  277. [DllImport(strOSPS)]
  278. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  279. public int SetPropagationQuality(float quality)
  280. {
  281. return ovrAudio_SetPropagationQuality(context, quality);
  282. }
  283. [DllImport(strOSPS)]
  284. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  285. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  286. {
  287. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  288. }
  289. /***********************************************************************************/
  290. // Geometry API
  291. [DllImport(strOSPS)]
  292. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  293. public int CreateAudioGeometry(out IntPtr geometry)
  294. {
  295. return ovrAudio_CreateAudioGeometry(context, out geometry);
  296. }
  297. [DllImport(strOSPS)]
  298. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  299. public int DestroyAudioGeometry(IntPtr geometry)
  300. {
  301. return ovrAudio_DestroyAudioGeometry(geometry);
  302. }
  303. [DllImport(strOSPS)]
  304. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  305. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  306. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  307. MeshGroup[] groups, UIntPtr groupCount);
  308. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  309. float[] vertices, int vertexCount,
  310. int[] indices, int indexCount,
  311. MeshGroup[] groups, int groupCount)
  312. {
  313. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  314. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  315. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  316. groups, (UIntPtr)groupCount);
  317. }
  318. [DllImport(strOSPS)]
  319. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  320. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  321. {
  322. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  323. }
  324. [DllImport(strOSPS)]
  325. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  326. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  327. {
  328. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  329. }
  330. [DllImport(strOSPS)]
  331. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  332. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  333. {
  334. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  335. }
  336. [DllImport(strOSPS)]
  337. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  338. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  339. {
  340. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  341. }
  342. [DllImport(strOSPS)]
  343. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  344. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  345. {
  346. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  347. }
  348. /***********************************************************************************/
  349. // Material API
  350. [DllImport(strOSPS)]
  351. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  352. public int CreateAudioMaterial(out IntPtr material)
  353. {
  354. return ovrAudio_CreateAudioMaterial(context, out material);
  355. }
  356. [DllImport(strOSPS)]
  357. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  358. public int DestroyAudioMaterial(IntPtr material)
  359. {
  360. return ovrAudio_DestroyAudioMaterial(material);
  361. }
  362. [DllImport(strOSPS)]
  363. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  364. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  365. {
  366. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  367. }
  368. [DllImport(strOSPS)]
  369. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  370. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  371. {
  372. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  373. }
  374. [DllImport(strOSPS)]
  375. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  376. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  377. {
  378. return ovrAudio_AudioMaterialReset(material, property);
  379. }
  380. }
  381. /***********************************************************************************/
  382. // FMOD
  383. /***********************************************************************************/
  384. public class FMODPluginInterface : PropagationInterface
  385. {
  386. // The name used for the plugin DLL.
  387. public const string strOSPS = "OculusSpatializerFMOD";
  388. /***********************************************************************************/
  389. // Context API: Required to create internal context if it does not exist yet
  390. IntPtr context_ = IntPtr.Zero;
  391. IntPtr context { get { if (context_ == IntPtr.Zero) { ovrAudio_GetPluginContext(out context_, ClientType.OVRA_CLIENT_TYPE_FMOD); } return context_; } }
  392. [DllImport(strOSPS)]
  393. public static extern int ovrAudio_GetPluginContext(out IntPtr context, uint clientType);
  394. /***********************************************************************************/
  395. // Settings API
  396. [DllImport(strOSPS)]
  397. private static extern int ovrAudio_SetPropagationQuality(IntPtr context, float quality);
  398. public int SetPropagationQuality(float quality)
  399. {
  400. return ovrAudio_SetPropagationQuality(context, quality);
  401. }
  402. [DllImport(strOSPS)]
  403. private static extern int ovrAudio_SetPropagationThreadAffinity(IntPtr context, UInt64 cpuMask);
  404. public int SetPropagationThreadAffinity(UInt64 cpuMask)
  405. {
  406. return ovrAudio_SetPropagationThreadAffinity(context, cpuMask);
  407. }
  408. /***********************************************************************************/
  409. // Geometry API
  410. [DllImport(strOSPS)]
  411. private static extern int ovrAudio_CreateAudioGeometry(IntPtr context, out IntPtr geometry);
  412. public int CreateAudioGeometry(out IntPtr geometry)
  413. {
  414. return ovrAudio_CreateAudioGeometry(context, out geometry);
  415. }
  416. [DllImport(strOSPS)]
  417. private static extern int ovrAudio_DestroyAudioGeometry(IntPtr geometry);
  418. public int DestroyAudioGeometry(IntPtr geometry)
  419. {
  420. return ovrAudio_DestroyAudioGeometry(geometry);
  421. }
  422. [DllImport(strOSPS)]
  423. private static extern int ovrAudio_AudioGeometryUploadMeshArrays(IntPtr geometry,
  424. float[] vertices, UIntPtr verticesBytesOffset, UIntPtr vertexCount, UIntPtr vertexStride, ovrAudioScalarType vertexType,
  425. int[] indices, UIntPtr indicesByteOffset, UIntPtr indexCount, ovrAudioScalarType indexType,
  426. MeshGroup[] groups, UIntPtr groupCount);
  427. public int AudioGeometryUploadMeshArrays(IntPtr geometry,
  428. float[] vertices, int vertexCount,
  429. int[] indices, int indexCount,
  430. MeshGroup[] groups, int groupCount)
  431. {
  432. return ovrAudio_AudioGeometryUploadMeshArrays(geometry,
  433. vertices, UIntPtr.Zero, (UIntPtr)vertexCount, UIntPtr.Zero, ovrAudioScalarType.Float32,
  434. indices, UIntPtr.Zero, (UIntPtr)indexCount, ovrAudioScalarType.UInt32,
  435. groups, (UIntPtr)groupCount);
  436. }
  437. [DllImport(strOSPS)]
  438. private static extern int ovrAudio_AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4);
  439. public int AudioGeometrySetTransform(IntPtr geometry, float[] matrix4x4)
  440. {
  441. return ovrAudio_AudioGeometrySetTransform(geometry, matrix4x4);
  442. }
  443. [DllImport(strOSPS)]
  444. private static extern int ovrAudio_AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4);
  445. public int AudioGeometryGetTransform(IntPtr geometry, out float[] matrix4x4)
  446. {
  447. return ovrAudio_AudioGeometryGetTransform(geometry, out matrix4x4);
  448. }
  449. [DllImport(strOSPS)]
  450. private static extern int ovrAudio_AudioGeometryWriteMeshFile(IntPtr geometry, string filePath);
  451. public int AudioGeometryWriteMeshFile(IntPtr geometry, string filePath)
  452. {
  453. return ovrAudio_AudioGeometryWriteMeshFile(geometry, filePath);
  454. }
  455. [DllImport(strOSPS)]
  456. private static extern int ovrAudio_AudioGeometryReadMeshFile(IntPtr geometry, string filePath);
  457. public int AudioGeometryReadMeshFile(IntPtr geometry, string filePath)
  458. {
  459. return ovrAudio_AudioGeometryReadMeshFile(geometry, filePath);
  460. }
  461. [DllImport(strOSPS)]
  462. private static extern int ovrAudio_AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath);
  463. public int AudioGeometryWriteMeshFileObj(IntPtr geometry, string filePath)
  464. {
  465. return ovrAudio_AudioGeometryWriteMeshFileObj(geometry, filePath);
  466. }
  467. /***********************************************************************************/
  468. // Material API
  469. [DllImport(strOSPS)]
  470. private static extern int ovrAudio_CreateAudioMaterial(IntPtr context, out IntPtr material);
  471. public int CreateAudioMaterial(out IntPtr material)
  472. {
  473. return ovrAudio_CreateAudioMaterial(context, out material);
  474. }
  475. [DllImport(strOSPS)]
  476. private static extern int ovrAudio_DestroyAudioMaterial(IntPtr material);
  477. public int DestroyAudioMaterial(IntPtr material)
  478. {
  479. return ovrAudio_DestroyAudioMaterial(material);
  480. }
  481. [DllImport(strOSPS)]
  482. private static extern int ovrAudio_AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value);
  483. public int AudioMaterialSetFrequency(IntPtr material, MaterialProperty property, float frequency, float value)
  484. {
  485. return ovrAudio_AudioMaterialSetFrequency(material, property, frequency, value);
  486. }
  487. [DllImport(strOSPS)]
  488. private static extern int ovrAudio_AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value);
  489. public int AudioMaterialGetFrequency(IntPtr material, MaterialProperty property, float frequency, out float value)
  490. {
  491. return ovrAudio_AudioMaterialGetFrequency(material, property, frequency, out value);
  492. }
  493. [DllImport(strOSPS)]
  494. private static extern int ovrAudio_AudioMaterialReset(IntPtr material, MaterialProperty property);
  495. public int AudioMaterialReset(IntPtr material, MaterialProperty property)
  496. {
  497. return ovrAudio_AudioMaterialReset(material, property);
  498. }
  499. }
  500. }