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