├── ProjectSettings ├── ProjectVersion.txt ├── ClusterInputManager.asset ├── PresetManager.asset ├── MultiplayerManager.asset ├── XRSettings.asset ├── VersionControlSettings.asset ├── TimeManager.asset ├── EditorBuildSettings.asset ├── VFXManager.asset ├── BurstAotSettings_StandaloneLinux64.json ├── BurstAotSettings_StandaloneWindows.json ├── BurstAotSettings_StandaloneOSX.json ├── AudioManager.asset ├── TagManager.asset ├── UnityConnectSettings.asset ├── PackageManagerSettings.asset ├── EditorSettings.asset ├── DynamicsManager.asset ├── MemorySettings.asset ├── QualitySettings.asset ├── NavMeshAreas.asset ├── Physics2DSettings.asset ├── GraphicsSettings.asset ├── SceneTemplateSettings.json ├── InputManager.asset └── ProjectSettings.asset ├── Packages ├── manifest.json ├── jp.keijiro.libsoundio │ ├── Runtime │ │ ├── Linux │ │ │ ├── libsoundio.so │ │ │ └── libsoundio.so.meta │ │ ├── MacOS │ │ │ ├── soundio.bundle │ │ │ └── soundio.bundle.meta │ │ ├── Windows │ │ │ ├── soundio.dll │ │ │ └── soundio.dll.meta │ │ ├── Linux.meta │ │ ├── MacOS.meta │ │ ├── Windows.meta │ │ ├── SoundIO.Runtime.asmdef.meta │ │ ├── Config.cs │ │ ├── Config.cs.meta │ │ ├── Context.cs.meta │ │ ├── Device.cs.meta │ │ ├── Enum.cs.meta │ │ ├── Struct.cs.meta │ │ ├── Unsafe.cs.meta │ │ ├── InStream.cs.meta │ │ ├── ChannelLayout.cs.meta │ │ ├── Unsafe.cs │ │ ├── Struct.cs │ │ ├── SoundIO.Runtime.asmdef │ │ ├── ChannelLayout.cs │ │ ├── Enum.cs │ │ ├── Device.cs │ │ ├── Context.cs │ │ └── InStream.cs │ ├── LICENSE.meta │ ├── README.md.meta │ ├── package.json.meta │ ├── Runtime.meta │ ├── package.json │ ├── LICENSE │ └── README.md └── packages-lock.json ├── Assets ├── Test.unity.meta ├── Test.meta ├── SimpleDriver.meta ├── Test │ ├── Line1.mat.meta │ ├── Line2.mat.meta │ ├── Ltc.cs.meta │ ├── DftBuffer.cs.meta │ ├── Utility.cs.meta │ ├── BiquadFilter.cs.meta │ ├── DeviceSelector.cs.meta │ ├── LevelMeter.cs.meta │ ├── SpectrumAnalyzer.cs.meta │ ├── TimecodeIndicator.cs.meta │ ├── WaveformRenderer.cs.meta │ ├── TimecodeIndicator.cs │ ├── BiquadFilter.cs │ ├── Utility.cs │ ├── Line1.mat │ ├── Line2.mat │ ├── WaveformRenderer.cs │ ├── LevelMeter.cs │ ├── SpectrumAnalyzer.cs │ ├── Ltc.cs │ ├── DeviceSelector.cs │ └── DftBuffer.cs └── SimpleDriver │ ├── InputStream.cs.meta │ ├── RingBuffer.cs.meta │ ├── DeviceDriver.cs.meta │ ├── RingBuffer.cs │ ├── DeviceDriver.cs │ └── InputStream.cs ├── .gitattributes ├── .gitignore ├── .github └── workflows │ └── main.yml ├── README.md └── LICENSE /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 6000.0.59f2 2 | m_EditorVersionWithRevision: 6000.0.59f2 (ef281c76c3c1) 3 | -------------------------------------------------------------------------------- /Packages/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": "1.8.25", 4 | "com.unity.ugui": "2.0.0" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Linux/libsoundio.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/jp.keijiro.libsoundio/HEAD/Packages/jp.keijiro.libsoundio/Runtime/Linux/libsoundio.so -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/MacOS/soundio.bundle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/jp.keijiro.libsoundio/HEAD/Packages/jp.keijiro.libsoundio/Runtime/MacOS/soundio.bundle -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Windows/soundio.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/jp.keijiro.libsoundio/HEAD/Packages/jp.keijiro.libsoundio/Runtime/Windows/soundio.dll -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!236 &1 4 | ClusterInputManager: 5 | m_ObjectHideFlags: 0 6 | m_Inputs: [] 7 | -------------------------------------------------------------------------------- /Assets/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3201003274822ed4b8b8dc3eaf700fc5 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/PresetManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1386491679 &1 4 | PresetManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_DefaultPresets: {} 8 | -------------------------------------------------------------------------------- /Assets/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 208fec832b1bc25e3ae356aaa794513f 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * -text 2 | 3 | *.cs text eol=lf diff=csharp 4 | *.shader text eol=lf 5 | *.cginc text eol=lf 6 | *.hlsl text eol=lf 7 | *.compute text eol=lf 8 | 9 | *.meta text eol=lf 10 | -------------------------------------------------------------------------------- /Assets/SimpleDriver.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee55e6ec2e84b5d4594877966583d8c3 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/LICENSE.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 91c11909cc198d1a2bcf322c75acd2c3 3 | DefaultImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/MultiplayerManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!655991488 &1 4 | MultiplayerManager: 5 | m_ObjectHideFlags: 0 6 | m_EnableMultiplayerRoles: 0 7 | m_StrippingTypes: {} 8 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/README.md.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f1864442aabc7714a9d686c9273754ec 3 | TextScriptImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /ProjectSettings/XRSettings.asset: -------------------------------------------------------------------------------- 1 | { 2 | "m_SettingKeys": [ 3 | "VR Device Disabled", 4 | "VR Device User Alert" 5 | ], 6 | "m_SettingValues": [ 7 | "False", 8 | "False" 9 | ] 10 | } -------------------------------------------------------------------------------- /Assets/Test/Line1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7baa6452cd667084e86b064a40321d3b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/Line2.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 998d188accde3894ba0f27357748be8b 3 | NativeFormatImporter: 4 | externalObjects: {} 5 | mainObjectFileID: 0 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/package.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 088ff2360daa7f944847cd641766c1d6 3 | PackageManifestImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 448ee0e50afd8f845b4c4e7ffdde87d6 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /ProjectSettings/VersionControlSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!890905787 &1 4 | VersionControlSettings: 5 | m_ObjectHideFlags: 0 6 | m_Mode: Visible Meta Files 7 | m_TrackPackagesOutsideProject: 0 8 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Linux.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1944fc49556caa84ea8c51ab6a8874dc 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/MacOS.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ab778ba3f8174585b3199970516b097 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Windows.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e3d8b1cdf44497b43aa8f6330bcbf8ee 3 | folderAsset: yes 4 | DefaultImporter: 5 | externalObjects: {} 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/SoundIO.Runtime.asmdef.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e0966a2366ad464888a2470749e8879 3 | AssemblyDefinitionImporter: 4 | externalObjects: {} 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Config.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | namespace SoundIO 5 | { 6 | static class Config { internal const string DllName = "soundio.dll"; } 7 | } 8 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: 0.02 7 | Maximum Allowed Timestep: 0.33333334 8 | m_TimeScale: 1 9 | Maximum Particle Timestep: 0.03 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Windows 2 | Thumbs.db 3 | Desktop.ini 4 | 5 | # macOS 6 | .DS_Store 7 | 8 | # Code Editors 9 | /.idea 10 | /.vscode 11 | /*.csproj 12 | /*.sln 13 | *.swp 14 | *.vcxproj.user 15 | 16 | # Unity 17 | /Library 18 | /Logs 19 | /Recordings 20 | /Temp 21 | /UIElementsSchema 22 | /UserSettings 23 | -------------------------------------------------------------------------------- /Assets/Test/Ltc.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a85e8b0e1113d52438ba0ffc013d6ff9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/DftBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 71c0ba8427c0a674499fb77bdaf9f1d6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/Utility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 76ebff911c3f5774697843613227e470 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/BiquadFilter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d076d437dfb3e6db90ef293634086f9 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/DeviceSelector.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10088a742a67f544f84ed267b5304670 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/LevelMeter.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 923ee8baa01f6c0f8a8b6f335767e882 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SimpleDriver/InputStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b657362afd1d4081091ea18824b16bf1 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SimpleDriver/RingBuffer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2cd1324b137fbdef094f372822e338e3 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/SpectrumAnalyzer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 67a7caa138d3d6c4f8e0c7f34aba43ad 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/TimecodeIndicator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b3aa3b9030c75e9468534ee2ffd7119c 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/Test/WaveformRenderer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2711405b083e76e4bad6382e033c30a6 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/SimpleDriver/DeviceDriver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 452c837dbdca7374eaade87f4d5987dd 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: 8 | - enabled: 1 9 | path: Assets/Test.unity 10 | guid: 3201003274822ed4b8b8dc3eaf700fc5 11 | m_configObjects: {} 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Config.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f03f5dd7ff4371548e863d5a5880c50 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Context.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 953ce7a1a82130646868d090e2d72f03 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Device.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f3c3bc3c7706b3c478fd6caf49b9912f 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Enum.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 980a553241dd1a846b50bb00dbdc0198 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Struct.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8d0f83ec293448d4ba17415998dd0c7b 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Unsafe.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 553f790599bde4e569a23802e5ff03b7 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/InStream.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34eee938bb28a3c4d84a6c92e0413cae 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/ChannelLayout.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4ad6c0f10cd45c44b1afc2ed3c3dd4e 3 | MonoImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | defaultReferences: [] 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /ProjectSettings/VFXManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!937362698 &1 4 | VFXManager: 5 | m_ObjectHideFlags: 0 6 | m_IndirectShader: {fileID: 0} 7 | m_CopyBufferShader: {fileID: 0} 8 | m_SortShader: {fileID: 0} 9 | m_StripUpdateShader: {fileID: 0} 10 | m_RenderPipeSettingsPath: 11 | m_FixedTimeStep: 0.016666668 12 | m_MaxDeltaTime: 0.05 13 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Keijiro Takahashi", 3 | "description": "libsoundio for Unity", 4 | "displayName": "libsoundio", 5 | "keywords": [ "unity" ], 6 | "license": "MIT", 7 | "name": "jp.keijiro.libsoundio", 8 | "repository": "github:keijiro/jp.keijiro.libsoundio", 9 | "unity": "2019.3", 10 | "unityRelease": "1f1", 11 | "version": "1.0.6" 12 | } 13 | -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneLinux64.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "m_Enabled": true, 4 | "m_EditorHideFlags": 0, 5 | "m_Name": "", 6 | "m_EditorClassIdentifier": "Unity.Burst.Editor:Unity.Burst.Editor:BurstPlatformAotSettings", 7 | "DisableOptimisations": false, 8 | "DisableSafetyChecks": true, 9 | "DisableBurstCompilation": false 10 | } 11 | } -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneWindows.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "m_Enabled": true, 4 | "m_EditorHideFlags": 0, 5 | "m_Name": "", 6 | "m_EditorClassIdentifier": "Unity.Burst.Editor:Unity.Burst.Editor:BurstPlatformAotSettings", 7 | "DisableOptimisations": false, 8 | "DisableSafetyChecks": true, 9 | "DisableBurstCompilation": false 10 | } 11 | } -------------------------------------------------------------------------------- /ProjectSettings/BurstAotSettings_StandaloneOSX.json: -------------------------------------------------------------------------------- 1 | { 2 | "MonoBehaviour": { 3 | "Version": 3, 4 | "EnableBurstCompilation": true, 5 | "EnableOptimisations": true, 6 | "EnableSafetyChecks": false, 7 | "EnableDebugInAllBuilds": false, 8 | "UsePlatformSDKLinker": false, 9 | "CpuMinTargetX32": 0, 10 | "CpuMaxTargetX32": 0, 11 | "CpuMinTargetX64": 0, 12 | "CpuMaxTargetX64": 0, 13 | "CpuTargetsX64": 72 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: UPM on npsjs.com 2 | on: 3 | release: 4 | types: [created] 5 | jobs: 6 | publish: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - uses: actions/setup-node@v2 11 | with: 12 | registry-url: 'https://registry.npmjs.org' 13 | - run: npm publish 14 | working-directory: Packages/jp.keijiro.libsoundio 15 | env: 16 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} 17 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Unsafe.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | namespace SoundIO 5 | { 6 | static class Unsafe 7 | { 8 | public unsafe static ref T AsRef(void* p) where T : struct 9 | #if USE_UNITY_UNSAFE_UTILITY 10 | => ref Unity.Collections.LowLevel.Unsafe.UnsafeUtility.AsRef(p); 11 | #else 12 | => ref System.Runtime.CompilerServices.Unsafe.AsRef(p); 13 | #endif 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Volume: 1 8 | Rolloff Scale: 1 9 | Doppler Factor: 1 10 | Default Speaker Mode: 2 11 | m_SampleRate: 0 12 | m_DSPBufferSize: 1024 13 | m_VirtualVoiceCount: 512 14 | m_RealVoiceCount: 32 15 | m_SpatializerPlugin: 16 | m_AmbisonicDecoderPlugin: 17 | m_DisableAudio: 0 18 | m_VirtualizeEffects: 1 19 | m_RequestedDSPBufferSize: 1024 20 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Struct.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace SoundIO 8 | { 9 | // Basic structs defined in libsoundio 10 | 11 | [StructLayout(LayoutKind.Sequential)] 12 | public struct SampleRateRange 13 | { 14 | public int Min; 15 | public int Max; 16 | } 17 | 18 | [StructLayout(LayoutKind.Sequential)] 19 | public struct ChannelArea 20 | { 21 | public IntPtr Pointer; 22 | public int Step; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Assets/Test/TimecodeIndicator.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEngine.UI; 3 | 4 | // LTC (linear timecode) indicator 5 | 6 | public sealed class TimecodeIndicator : MonoBehaviour 7 | { 8 | [SerializeField] DeviceSelector _selector = null; 9 | [SerializeField] Text _label = null; 10 | 11 | Ltc.TimecodeDecoder _decoder = new Ltc.TimecodeDecoder(); 12 | 13 | void Update() 14 | { 15 | _decoder.ParseAudioData(_selector.AudioDataSpan); 16 | var tc = _decoder.LastTimecode; 17 | var drop = tc.dropFrame ? " (drop frame)" : " (non-drop frame)"; 18 | _label.text = tc.ToString() + drop; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Windows/soundio.dll.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a64a2d5dc04a004eab5d4eff6b91eb8 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 1 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 0 23 | settings: 24 | DefaultValueInitialized: true 25 | userData: 26 | assetBundleName: 27 | assetBundleVariant: 28 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/SoundIO.Runtime.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SoundIO.Runtime", 3 | "references": [], 4 | "includePlatforms": [ 5 | "Editor", 6 | "LinuxStandalone64", 7 | "macOSStandalone", 8 | "WindowsStandalone64" 9 | ], 10 | "excludePlatforms": [], 11 | "allowUnsafeCode": true, 12 | "overrideReferences": false, 13 | "precompiledReferences": [], 14 | "autoReferenced": true, 15 | "defineConstraints": [], 16 | "versionDefines": [ 17 | { 18 | "name": "Unity", 19 | "expression": "2021.2.0b6", 20 | "define": "USE_UNITY_UNSAFE_UTILITY" 21 | } 22 | ], 23 | "noEngineReferences": false 24 | } -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/MacOS/soundio.bundle.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 763de16360116427996139f2a6f96948 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 1 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | Any: 16 | second: 17 | enabled: 0 18 | settings: {} 19 | - first: 20 | Editor: Editor 21 | second: 22 | enabled: 1 23 | settings: 24 | DefaultValueInitialized: true 25 | - first: 26 | Standalone: OSXUniversal 27 | second: 28 | enabled: 1 29 | settings: 30 | CPU: AnyCPU 31 | userData: 32 | assetBundleName: 33 | assetBundleVariant: 34 | -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!310 &1 4 | UnityConnectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 1 7 | m_Enabled: 0 8 | m_TestMode: 0 9 | m_EventOldUrl: https://api.uca.cloud.unity3d.com/v1/events 10 | m_EventUrl: https://cdp.cloud.unity3d.com/v1/events 11 | m_ConfigUrl: https://config.uca.cloud.unity3d.com 12 | m_TestInitMode: 0 13 | CrashReportingSettings: 14 | m_EventUrl: https://perf-events.cloud.unity3d.com 15 | m_Enabled: 0 16 | m_LogBufferSize: 10 17 | m_CaptureEditorExceptions: 1 18 | UnityPurchasingSettings: 19 | m_Enabled: 0 20 | m_TestMode: 0 21 | UnityAnalyticsSettings: 22 | m_Enabled: 0 23 | m_TestMode: 0 24 | m_InitializeOnStartup: 1 25 | UnityAdsSettings: 26 | m_Enabled: 0 27 | m_InitializeOnStartup: 1 28 | m_TestMode: 0 29 | m_IosGameId: 30 | m_AndroidGameId: 31 | m_GameIds: {} 32 | m_GameId: 33 | PerformanceReportingSettings: 34 | m_Enabled: 0 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libsoundio Package for Unity 2 | 3 | ![gif](https://i.imgur.com/lxWgeaA.gif) 4 | 5 | This repository contains a Unity package that provides a C# wrapper for [libsoundio]. 6 | 7 | [libsoundio]: https://github.com/andrewrk/libsoundio 8 | 9 | Currently, only the audio input features are implemented, as the primary focus 10 | of this project is to provide low-latency audio input for Unity. 11 | 12 | ## System Requirements 13 | 14 | - Unity 2019.4 or later 15 | - 64-bit desktop platforms (Windows, macOS, Linux) 16 | 17 | ## Installation 18 | 19 | You can install the libsoundio package (`jp.keijiro.libsoundio`) via the "Keijiro" 20 | scoped registry using the Unity Package Manager. To add the registry to your project, 21 | please follow [these instructions]. 22 | 23 | [these instructions]: 24 | https://gist.github.com/keijiro/f8c7e8ff29bfe63d86b888901b82644c 25 | 26 | ## Related Repository 27 | 28 | I have made some modifications to libsoundio to address issues encountered during 29 | its integration with Unity. For more details, please refer to the following fork: 30 | 31 | https://github.com/keijiro/libsoundio 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (Expat) 2 | 3 | Copyright (c) 2015 Andrew Kelley 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/PackageManagerSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!114 &1 4 | MonoBehaviour: 5 | m_ObjectHideFlags: 61 6 | m_CorrespondingSourceObject: {fileID: 0} 7 | m_PrefabInstance: {fileID: 0} 8 | m_PrefabAsset: {fileID: 0} 9 | m_GameObject: {fileID: 0} 10 | m_Enabled: 1 11 | m_EditorHideFlags: 0 12 | m_Script: {fileID: 13964, guid: 0000000000000000e000000000000000, type: 0} 13 | m_Name: 14 | m_EditorClassIdentifier: 15 | m_EnablePreReleasePackages: 0 16 | m_AdvancedSettingsExpanded: 1 17 | m_ScopedRegistriesSettingsExpanded: 1 18 | m_SeeAllPackageVersions: 0 19 | m_DismissPreviewPackagesInUse: 0 20 | oneTimeWarningShown: 0 21 | oneTimeDeprecatedPopUpShown: 0 22 | m_Registries: 23 | - m_Id: main 24 | m_Name: 25 | m_Url: https://packages.unity.com 26 | m_Scopes: [] 27 | m_IsDefault: 1 28 | m_Capabilities: 7 29 | m_ConfigSource: 0 30 | m_UserSelectedRegistryName: 31 | m_UserAddingNewScopedRegistry: 0 32 | m_RegistryInfoDraft: 33 | m_Modified: 0 34 | m_ErrorMessage: 35 | m_UserModificationsInstanceId: -892 36 | m_OriginalInstanceId: -896 37 | m_LoadAssets: 0 38 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (Expat) 2 | 3 | Copyright (c) 2015 Andrew Kelley 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 9 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_LineEndingsForNewScripts: 1 10 | m_DefaultBehaviorMode: 0 11 | m_PrefabRegularEnvironment: {fileID: 0} 12 | m_PrefabUIEnvironment: {fileID: 0} 13 | m_SpritePackerMode: 0 14 | m_SpritePackerPaddingPower: 1 15 | m_EtcTextureCompressorBehavior: 1 16 | m_EtcTextureFastCompressor: 1 17 | m_EtcTextureNormalCompressor: 2 18 | m_EtcTextureBestCompressor: 4 19 | m_ProjectGenerationIncludedExtensions: txt;xml;fnt;cd;asmdef;rsp;asmref 20 | m_ProjectGenerationRootNamespace: 21 | m_CollabEditorSettings: 22 | inProgressEnabled: 1 23 | m_EnableTextureStreamingInEditMode: 1 24 | m_EnableTextureStreamingInPlayMode: 1 25 | m_AsyncShaderCompilation: 1 26 | m_EnterPlayModeOptionsEnabled: 1 27 | m_EnterPlayModeOptions: 1 28 | m_ShowLightmapResolutionOverlay: 1 29 | m_UseLegacyProbeSampleCount: 1 30 | m_AssetPipelineMode: 1 31 | m_CacheServerMode: 0 32 | m_CacheServerEndpoint: 33 | m_CacheServerNamespacePrefix: default 34 | m_CacheServerEnableDownload: 1 35 | m_CacheServerEnableUpload: 1 36 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 11 7 | m_Gravity: {x: 0, y: -9.81, z: 0} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_BounceThreshold: 2 10 | m_SleepThreshold: 0.005 11 | m_DefaultContactOffset: 0.01 12 | m_DefaultSolverIterations: 6 13 | m_DefaultSolverVelocityIterations: 1 14 | m_QueriesHitBackfaces: 0 15 | m_QueriesHitTriggers: 1 16 | m_EnableAdaptiveForce: 0 17 | m_ClothInterCollisionDistance: 0 18 | m_ClothInterCollisionStiffness: 0 19 | m_ContactsGeneration: 1 20 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 21 | m_AutoSimulation: 1 22 | m_AutoSyncTransforms: 0 23 | m_ReuseCollisionCallbacks: 1 24 | m_ClothInterCollisionSettingsToggle: 0 25 | m_ContactPairsMode: 0 26 | m_BroadphaseType: 0 27 | m_WorldBounds: 28 | m_Center: {x: 0, y: 0, z: 0} 29 | m_Extent: {x: 250, y: 250, z: 250} 30 | m_WorldSubdivisions: 8 31 | m_FrictionType: 0 32 | m_EnableEnhancedDeterminism: 0 33 | m_EnableUnifiedHeightmaps: 1 34 | m_DefaultMaxAngluarSpeed: 7 35 | -------------------------------------------------------------------------------- /ProjectSettings/MemorySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!387306366 &1 4 | MemorySettings: 5 | m_ObjectHideFlags: 0 6 | m_EditorMemorySettings: 7 | m_MainAllocatorBlockSize: -1 8 | m_ThreadAllocatorBlockSize: -1 9 | m_MainGfxBlockSize: -1 10 | m_ThreadGfxBlockSize: -1 11 | m_CacheBlockSize: -1 12 | m_TypetreeBlockSize: -1 13 | m_ProfilerBlockSize: -1 14 | m_ProfilerEditorBlockSize: -1 15 | m_BucketAllocatorGranularity: -1 16 | m_BucketAllocatorBucketsCount: -1 17 | m_BucketAllocatorBlockSize: -1 18 | m_BucketAllocatorBlockCount: -1 19 | m_ProfilerBucketAllocatorGranularity: -1 20 | m_ProfilerBucketAllocatorBucketsCount: -1 21 | m_ProfilerBucketAllocatorBlockSize: -1 22 | m_ProfilerBucketAllocatorBlockCount: -1 23 | m_TempAllocatorSizeMain: -1 24 | m_JobTempAllocatorBlockSize: -1 25 | m_BackgroundJobTempAllocatorBlockSize: -1 26 | m_JobTempAllocatorReducedBlockSize: -1 27 | m_TempAllocatorSizeGIBakingWorker: -1 28 | m_TempAllocatorSizeNavMeshWorker: -1 29 | m_TempAllocatorSizeAudioWorker: -1 30 | m_TempAllocatorSizeCloudWorker: -1 31 | m_TempAllocatorSizeGfx: -1 32 | m_TempAllocatorSizeJobWorker: -1 33 | m_TempAllocatorSizeBackgroundWorker: -1 34 | m_TempAllocatorSizePreloadManager: -1 35 | m_PlatformMemorySettings: {} 36 | -------------------------------------------------------------------------------- /Assets/Test/BiquadFilter.cs: -------------------------------------------------------------------------------- 1 | using Unity.Mathematics; 2 | 3 | // Three-band (+ bypass) filter with a biquad IIR filter 4 | // based on the EarLevel Engineering blog article. 5 | // http://www.earlevel.com/main/2012/11/26/biquad-c-source-code/ 6 | 7 | public struct MultibandFilter 8 | { 9 | float4 _a0, _a1, _a2; 10 | float _b1, _b2; 11 | float4 _z1, _z2; 12 | 13 | static readonly float4 _xmask = math.float4(0, 1, 1, 1); 14 | 15 | public void SetParameter(float Fc, float Q) 16 | { 17 | var K = math.tan((float)math.PI * Fc); 18 | var norm = 1 / (1 + K / Q + K * K); 19 | 20 | // x: Bypass 21 | _a0.x = 1; 22 | _a1.x = 0; 23 | _a2.x = 0; 24 | 25 | // y: Lowpass 26 | _a0.y = K * K * norm; 27 | _a1.y = 2 * _a0.y; 28 | _a2.y = _a0.y; 29 | 30 | // z: Bandpass 31 | _a0.z = K / Q * norm; 32 | _a1.z = 0; 33 | _a2.z = -_a0.z; 34 | 35 | // w: Highpass 36 | _a0.w = norm; 37 | _a1.w = -2 * _a0.w; 38 | _a2.w = _a0.w; 39 | 40 | _b1 = 2 * (K * K - 1) * norm; 41 | _b2 = (1 - K / Q + K * K) * norm; 42 | } 43 | 44 | public float4 FeedSample(float i) 45 | { 46 | var o = _a0 * i + _z1 * _xmask; 47 | _z1 = _a1 * i + _z2 - o * _b1; 48 | _z2 = _a2 * i - o * _b2; 49 | return o; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Linux/libsoundio.so.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5e65223dc085b5b42a20d5201bc5b74d 3 | PluginImporter: 4 | externalObjects: {} 5 | serializedVersion: 2 6 | iconMap: {} 7 | executionOrder: {} 8 | defineConstraints: [] 9 | isPreloaded: 0 10 | isOverridable: 0 11 | isExplicitlyReferenced: 0 12 | validateReferences: 1 13 | platformData: 14 | - first: 15 | : Any 16 | second: 17 | enabled: 0 18 | settings: 19 | Exclude Editor: 0 20 | Exclude Linux64: 0 21 | Exclude OSXUniversal: 1 22 | Exclude Win: 0 23 | Exclude Win64: 0 24 | - first: 25 | Any: 26 | second: 27 | enabled: 0 28 | settings: {} 29 | - first: 30 | Editor: Editor 31 | second: 32 | enabled: 1 33 | settings: 34 | CPU: x86_64 35 | DefaultValueInitialized: true 36 | OS: Linux 37 | - first: 38 | Standalone: Linux64 39 | second: 40 | enabled: 1 41 | settings: 42 | CPU: x86_64 43 | - first: 44 | Standalone: OSXUniversal 45 | second: 46 | enabled: 0 47 | settings: 48 | CPU: None 49 | - first: 50 | Standalone: Win 51 | second: 52 | enabled: 1 53 | settings: 54 | CPU: x86 55 | - first: 56 | Standalone: Win64 57 | second: 58 | enabled: 1 59 | settings: 60 | CPU: x86_64 61 | userData: 62 | assetBundleName: 63 | assetBundleVariant: 64 | -------------------------------------------------------------------------------- /Packages/packages-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies": { 3 | "com.unity.burst": { 4 | "version": "1.8.25", 5 | "depth": 0, 6 | "source": "registry", 7 | "dependencies": { 8 | "com.unity.mathematics": "1.2.1", 9 | "com.unity.modules.jsonserialize": "1.0.0" 10 | }, 11 | "url": "https://packages.unity.com" 12 | }, 13 | "com.unity.mathematics": { 14 | "version": "1.3.2", 15 | "depth": 1, 16 | "source": "registry", 17 | "dependencies": {}, 18 | "url": "https://packages.unity.com" 19 | }, 20 | "com.unity.ugui": { 21 | "version": "2.0.0", 22 | "depth": 0, 23 | "source": "builtin", 24 | "dependencies": { 25 | "com.unity.modules.ui": "1.0.0", 26 | "com.unity.modules.imgui": "1.0.0" 27 | } 28 | }, 29 | "jp.keijiro.libsoundio": { 30 | "version": "file:jp.keijiro.libsoundio", 31 | "depth": 0, 32 | "source": "embedded", 33 | "dependencies": {} 34 | }, 35 | "com.unity.modules.imgui": { 36 | "version": "1.0.0", 37 | "depth": 1, 38 | "source": "builtin", 39 | "dependencies": {} 40 | }, 41 | "com.unity.modules.jsonserialize": { 42 | "version": "1.0.0", 43 | "depth": 1, 44 | "source": "builtin", 45 | "dependencies": {} 46 | }, 47 | "com.unity.modules.ui": { 48 | "version": "1.0.0", 49 | "depth": 1, 50 | "source": "builtin", 51 | "dependencies": {} 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 0 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Medium 11 | pixelLightCount: 1 12 | shadows: 1 13 | shadowResolution: 0 14 | shadowProjection: 1 15 | shadowCascades: 1 16 | shadowDistance: 20 17 | shadowNearPlaneOffset: 3 18 | shadowCascade2Split: 0.33333334 19 | shadowCascade4Split: {x: 0.06666667, y: 0.2, z: 0.46666667} 20 | shadowmaskMode: 0 21 | skinWeights: 2 22 | textureQuality: 0 23 | anisotropicTextures: 1 24 | antiAliasing: 8 25 | softParticles: 0 26 | softVegetation: 0 27 | realtimeReflectionProbes: 0 28 | billboardsFaceCameraPosition: 0 29 | vSyncCount: 1 30 | lodBias: 0.7 31 | maximumLODLevel: 0 32 | streamingMipmapsActive: 0 33 | streamingMipmapsAddAllCameras: 1 34 | streamingMipmapsMemoryBudget: 512 35 | streamingMipmapsRenderersPerFrame: 512 36 | streamingMipmapsMaxLevelReduction: 2 37 | streamingMipmapsMaxFileIORequests: 1024 38 | particleRaycastBudget: 64 39 | asyncUploadTimeSlice: 2 40 | asyncUploadBufferSize: 16 41 | asyncUploadPersistentBuffer: 1 42 | resolutionScalingFixedDPIFactor: 1 43 | customRenderPipeline: {fileID: 0} 44 | excludedTargetPlatforms: [] 45 | m_PerPlatformDefaultQuality: 46 | Android: 0 47 | Lumin: 0 48 | Nintendo 3DS: 0 49 | Nintendo Switch: 0 50 | PS4: 0 51 | PSP2: 0 52 | Stadia: 0 53 | Standalone: 0 54 | WebGL: 0 55 | Windows Store Apps: 0 56 | XboxOne: 0 57 | iPhone: 0 58 | tvOS: 0 59 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshProjectSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | m_LastAgentTypeID: -887442657 73 | m_Settings: 74 | - serializedVersion: 2 75 | agentTypeID: 0 76 | agentRadius: 0.5 77 | agentHeight: 2 78 | agentSlope: 45 79 | agentClimb: 0.75 80 | ledgeDropHeight: 0 81 | maxJumpAcrossDistance: 0 82 | minRegionArea: 2 83 | manualCellSize: 0 84 | cellSize: 0.16666667 85 | manualTileSize: 0 86 | tileSize: 256 87 | accuratePlacement: 0 88 | debug: 89 | m_Flags: 0 90 | m_SettingNames: 91 | - Humanoid 92 | -------------------------------------------------------------------------------- /Assets/Test/Utility.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Unity.Collections; 3 | using Unity.Collections.LowLevel.Unsafe; 4 | 5 | // Extension methods for NativeArray/NativeSlice <-> ReadOnlySpan conversion 6 | 7 | static class SpanNativeSliceExtensions 8 | { 9 | public unsafe static NativeSlice 10 | GetNativeSlice(this ReadOnlySpan span, int offset, int stride) 11 | where T : unmanaged 12 | { 13 | fixed (void* ptr = &span.GetPinnableReference()) 14 | { 15 | var headPtr = (T*)ptr + offset; 16 | var strideInByte = sizeof(T) * stride; 17 | var elementCount = span.Length / stride - offset / stride; 18 | 19 | var slice = 20 | NativeSliceUnsafeUtility.ConvertExistingDataToNativeSlice 21 | (headPtr, strideInByte, elementCount); 22 | 23 | #if ENABLE_UNITY_COLLECTIONS_CHECKS 24 | NativeSliceUnsafeUtility.SetAtomicSafetyHandle 25 | (ref slice, AtomicSafetyHandle.GetTempUnsafePtrSliceHandle()); 26 | #endif 27 | 28 | return slice; 29 | } 30 | } 31 | 32 | public unsafe static NativeSlice 33 | GetNativeSlice(this ReadOnlySpan span) 34 | where T : unmanaged 35 | => GetNativeSlice(span, 0, 1); 36 | 37 | public unsafe static ReadOnlySpan 38 | GetReadOnlySpan(this NativeArray array) 39 | where T : unmanaged 40 | { 41 | var ptr = NativeArrayUnsafeUtility.GetUnsafeReadOnlyPtr(array); 42 | return new Span(ptr, array.Length); 43 | } 44 | 45 | public unsafe static ReadOnlySpan 46 | GetReadOnlySpan(this NativeSlice slice) 47 | where T : unmanaged 48 | { 49 | var ptr = NativeSliceUnsafeUtility.GetUnsafeReadOnlyPtr(slice); 50 | return new Span(ptr, slice.Length); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 4 7 | m_Gravity: {x: 0, y: -9.81} 8 | m_DefaultMaterial: {fileID: 0} 9 | m_VelocityIterations: 8 10 | m_PositionIterations: 3 11 | m_VelocityThreshold: 1 12 | m_MaxLinearCorrection: 0.2 13 | m_MaxAngularCorrection: 8 14 | m_MaxTranslationSpeed: 100 15 | m_MaxRotationSpeed: 360 16 | m_BaumgarteScale: 0.2 17 | m_BaumgarteTimeOfImpactScale: 0.75 18 | m_TimeToSleep: 0.5 19 | m_LinearSleepTolerance: 0.01 20 | m_AngularSleepTolerance: 2 21 | m_DefaultContactOffset: 0.01 22 | m_JobOptions: 23 | serializedVersion: 2 24 | useMultithreading: 0 25 | useConsistencySorting: 0 26 | m_InterpolationPosesPerJob: 100 27 | m_NewContactsPerJob: 30 28 | m_CollideContactsPerJob: 100 29 | m_ClearFlagsPerJob: 200 30 | m_ClearBodyForcesPerJob: 200 31 | m_SyncDiscreteFixturesPerJob: 50 32 | m_SyncContinuousFixturesPerJob: 50 33 | m_FindNearestContactsPerJob: 100 34 | m_UpdateTriggerContactsPerJob: 100 35 | m_IslandSolverCostThreshold: 100 36 | m_IslandSolverBodyCostScale: 1 37 | m_IslandSolverContactCostScale: 10 38 | m_IslandSolverJointCostScale: 10 39 | m_IslandSolverBodiesPerJob: 50 40 | m_IslandSolverContactsPerJob: 50 41 | m_AutoSimulation: 1 42 | m_QueriesHitTriggers: 1 43 | m_QueriesStartInColliders: 1 44 | m_CallbacksOnDisable: 1 45 | m_ReuseCollisionCallbacks: 1 46 | m_AutoSyncTransforms: 0 47 | m_AlwaysShowColliders: 0 48 | m_ShowColliderSleep: 1 49 | m_ShowColliderContacts: 0 50 | m_ShowColliderAABB: 0 51 | m_ContactArrowScale: 0.2 52 | m_ColliderAwakeColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.7529412} 53 | m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} 54 | m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} 55 | m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} 56 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 57 | -------------------------------------------------------------------------------- /Assets/Test/Line1.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Line1 11 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 0.63518536, g: 1, b: 0.5613208, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Assets/Test/Line2.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_CorrespondingSourceObject: {fileID: 0} 8 | m_PrefabInstance: {fileID: 0} 9 | m_PrefabAsset: {fileID: 0} 10 | m_Name: Line2 11 | m_Shader: {fileID: 10755, guid: 0000000000000000f000000000000000, type: 0} 12 | m_ShaderKeywords: 13 | m_LightmapFlags: 4 14 | m_EnableInstancingVariants: 0 15 | m_DoubleSidedGI: 0 16 | m_CustomRenderQueue: -1 17 | stringTagMap: {} 18 | disabledShaderPasses: [] 19 | m_SavedProperties: 20 | serializedVersion: 3 21 | m_TexEnvs: 22 | - _BumpMap: 23 | m_Texture: {fileID: 0} 24 | m_Scale: {x: 1, y: 1} 25 | m_Offset: {x: 0, y: 0} 26 | - _DetailAlbedoMap: 27 | m_Texture: {fileID: 0} 28 | m_Scale: {x: 1, y: 1} 29 | m_Offset: {x: 0, y: 0} 30 | - _DetailMask: 31 | m_Texture: {fileID: 0} 32 | m_Scale: {x: 1, y: 1} 33 | m_Offset: {x: 0, y: 0} 34 | - _DetailNormalMap: 35 | m_Texture: {fileID: 0} 36 | m_Scale: {x: 1, y: 1} 37 | m_Offset: {x: 0, y: 0} 38 | - _EmissionMap: 39 | m_Texture: {fileID: 0} 40 | m_Scale: {x: 1, y: 1} 41 | m_Offset: {x: 0, y: 0} 42 | - _MainTex: 43 | m_Texture: {fileID: 0} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | - _MetallicGlossMap: 47 | m_Texture: {fileID: 0} 48 | m_Scale: {x: 1, y: 1} 49 | m_Offset: {x: 0, y: 0} 50 | - _OcclusionMap: 51 | m_Texture: {fileID: 0} 52 | m_Scale: {x: 1, y: 1} 53 | m_Offset: {x: 0, y: 0} 54 | - _ParallaxMap: 55 | m_Texture: {fileID: 0} 56 | m_Scale: {x: 1, y: 1} 57 | m_Offset: {x: 0, y: 0} 58 | m_Floats: 59 | - _BumpScale: 1 60 | - _Cutoff: 0.5 61 | - _DetailNormalMapScale: 1 62 | - _DstBlend: 0 63 | - _GlossMapScale: 1 64 | - _Glossiness: 0.5 65 | - _GlossyReflections: 1 66 | - _Metallic: 0 67 | - _Mode: 0 68 | - _OcclusionStrength: 1 69 | - _Parallax: 0.02 70 | - _SmoothnessTextureChannel: 0 71 | - _SpecularHighlights: 1 72 | - _SrcBlend: 1 73 | - _UVSec: 0 74 | - _ZWrite: 1 75 | m_Colors: 76 | - _Color: {r: 1, g: 0.6950873, b: 0.41037738, a: 1} 77 | - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} 78 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/ChannelLayout.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | 7 | namespace SoundIO 8 | { 9 | // SoundIoChannelLayout struct representation 10 | [StructLayout(LayoutKind.Sequential)] 11 | public struct ChannelLayout 12 | { 13 | #region Struct data members 14 | 15 | const int MaxChannels = 24; 16 | 17 | IntPtr _name; 18 | int _channelCount; 19 | unsafe fixed int _channels[MaxChannels]; 20 | 21 | #endregion 22 | 23 | #region Struct member accessors 24 | 25 | public string Name => Marshal.PtrToStringAnsi(_name); 26 | public int ChannelCount => _channelCount; 27 | 28 | unsafe public ReadOnlySpan Channels { get { 29 | fixed (int* p = _channels) 30 | return new ReadOnlySpan(p, ChannelCount); 31 | } } 32 | 33 | #endregion 34 | 35 | #region Builtin layouts 36 | 37 | public enum Builtin 38 | { 39 | Mono, 40 | Stereo, 41 | _2Point1, 42 | _3Point0, 43 | _3Point0Back, 44 | _3Point1, 45 | _4Point0, 46 | Quad, 47 | QuadSide, 48 | _4Point1, 49 | _5Point0Back, 50 | _5Point0Side, 51 | _5Point1, 52 | _5Point1Back, 53 | _6Point0Side, 54 | _6Point0Front, 55 | Hexagonal, 56 | _6Point1, 57 | _6Point1Back, 58 | _6Point1Front, 59 | _7Point0, 60 | _7Point0Front, 61 | _7Point1, 62 | _7Point1Wide, 63 | _7Point1WideBack, 64 | Octagonal 65 | } 66 | 67 | static public ChannelLayout GetBuiltin(Builtin id) => _GetBuiltin(id); 68 | 69 | #endregion 70 | 71 | #region Unmanaged functions 72 | 73 | [DllImport(Config.DllName, EntryPoint="soundio_channel_layout_builtin_count")] 74 | extern static int _BuiltinCount(); 75 | 76 | [DllImport(Config.DllName, EntryPoint="soundio_channel_layout_get_builtin")] 77 | extern static ref readonly ChannelLayout _GetBuiltin(Builtin id); 78 | 79 | #endregion 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Enum.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | namespace SoundIO 5 | { 6 | // Enumerations defined in libsoundio 7 | 8 | public enum Error 9 | { 10 | None, 11 | NoMem, 12 | InitAudioBackend, 13 | SystemResources, 14 | OpeningDevice, 15 | NoSuchDevice, 16 | Invalid, 17 | BackendUnavailable, 18 | Streaming, 19 | IncompatibleDevice, 20 | NoSuchClient, 21 | IncompatibleBackend, 22 | BackendDisconnected, 23 | Underflow, 24 | EncodingString 25 | } 26 | 27 | public enum Backend 28 | { 29 | None, Jack, PulseAudio, Alsa, CoreAudio, Wasapi, Dummy 30 | } 31 | 32 | public enum DeviceAim 33 | { 34 | Input, Output 35 | }; 36 | 37 | public enum Format 38 | { 39 | Invalid, 40 | S8, U8, 41 | S16LE, S16BE, U16LE, U16BE, 42 | S24LE, S24BE, U24LE, U24BE, 43 | S32LE, S32BE, U32LE, U32BE, 44 | Float32LE, Float32BE, Float64LE, Float64BE, 45 | } 46 | 47 | public enum Channel 48 | { 49 | Invalid, 50 | 51 | FrontLeft, FrontRight, FrontCenter, 52 | Lfe, 53 | BackLeft, BackRight, 54 | FrontLeftCenter, FrontRightCenter, 55 | BackCenter, 56 | SideLeft, SideRight, 57 | TopCenter, 58 | TopFrontLeft, TopFrontCenter, TopFrontRight, 59 | TopBackLeft, TopBackCenter, TopBackRight, 60 | 61 | BackLeftCenter, BackRightCenter, 62 | FrontLeftWide, FrontRightWide, 63 | FrontLeftHigh, FrontCenterHigh, FrontRightHigh, 64 | TopFrontLeftCenter, TopFrontRightCenter, 65 | TopSideLeft, TopSideRight, 66 | LeftLfe, RightLfe, Lfe2, 67 | BottomCenter, BottomLeftCenter, BottomRightCenter, 68 | 69 | MsMid, MsSide, 70 | 71 | AmbisonicW, AmbisonicX, AmbisonicY, AmbisonicZ, 72 | 73 | XyX, XyY, 74 | 75 | HeadphonesLeft, HeadphonesRight, 76 | ClickTrack, 77 | ForeignLanguage, 78 | HearingImpaired, 79 | Narration, 80 | Haptic, 81 | DialogCentricMix, 82 | 83 | Aux, Aux0, Aux1, Aux2, Aux3, Aux4, Aux5, Aux6, Aux7, 84 | Aux8, Aux9, Aux10, Aux11, Aux12, Aux13, Aux14, Aux15 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 13 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_DeferredReflections: 11 | m_Mode: 1 12 | m_Shader: {fileID: 74, guid: 0000000000000000f000000000000000, type: 0} 13 | m_ScreenSpaceShadows: 14 | m_Mode: 1 15 | m_Shader: {fileID: 64, guid: 0000000000000000f000000000000000, type: 0} 16 | m_LegacyDeferred: 17 | m_Mode: 1 18 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 19 | m_DepthNormals: 20 | m_Mode: 1 21 | m_Shader: {fileID: 62, guid: 0000000000000000f000000000000000, type: 0} 22 | m_MotionVectors: 23 | m_Mode: 1 24 | m_Shader: {fileID: 75, guid: 0000000000000000f000000000000000, type: 0} 25 | m_LightHalo: 26 | m_Mode: 1 27 | m_Shader: {fileID: 105, guid: 0000000000000000f000000000000000, type: 0} 28 | m_LensFlare: 29 | m_Mode: 1 30 | m_Shader: {fileID: 102, guid: 0000000000000000f000000000000000, type: 0} 31 | m_AlwaysIncludedShaders: 32 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 33 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 34 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 35 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 36 | - {fileID: 10753, guid: 0000000000000000f000000000000000, type: 0} 37 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 38 | - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} 39 | - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} 40 | - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} 41 | - {fileID: 16002, guid: 0000000000000000f000000000000000, type: 0} 42 | m_PreloadedShaders: [] 43 | m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, 44 | type: 0} 45 | m_CustomRenderPipeline: {fileID: 0} 46 | m_TransparencySortMode: 0 47 | m_TransparencySortAxis: {x: 0, y: 0, z: 1} 48 | m_DefaultRenderingPath: 1 49 | m_DefaultMobileRenderingPath: 1 50 | m_TierSettings: [] 51 | m_LightmapStripping: 0 52 | m_FogStripping: 0 53 | m_InstancingStripping: 0 54 | m_LightmapKeepPlain: 1 55 | m_LightmapKeepDirCombined: 1 56 | m_LightmapKeepDynamicPlain: 1 57 | m_LightmapKeepDynamicDirCombined: 1 58 | m_LightmapKeepShadowMask: 1 59 | m_LightmapKeepSubtractive: 1 60 | m_FogKeepLinear: 1 61 | m_FogKeepExp: 1 62 | m_FogKeepExp2: 1 63 | m_AlbedoSwatchInfos: [] 64 | m_LightsUseLinearIntensity: 0 65 | m_LightsUseColorTemperature: 0 66 | m_LogWhenShaderIsCompiled: 0 67 | m_AllowEnlightenSupportForUpgradedProject: 0 68 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/README.md: -------------------------------------------------------------------------------- 1 | jp.keijiro.libsoundio 2 | ===================== 3 | 4 | ![gif](https://i.imgur.com/lxWgeaA.gif) 5 | 6 | This is a C# wrapper class library of [libsoundio] that is specialized for the 7 | [Unity] runtime environment. 8 | 9 | [libsoundio]: https://github.com/andrewrk/libsoundio 10 | [Unity]: https://unity3d.com 11 | 12 | At the moment, only the audio input features are implemented and tested because 13 | the main aim of this project is providing low-latency audio input functionality 14 | to Unity. 15 | 16 | libsoundio binaries contained in this repository are slightly different from 17 | the official ones. See the following fork for details: 18 | 19 | https://github.com/keijiro/libsoundio 20 | 21 | System Requirements 22 | ------------------- 23 | 24 | - Unity 2019.4 or later 25 | - Intel 64-bit desktop platforms (Windows, macOS, Linux) 26 | 27 | On Linux, ALSA (libasound2) must be installed on the system. 28 | 29 | How To Install 30 | -------------- 31 | 32 | This package uses the [scoped registry] feature to resolve package 33 | dependencies. Please add the following lines to the manifest file 34 | (`Packages/manifest.json`). 35 | 36 | [scoped registry]: https://docs.unity3d.com/Manual/upm-scoped.html 37 | 38 |
39 | .NET Standard 2.0 (Unity 2021.1 or earlier) 40 | 41 | To the `scopedRegistries` section: 42 | 43 | ``` 44 | { 45 | "name": "Unity NuGet", 46 | "url": "https://unitynuget-registry.azurewebsites.net", 47 | "scopes": [ "org.nuget" ] 48 | }, 49 | { 50 | "name": "Keijiro", 51 | "url": "https://registry.npmjs.com", 52 | "scopes": [ "jp.keijiro" ] 53 | } 54 | ``` 55 | 56 | To the `dependencies` section: 57 | 58 | ``` 59 | "org.nuget.system.memory": "4.5.3", 60 | "jp.keijiro.libsoundio": "1.0.4" 61 | ``` 62 | 63 | After the changes, the manifest file should look like: 64 | 65 | ``` 66 | { 67 | "scopedRegistries": [ 68 | { 69 | "name": "Unity NuGet", 70 | "url": "https://unitynuget-registry.azurewebsites.net", 71 | "scopes": [ "org.nuget" ] 72 | }, 73 | { 74 | "name": "Keijiro", 75 | "url": "https://registry.npmjs.com", 76 | "scopes": [ "jp.keijiro" ] 77 | } 78 | ], 79 | "dependencies": { 80 | "org.nuget.system.memory": "4.5.3", 81 | "jp.keijiro.libsoundio": "1.0.4", 82 | ... 83 | ``` 84 |
85 | 86 |
87 | .NET Standard 2.1 (Unity 2021.2 or later) 88 | 89 | To the `scopedRegistries` section: 90 | 91 | ``` 92 | { 93 | "name": "Keijiro", 94 | "url": "https://registry.npmjs.com", 95 | "scopes": [ "jp.keijiro" ] 96 | } 97 | ``` 98 | 99 | To the `dependencies` section: 100 | 101 | ``` 102 | "jp.keijiro.libsoundio": "1.0.4" 103 | ``` 104 | 105 | After the changes, the manifest file should look like: 106 | 107 | ``` 108 | { 109 | "scopedRegistries": [ 110 | { 111 | "name": "Keijiro", 112 | "url": "https://registry.npmjs.com", 113 | "scopes": [ "jp.keijiro" ] 114 | } 115 | ], 116 | "dependencies": { 117 | "jp.keijiro.libsoundio": "1.0.4", 118 | ... 119 | ``` 120 |
121 | -------------------------------------------------------------------------------- /Assets/Test/WaveformRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Unity.Collections; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | // Raw waveform renderer 8 | 9 | public sealed class WaveformRenderer : MonoBehaviour 10 | { 11 | #region Editable attributes 12 | 13 | [SerializeField] DeviceSelector _selector = null; 14 | [SerializeField, Range(16, 1024)] int _resolution = 512; 15 | [SerializeField] Material _material = null; 16 | 17 | #endregion 18 | 19 | #region MonoBehaviour implementation 20 | 21 | void Update() 22 | { 23 | if (_selector.AudioDataSpan.Length == 0) return; 24 | 25 | UpdateMesh(); 26 | 27 | Graphics.DrawMesh( 28 | _mesh, transform.localToWorldMatrix, 29 | _material, gameObject.layer); 30 | } 31 | 32 | void OnDestroy() 33 | { 34 | if (_mesh != null) Destroy(_mesh); 35 | } 36 | 37 | #endregion 38 | 39 | #region Mesh generator 40 | 41 | Mesh _mesh; 42 | 43 | void UpdateMesh() 44 | { 45 | if (_mesh == null) 46 | { 47 | _mesh = new Mesh(); 48 | _mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 10); 49 | 50 | // Initial vertices 51 | using (var vertices = CreateVertexArray()) 52 | { 53 | var pos = new VertexAttributeDescriptor( 54 | VertexAttribute.Position, 55 | VertexAttributeFormat.Float32, 3); 56 | 57 | _mesh.SetVertexBufferParams(vertices.Length, pos); 58 | _mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length); 59 | } 60 | 61 | // Initial indices 62 | using (var indices = CreateIndexArray()) 63 | { 64 | _mesh.SetIndexBufferParams(indices.Length, IndexFormat.UInt32); 65 | _mesh.SetIndexBufferData(indices, 0, 0, indices.Length); 66 | 67 | var lines = new SubMeshDescriptor 68 | (0, indices.Length, MeshTopology.LineStrip); 69 | 70 | _mesh.SetSubMesh(0, lines); 71 | } 72 | } 73 | else 74 | { 75 | // Vertex update 76 | using (var vertices = CreateVertexArray()) 77 | _mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length); 78 | } 79 | } 80 | 81 | NativeArray CreateIndexArray() 82 | { 83 | var indices = Enumerable.Range(0, _resolution); 84 | return new NativeArray(indices.ToArray(), Allocator.Temp); 85 | } 86 | 87 | NativeArray CreateVertexArray() 88 | { 89 | var data = _selector.AudioDataSpan; 90 | 91 | var buffer = new NativeArray( 92 | _resolution, Allocator.Temp, 93 | NativeArrayOptions.UninitializedMemory); 94 | 95 | for (var vi = 0; vi < _resolution; vi++) 96 | { 97 | var x = (float)vi / _resolution; 98 | var i = vi * data.Length / _resolution; 99 | buffer[vi] = new Vector3(x, data[i], 0); 100 | } 101 | 102 | return buffer; 103 | } 104 | 105 | #endregion 106 | } 107 | -------------------------------------------------------------------------------- /Assets/Test/LevelMeter.cs: -------------------------------------------------------------------------------- 1 | using SoundIO.SimpleDriver; 2 | using Unity.Collections; 3 | using Unity.Jobs; 4 | using Unity.Mathematics; 5 | using UnityEngine; 6 | 7 | // Level meter with low/mid/high filter bank 8 | 9 | public sealed class LevelMeter : MonoBehaviour 10 | { 11 | #region Editable attributes 12 | 13 | [SerializeField] DeviceSelector _selector = null; 14 | [SerializeField] float _range = 60; 15 | [SerializeField] RectTransform _bypassMeter = null; 16 | [SerializeField] RectTransform _lowPassMeter = null; 17 | [SerializeField] RectTransform _bandPassMeter = null; 18 | [SerializeField] RectTransform _highPassMeter = null; 19 | 20 | #endregion 21 | 22 | #region Filter + RMS level calculation job 23 | 24 | [Unity.Burst.BurstCompile(CompileSynchronously = true)] 25 | struct FilterRmsJob : IJob 26 | { 27 | [ReadOnly] public NativeSlice Input; 28 | [WriteOnly] public NativeArray Output; 29 | public NativeArray Filter; 30 | 31 | public void Execute() 32 | { 33 | var filter = Filter[0]; 34 | 35 | // Square sum 36 | var ss = float4.zero; 37 | 38 | for (var i = 0; i < Input.Length; i++) 39 | { 40 | var vf = filter.FeedSample(Input[i]); 41 | ss += vf * vf; 42 | } 43 | 44 | // Root mean square 45 | var rms = math.sqrt(ss / Input.Length); 46 | 47 | // RMS in dBFS 48 | // Full scale sin wave = 0 dBFS : refLevel = 1/sqrt(2) 49 | const float refLevel = 0.7071f; 50 | const float zeroOffset = 1.5849e-13f; 51 | var level = 20 * math.log10(rms / refLevel + zeroOffset); 52 | 53 | // Output 54 | Output[0] = level; 55 | Filter[0] = filter; 56 | } 57 | } 58 | 59 | #endregion 60 | 61 | #region MonoBehaviour implementation 62 | 63 | MultibandFilter _filter; 64 | 65 | void Update() 66 | { 67 | // Single element native array used to share structs with the job. 68 | var tempFilter = new NativeArray 69 | (1, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); 70 | 71 | var tempLevel = new NativeArray 72 | (1, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); 73 | 74 | // Filter update 75 | _filter.SetParameter(960.0f / _selector.SampleRate, 0.15f); 76 | tempFilter[0] = _filter; 77 | 78 | // Run the job on the main thread. 79 | new FilterRmsJob { Input = _selector.AudioDataSlice, 80 | Filter = tempFilter, Output = tempLevel }.Run(); 81 | 82 | // Preserve the filter state. 83 | _filter = tempFilter[0]; 84 | 85 | // Meter scale 86 | var sc = math.max(0, _range + tempLevel[0]) / _range; 87 | 88 | // Apply to rect-transforms. 89 | _bypassMeter.transform.localScale = new Vector3(sc.x, 1, 1); 90 | _lowPassMeter.transform.localScale = new Vector3(sc.y, 1, 1); 91 | _bandPassMeter.transform.localScale = new Vector3(sc.z, 1, 1); 92 | _highPassMeter.transform.localScale = new Vector3(sc.w, 1, 1); 93 | 94 | // Cleaning the temporaries up. 95 | tempFilter.Dispose(); 96 | tempLevel.Dispose(); 97 | } 98 | 99 | #endregion 100 | } 101 | -------------------------------------------------------------------------------- /Assets/Test/SpectrumAnalyzer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Unity.Collections; 4 | using UnityEngine; 5 | using UnityEngine.Rendering; 6 | 7 | // DFT spectrum analyzer graph 8 | 9 | public sealed class SpectrumAnalyzer : MonoBehaviour 10 | { 11 | #region Editable attributes 12 | 13 | [SerializeField] DeviceSelector _selector = null; 14 | [SerializeField] Material _material = null; 15 | 16 | #endregion 17 | 18 | #region Internal objects 19 | 20 | const int Resolution = 1024; 21 | DftBuffer _dft; 22 | Mesh _mesh; 23 | 24 | #endregion 25 | 26 | #region MonoBehaviour implementation 27 | 28 | void Start() 29 | { 30 | _dft = new DftBuffer(Resolution); 31 | } 32 | 33 | void OnDestroy() 34 | { 35 | _dft?.Dispose(); 36 | if (_mesh != null) Destroy(_mesh); 37 | } 38 | 39 | void Update() 40 | { 41 | _dft.Push(_selector.AudioDataSpan); 42 | _dft.Analyze(); 43 | 44 | UpdateMesh(); 45 | 46 | Graphics.DrawMesh( 47 | _mesh, transform.localToWorldMatrix, 48 | _material, gameObject.layer); 49 | } 50 | 51 | #endregion 52 | 53 | #region Mesh generator 54 | 55 | void UpdateMesh() 56 | { 57 | if (_mesh == null) 58 | { 59 | _mesh = new Mesh(); 60 | _mesh.bounds = new Bounds(Vector3.zero, Vector3.one * 1000); 61 | 62 | // Initial vertices 63 | using (var vertices = CreateVertexArray()) 64 | { 65 | var pos = new VertexAttributeDescriptor( 66 | VertexAttribute.Position, 67 | VertexAttributeFormat.Float32, 3); 68 | 69 | _mesh.SetVertexBufferParams(vertices.Length, pos); 70 | _mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length); 71 | } 72 | 73 | // Initial indices 74 | using (var indices = CreateIndexArray()) 75 | { 76 | _mesh.SetIndexBufferParams(indices.Length, IndexFormat.UInt32); 77 | _mesh.SetIndexBufferData(indices, 0, 0, indices.Length); 78 | 79 | var lines = new SubMeshDescriptor( 80 | 0, indices.Length, MeshTopology.LineStrip); 81 | 82 | _mesh.SetSubMesh(0, lines); 83 | } 84 | } 85 | else 86 | { 87 | // Vertex update 88 | using (var vertices = CreateVertexArray()) 89 | _mesh.SetVertexBufferData(vertices, 0, 0, vertices.Length); 90 | } 91 | } 92 | 93 | NativeArray CreateIndexArray() 94 | { 95 | var indices = Enumerable.Range(0, Resolution / 2); 96 | return new NativeArray(indices.ToArray(), Allocator.Temp); 97 | } 98 | 99 | NativeArray CreateVertexArray() 100 | { 101 | var data = _dft.Spectrum; 102 | 103 | var buffer = new NativeArray( 104 | Resolution / 2, Allocator.Temp, 105 | NativeArrayOptions.UninitializedMemory); 106 | 107 | const float refLevel = 0.7071f; 108 | const float zeroOffset = 1.5849e-13f; 109 | 110 | for (var vi = 0; vi < Resolution / 2; vi++) 111 | { 112 | var x = Mathf.Log10(vi) / Mathf.Log10(Resolution / 2 - 1); 113 | var y = 20 * Mathf.Log10(data[vi] / refLevel + zeroOffset); 114 | buffer[vi] = new Vector3(x, y, 0); 115 | } 116 | 117 | return buffer; 118 | } 119 | 120 | #endregion 121 | } 122 | -------------------------------------------------------------------------------- /Assets/SimpleDriver/RingBuffer.cs: -------------------------------------------------------------------------------- 1 | // Simple driver for libsoundio 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | 6 | namespace SoundIO.SimpleDriver 7 | { 8 | // 9 | // A simple implementation of a ring buffer 10 | // 11 | // Note that this class is non-thread safe. The owner class should take 12 | // care of race conditions. 13 | // 14 | public sealed class RingBuffer 15 | { 16 | byte[] _buffer; 17 | 18 | ulong _readCount; 19 | ulong _writeCount; 20 | 21 | public RingBuffer(int capacity) => _buffer = new byte[capacity]; 22 | 23 | public int Capacity => _buffer.Length; 24 | public int FillCount => (int)(_writeCount - _readCount); 25 | public int FreeCount => Capacity - FillCount; 26 | public int OverflowCount { get; private set; } 27 | 28 | int ReadOffset => (int)( _readCount % (ulong)Capacity); 29 | int WriteOffset => (int)(_writeCount % (ulong)Capacity); 30 | 31 | public void Clear() 32 | { 33 | _readCount = _writeCount = 0ul; 34 | OverflowCount = 0; 35 | } 36 | 37 | public void Write(ReadOnlySpan data) 38 | { 39 | if (FreeCount == 0) 40 | { 41 | OverflowCount++; 42 | return; 43 | } 44 | 45 | if (data.Length > FreeCount) 46 | { 47 | OverflowCount++; 48 | data = data.Slice(data.Length - FreeCount); 49 | } 50 | 51 | var rp = ReadOffset; 52 | var wp = WriteOffset; 53 | 54 | var head_rp = new Span(_buffer, 0, rp); 55 | var wp_tail = new Span(_buffer, wp, Capacity - wp); 56 | 57 | if (rp > wp || data.Length <= wp_tail.Length) 58 | { 59 | data.CopyTo(wp_tail); 60 | } 61 | else 62 | { 63 | data.Slice(0, wp_tail.Length).CopyTo(wp_tail); 64 | data.Slice(wp_tail.Length).CopyTo(head_rp); 65 | } 66 | 67 | _writeCount += (ulong)data.Length; 68 | } 69 | 70 | public void WriteEmpty(int length) 71 | { 72 | UnityEngine.Debug.Assert(length <= FreeCount); 73 | 74 | var rp = ReadOffset; 75 | var wp = WriteOffset; 76 | 77 | var head_rp = new Span(_buffer, 0, rp); 78 | var wp_tail = new Span(_buffer, wp, Capacity - wp); 79 | 80 | if (rp > wp) 81 | { 82 | wp_tail.Slice(0, length).Fill(0); 83 | } 84 | else 85 | { 86 | wp_tail.Fill(0); 87 | head_rp.Slice(0, length - wp_tail.Length).Fill(0); 88 | } 89 | 90 | _writeCount += (ulong)length; 91 | } 92 | 93 | public void Read(Span dest) 94 | { 95 | UnityEngine.Debug.Assert(dest.Length <= FillCount); 96 | 97 | var rp = ReadOffset; 98 | var wp = WriteOffset; 99 | 100 | if (wp > rp || dest.Length <= Capacity - rp) 101 | { 102 | new Span(_buffer, rp, dest.Length).CopyTo(dest); 103 | } 104 | else 105 | { 106 | var part = Capacity - rp; 107 | new Span(_buffer, rp, part).CopyTo(dest); 108 | new Span(_buffer, 0, dest.Length - part).CopyTo(dest.Slice(part)); 109 | } 110 | 111 | _readCount += (ulong)dest.Length; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Test/Ltc.cs: -------------------------------------------------------------------------------- 1 | // 2 | // LTC (Linear timecode) data structure and decoder 3 | // 4 | 5 | using System; 6 | 7 | namespace Ltc 8 | { 9 | // Unpacked representation of LTC 10 | public struct Timecode 11 | { 12 | public int frame; 13 | public int second; 14 | public int minute; 15 | public int hour; 16 | public bool dropFrame; 17 | 18 | // Unpack LTC data into a timecode instance 19 | static public Timecode Unpack(ulong data) 20 | { 21 | var s1 = (int)((data ) & 0xffff); 22 | var s2 = (int)((data >> 16) & 0xffff); 23 | var s3 = (int)((data >> 32) & 0xffff); 24 | var s4 = (int)((data >> 48) & 0xffff); 25 | 26 | return new Timecode 27 | { 28 | frame = (s1 & 0xf) + ((s1 >> 8) & 3) * 10, 29 | second = (s2 & 0xf) + ((s2 >> 8) & 7) * 10, 30 | minute = (s3 & 0xf) + ((s3 >> 8) & 7) * 10, 31 | hour = (s4 & 0xf) + ((s4 >> 8) & 3) * 10, 32 | dropFrame = (s1 & 0x400) != 0 33 | }; 34 | } 35 | 36 | public override string ToString() 37 | { 38 | return $"{hour:D2}:{minute:D2}:{second:D2}:{frame:D2}"; 39 | } 40 | } 41 | 42 | // Timecode decoder class that analyzes audio signals to extract LTC data 43 | public sealed class TimecodeDecoder 44 | { 45 | #region Public methods 46 | 47 | public Timecode LastTimecode { get; private set; } 48 | 49 | public void ParseAudioData(ReadOnlySpan data) 50 | { 51 | foreach (var v in data) ProcessSample(v > 0.0f); 52 | } 53 | 54 | #endregion 55 | 56 | #region Internal state 57 | 58 | // 128 bit FIFO queue for the bit stream 59 | (ulong lo, ulong hi) _fifo; 60 | 61 | // Sample count from the last transition 62 | int _count; 63 | 64 | // Bit period (x100 fixed point value) 65 | int _period; 66 | 67 | // Transition counter for true bits 68 | bool _tick; 69 | 70 | // Current state (the previous sample value) 71 | bool _state; 72 | 73 | #endregion 74 | 75 | #region Private methods 76 | 77 | void ProcessSample(bool sample) 78 | { 79 | // Biphase mark code decoder with an adaptive bit-period estimator. 80 | 81 | // No transition? 82 | if (_state == sample) 83 | { 84 | // Just increment the counter. 85 | if (_count < 10000) _count++; 86 | return; 87 | } 88 | 89 | // Half period? 90 | if (_count < _period / 100) 91 | { 92 | // Second transition? 93 | if (_tick) 94 | { 95 | ProcessBit(true); // Output: "1" 96 | _tick = false; 97 | } 98 | else 99 | _tick = true; 100 | } 101 | else 102 | { 103 | ProcessBit(false); // Output: "0" 104 | _tick = false; 105 | } 106 | 107 | // Adaptive estimation of the bit period 108 | _period = (_period * 99 + _count * 100) / 100; 109 | 110 | _state = sample; 111 | _count = 0; 112 | } 113 | 114 | void ProcessBit(bool bit) 115 | { 116 | const ushort sync = 0xbffc; // LTC sync word 117 | const ulong msb64 = 1ul << 63; 118 | 119 | // 64:64 combined FIFO 120 | var hi_lsb = (_fifo.hi & 1ul) != 0; 121 | _fifo.lo = (_fifo.lo >> 1) | (hi_lsb ? msb64 : 0ul); 122 | _fifo.hi = (_fifo.hi >> 1) | ( bit ? msb64 : 0ul); 123 | 124 | // LTC sync word detection 125 | if ((ushort)_fifo.hi == sync) 126 | LastTimecode = Timecode.Unpack(_fifo.lo); 127 | } 128 | 129 | #endregion 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /ProjectSettings/SceneTemplateSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "templatePinStates": [], 3 | "dependencyTypeInfos": [ 4 | { 5 | "userAdded": false, 6 | "type": "UnityEngine.AnimationClip", 7 | "defaultInstantiationMode": 0 8 | }, 9 | { 10 | "userAdded": false, 11 | "type": "UnityEditor.Animations.AnimatorController", 12 | "defaultInstantiationMode": 0 13 | }, 14 | { 15 | "userAdded": false, 16 | "type": "UnityEngine.AnimatorOverrideController", 17 | "defaultInstantiationMode": 0 18 | }, 19 | { 20 | "userAdded": false, 21 | "type": "UnityEditor.Audio.AudioMixerController", 22 | "defaultInstantiationMode": 0 23 | }, 24 | { 25 | "userAdded": false, 26 | "type": "UnityEngine.ComputeShader", 27 | "defaultInstantiationMode": 1 28 | }, 29 | { 30 | "userAdded": false, 31 | "type": "UnityEngine.Cubemap", 32 | "defaultInstantiationMode": 0 33 | }, 34 | { 35 | "userAdded": false, 36 | "type": "UnityEngine.GameObject", 37 | "defaultInstantiationMode": 0 38 | }, 39 | { 40 | "userAdded": false, 41 | "type": "UnityEditor.LightingDataAsset", 42 | "defaultInstantiationMode": 0 43 | }, 44 | { 45 | "userAdded": false, 46 | "type": "UnityEngine.LightingSettings", 47 | "defaultInstantiationMode": 0 48 | }, 49 | { 50 | "userAdded": false, 51 | "type": "UnityEngine.Material", 52 | "defaultInstantiationMode": 0 53 | }, 54 | { 55 | "userAdded": false, 56 | "type": "UnityEditor.MonoScript", 57 | "defaultInstantiationMode": 1 58 | }, 59 | { 60 | "userAdded": false, 61 | "type": "UnityEngine.PhysicsMaterial", 62 | "defaultInstantiationMode": 0 63 | }, 64 | { 65 | "userAdded": false, 66 | "type": "UnityEngine.PhysicsMaterial2D", 67 | "defaultInstantiationMode": 0 68 | }, 69 | { 70 | "userAdded": false, 71 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessProfile", 72 | "defaultInstantiationMode": 0 73 | }, 74 | { 75 | "userAdded": false, 76 | "type": "UnityEngine.Rendering.PostProcessing.PostProcessResources", 77 | "defaultInstantiationMode": 0 78 | }, 79 | { 80 | "userAdded": false, 81 | "type": "UnityEngine.Rendering.VolumeProfile", 82 | "defaultInstantiationMode": 0 83 | }, 84 | { 85 | "userAdded": false, 86 | "type": "UnityEditor.SceneAsset", 87 | "defaultInstantiationMode": 1 88 | }, 89 | { 90 | "userAdded": false, 91 | "type": "UnityEngine.Shader", 92 | "defaultInstantiationMode": 1 93 | }, 94 | { 95 | "userAdded": false, 96 | "type": "UnityEngine.ShaderVariantCollection", 97 | "defaultInstantiationMode": 1 98 | }, 99 | { 100 | "userAdded": false, 101 | "type": "UnityEngine.Texture", 102 | "defaultInstantiationMode": 0 103 | }, 104 | { 105 | "userAdded": false, 106 | "type": "UnityEngine.Texture2D", 107 | "defaultInstantiationMode": 0 108 | }, 109 | { 110 | "userAdded": false, 111 | "type": "UnityEngine.Timeline.TimelineAsset", 112 | "defaultInstantiationMode": 0 113 | } 114 | ], 115 | "defaultDependencyTypeInfo": { 116 | "userAdded": false, 117 | "type": "", 118 | "defaultInstantiationMode": 1 119 | }, 120 | "newSceneOverride": 0 121 | } -------------------------------------------------------------------------------- /Assets/SimpleDriver/DeviceDriver.cs: -------------------------------------------------------------------------------- 1 | // Simple driver for libsoundio 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using UnityEngine.LowLevel; 7 | 8 | namespace SoundIO.SimpleDriver 9 | { 10 | // 11 | // Singleton-like device driver class 12 | // 13 | // This class manages a soundio context and input stream objects created in 14 | // the context. It also implements a Player Loop System and invokes the 15 | // Update methods in the EarlyUpdate phase every frame. 16 | // 17 | // Caveat: Doesn't support device addition/removal during run. 18 | // 19 | public static class DeviceDriver 20 | { 21 | #region Public properties and methods 22 | 23 | public static int DeviceCount => Context.InputDeviceCount; 24 | public static int DefaultDeviceIndex => Context.DefaultInputDeviceIndex; 25 | 26 | public static string GetDeviceName(int index) 27 | { 28 | using (var dev = Context.GetInputDevice(index)) 29 | return dev.IsRaw ? "Raw: " + dev.Name : dev.Name; 30 | } 31 | 32 | public static InputStream OpenInputStream(int deviceIndex) 33 | { 34 | // Note: The ownership of the device object will be transferred to 35 | // the input stream object. 36 | var stream = new InputStream(Context.GetInputDevice(deviceIndex)); 37 | 38 | if (stream.IsValid) 39 | { 40 | _inputStreams.Add(stream); 41 | return stream; 42 | } 43 | else 44 | { 45 | stream.Dispose(); 46 | return null; 47 | } 48 | } 49 | 50 | #endregion 51 | 52 | #region SoundIO context management 53 | 54 | static Context Context => GetContextWithLazyInitialization(); 55 | 56 | static Context _context; 57 | 58 | static Context GetContextWithLazyInitialization() 59 | { 60 | if (_context == null) 61 | { 62 | _context = Context.Create(); 63 | 64 | _context.Connect(); 65 | _context.FlushEvents(); 66 | 67 | // Install the Player Loop System. 68 | InsertPlayerLoopSystem(); 69 | } 70 | 71 | return _context; 72 | } 73 | 74 | #endregion 75 | 76 | #region Update method implementation 77 | 78 | static List _inputStreams = new List(); 79 | 80 | static void Update() 81 | { 82 | Context.FlushEvents(); 83 | 84 | // Update and validate the input streams. 85 | var foundInvalid = false; 86 | 87 | foreach (var stream in _inputStreams) 88 | if (stream.IsValid) 89 | stream.Update(); 90 | else 91 | foundInvalid = true; 92 | 93 | // Reconstruct the input stream list when invalid ones were found. 94 | if (foundInvalid) 95 | _inputStreams = _inputStreams.Where(s => s.IsValid).ToList(); 96 | } 97 | 98 | #endregion 99 | 100 | #region PlayerLoopSystem implementation 101 | 102 | static void InsertPlayerLoopSystem() 103 | { 104 | // Append a custom system to the Early Update phase. 105 | 106 | var customSystem = new PlayerLoopSystem() 107 | { 108 | type = typeof(DeviceDriver), 109 | updateDelegate = () => DeviceDriver.Update() 110 | }; 111 | 112 | var playerLoop = PlayerLoop.GetCurrentPlayerLoop(); 113 | 114 | for (var i = 0; i < playerLoop.subSystemList.Length; i++) 115 | { 116 | ref var phase = ref playerLoop.subSystemList[i]; 117 | if (phase.type == typeof(UnityEngine.PlayerLoop.EarlyUpdate)) 118 | { 119 | phase.subSystemList = phase.subSystemList. 120 | Concat(new[]{ customSystem }).ToArray(); 121 | break; 122 | } 123 | } 124 | 125 | PlayerLoop.SetPlayerLoop(playerLoop); 126 | } 127 | 128 | #endregion 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /Assets/Test/DeviceSelector.cs: -------------------------------------------------------------------------------- 1 | using SoundIO.SimpleDriver; 2 | using System; 3 | using System.Linq; 4 | using System.Runtime.InteropServices; 5 | using Unity.Collections; 6 | using UnityEngine; 7 | using UnityEngine.UI; 8 | 9 | // Device selector class 10 | // - Controlls the device selection UI. 11 | // - Manages SoundIO objects. 12 | // - Provides audio data for the other scripts. 13 | 14 | public sealed class DeviceSelector : MonoBehaviour 15 | { 16 | #region Editable attributes 17 | 18 | [SerializeField] Dropdown _deviceList = null; 19 | [SerializeField] Dropdown _channelList = null; 20 | [SerializeField] Text _statusText = null; 21 | 22 | #endregion 23 | 24 | #region Public properties 25 | 26 | public int Channel => _channelList.value; 27 | public int ChannelCount => _stream?.ChannelCount ?? 0; 28 | public int SampleRate => _stream?.SampleRate ?? 0; 29 | 30 | public float Volume { get; set; } = 1; 31 | 32 | public ReadOnlySpan AudioDataSpan => 33 | _audioData.GetSubArray(0, _audioDataFilled).GetReadOnlySpan(); 34 | 35 | public NativeSlice AudioDataSlice => 36 | new NativeSlice(_audioData, 0, _audioDataFilled); 37 | 38 | #endregion 39 | 40 | #region Internal objects 41 | 42 | InputStream _stream; 43 | NativeArray _audioData; 44 | int _audioDataFilled; 45 | 46 | #endregion 47 | 48 | #region MonoBehaviour implementation 49 | 50 | void Start() 51 | { 52 | // Buffer allocation 53 | _audioData = new NativeArray(4096, Allocator.Persistent); 54 | 55 | // Clear the UI contents. 56 | _deviceList.ClearOptions(); 57 | _channelList.ClearOptions(); 58 | _statusText.text = ""; 59 | 60 | // Null device option 61 | _deviceList.options.Add(new Dropdown.OptionData() { text = "--" }); 62 | 63 | // Device list initialization 64 | _deviceList.options.AddRange( 65 | Enumerable.Range(0, DeviceDriver.DeviceCount). 66 | Select(i => DeviceDriver.GetDeviceName(i)). 67 | Select(name => new Dropdown.OptionData() { text = name })); 68 | 69 | _deviceList.RefreshShownValue(); 70 | } 71 | 72 | void OnDestroy() 73 | { 74 | _stream?.Dispose(); 75 | _audioData.Dispose(); 76 | } 77 | 78 | void Update() 79 | { 80 | if (_stream == null) 81 | { 82 | _audioDataFilled = 0; 83 | return; 84 | } 85 | 86 | // Strided copy 87 | var input = MemoryMarshal.Cast(_stream.LastFrameWindow); 88 | var stride = _stream.ChannelCount; 89 | var offset = Channel; 90 | 91 | _audioDataFilled = Mathf.Min(input.Length, input.Length / stride); 92 | 93 | for (var i = 0; i < _audioDataFilled; i++) 94 | _audioData[i] = input[i * stride + offset] * Volume; 95 | 96 | // Status line 97 | _statusText.text = 98 | $"Sampling rate: {_stream.SampleRate:n0}Hz / " + 99 | $"Software Latency: {_stream.Latency * 1000:n2}ms / " + 100 | $"Amplifier: {Volume:P0}"; 101 | } 102 | 103 | #endregion 104 | 105 | #region UI callback 106 | 107 | public void OnDeviceSelected(int index) 108 | { 109 | // Stop and destroy the current stream. 110 | if (_stream != null) 111 | { 112 | _stream.Dispose(); 113 | _stream = null; 114 | } 115 | 116 | // Reset the UI elements. 117 | _channelList.ClearOptions(); 118 | _channelList.RefreshShownValue(); 119 | _statusText.text = ""; 120 | 121 | // Break if the null device option was selected. 122 | if (_deviceList.value == 0) return; 123 | 124 | // Open a new stream. 125 | try 126 | { 127 | _stream = DeviceDriver.OpenInputStream(_deviceList.value - 1); 128 | } 129 | catch (System.InvalidOperationException e) 130 | { 131 | _statusText.text = $"Error: {e.Message}"; 132 | return; 133 | } 134 | 135 | // Construct the channel list. 136 | _channelList.options = 137 | Enumerable.Range(0, _stream.ChannelCount). 138 | Select(i => $"Channel {i + 1}"). 139 | Select(text => new Dropdown.OptionData() { text = text }). 140 | ToList(); 141 | 142 | _channelList.RefreshShownValue(); 143 | } 144 | 145 | #endregion 146 | } 147 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Device.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | using Microsoft.Win32.SafeHandles; 7 | 8 | namespace SoundIO 9 | { 10 | // SoundIoDevice struct wrapper class 11 | public class Device : SafeHandleZeroOrMinusOneIsInvalid 12 | { 13 | #region SoundIoDevice struct representation 14 | 15 | [StructLayout(LayoutKind.Sequential)] 16 | internal struct NativeData 17 | { 18 | internal IntPtr context; 19 | internal IntPtr id; 20 | internal IntPtr name; 21 | internal DeviceAim aim; 22 | 23 | internal IntPtr layouts; 24 | internal int layoutCount; 25 | internal ChannelLayout currentLayout; 26 | 27 | internal IntPtr formats; 28 | internal int formatCount; 29 | internal Format currentFormat; 30 | 31 | internal IntPtr sampleRates; 32 | internal int sampleRateCount; 33 | internal int currentSampleRate; 34 | 35 | internal double softwareLatencyMin; 36 | internal double softwareLatencyMax; 37 | internal double softwareLatencyCurrent; 38 | 39 | internal byte isRaw; 40 | internal int refCount; 41 | internal Error probeError; 42 | } 43 | 44 | #endregion 45 | 46 | #region SafeHandle implementation 47 | 48 | Device() : base(true) {} 49 | 50 | protected override bool ReleaseHandle() 51 | { 52 | _Unref(handle); 53 | return true; 54 | } 55 | 56 | unsafe ref NativeData Data => ref Unsafe.AsRef((void*)handle); 57 | 58 | #endregion 59 | 60 | #region Struct member accessors 61 | 62 | public string ID => Marshal.PtrToStringAnsi(Data.id); 63 | public string Name => Marshal.PtrToStringAnsi(Data.name); 64 | public DeviceAim Aim => Data.aim; 65 | 66 | unsafe public Span Layouts => 67 | new Span((void*)Data.layouts, Data.layoutCount); 68 | 69 | public ChannelLayout CurrentLayout => Data.currentLayout; 70 | 71 | unsafe public Span Formats => 72 | new Span((void*)Data.formats, Data.formatCount); 73 | 74 | public Format CurrentFormat => Data.currentFormat; 75 | 76 | unsafe public Span SampleRates => 77 | new Span((void*)Data.sampleRates, Data.sampleRateCount); 78 | 79 | public int CurrentSampleRate => Data.currentSampleRate; 80 | 81 | public double SoftwareLatencyMin => Data.softwareLatencyMin; 82 | public double SoftwareLatencyMax => Data.softwareLatencyMax; 83 | public double SoftwareLatencyCurrent => Data.softwareLatencyCurrent; 84 | 85 | public bool IsRaw => Data.isRaw != 0; 86 | public Error ProbeError => Data.probeError; 87 | 88 | #endregion 89 | 90 | #region Public properties and methods 91 | 92 | public bool Equal(Device rhs) => _Equal(this, rhs) != 0; 93 | public void SortChannelLayouts() => _SortChannelLayouts(this); 94 | public bool CheckSupport(Format format) => _SupportsFormat(this, format) != 0; 95 | public bool CheckSupport(in ChannelLayout layout) => _SupportsLayout(this, layout) != 0; 96 | public bool CheckSampleRateSupport(int rate) => _SupportsSampleRate(this, rate) != 0; 97 | public int GetNearestSampleRate(int rate) => _NearestSampleRate(this, rate); 98 | 99 | #endregion 100 | 101 | #region Unmanaged functions 102 | 103 | [DllImport(Config.DllName, EntryPoint="soundio_device_unref")] 104 | extern static void _Unref(IntPtr device); 105 | 106 | [DllImport(Config.DllName, EntryPoint="soundio_device_equal")] 107 | extern static byte _Equal(Device a, Device b); 108 | 109 | [DllImport(Config.DllName, EntryPoint="soundio_device_sort_channel_layouts")] 110 | extern static void _SortChannelLayouts(Device device); 111 | 112 | [DllImport(Config.DllName, EntryPoint="soundio_device_supports_format")] 113 | extern static byte _SupportsFormat(Device device, Format format); 114 | 115 | [DllImport(Config.DllName, EntryPoint="soundio_device_supports_layout")] 116 | extern static byte _SupportsLayout(Device device, in ChannelLayout layout); 117 | 118 | [DllImport(Config.DllName, EntryPoint="soundio_device_supports_sample_rate")] 119 | extern static byte _SupportsSampleRate(Device device, int sampleRate); 120 | 121 | [DllImport(Config.DllName, EntryPoint="soundio_device_nearest_sample_rate")] 122 | extern static int _NearestSampleRate(Device device, int sampleRate); 123 | 124 | #endregion 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/Context.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | using Microsoft.Win32.SafeHandles; 7 | 8 | namespace SoundIO 9 | { 10 | // SoundIo struct wrapper class 11 | public class Context : SafeHandleZeroOrMinusOneIsInvalid 12 | { 13 | #region SoundIo struct representation 14 | 15 | [StructLayout(LayoutKind.Sequential)] 16 | internal struct NativeData 17 | { 18 | internal IntPtr userdata; 19 | internal IntPtr onDevicesChange; 20 | internal IntPtr onBackendDisconnect; 21 | internal IntPtr onEventsSignal; 22 | internal Backend currentBackend; 23 | internal IntPtr appName; 24 | } 25 | 26 | #endregion 27 | 28 | #region SafeHandle implementation 29 | 30 | Context() : base(true) {} 31 | 32 | protected override bool ReleaseHandle() 33 | { 34 | _Destroy(handle); 35 | return true; 36 | } 37 | 38 | unsafe ref NativeData Data => ref Unsafe.AsRef((void*)handle); 39 | 40 | #endregion 41 | 42 | #region Struct member accessors 43 | 44 | public IntPtr UserData => Data.userdata; 45 | 46 | public delegate void OnDevicesChangeDelegate(IntPtr context); 47 | 48 | public OnDevicesChangeDelegate OnDevicesChange 49 | { 50 | get => Marshal.GetDelegateForFunctionPointer(Data.onDevicesChange); 51 | set => Data.onDevicesChange = Marshal.GetFunctionPointerForDelegate(value); 52 | } 53 | 54 | public delegate void OnBackendDisconnectDelegate(IntPtr context, Error error); 55 | 56 | public OnBackendDisconnectDelegate OnBackendDisconnect 57 | { 58 | get => Marshal.GetDelegateForFunctionPointer(Data.onBackendDisconnect); 59 | set => Data.onBackendDisconnect = Marshal.GetFunctionPointerForDelegate(value); 60 | } 61 | 62 | public delegate void OnEventsSignalDelegate(IntPtr context); 63 | 64 | public OnEventsSignalDelegate OnEventSignal 65 | { 66 | get => Marshal.GetDelegateForFunctionPointer(Data.onEventsSignal); 67 | set => Data.onEventsSignal = Marshal.GetFunctionPointerForDelegate(value); 68 | } 69 | 70 | public Backend CurrentBackend => Data.currentBackend; 71 | public string AppName => Marshal.PtrToStringAnsi(Data.appName); 72 | 73 | #endregion 74 | 75 | #region Public properties and methods 76 | 77 | static public Context Create() => _Create(); 78 | 79 | public Error Connect() => _Connect(this); 80 | public Error Connect(Backend backend) => _Connect(this, backend); 81 | public void Disconnect() => _Disconnect(this); 82 | public void FlushEvents() => _FlushEvents(this); 83 | 84 | public int OutputDeviceCount => _OutputDeviceCount(this); 85 | public int InputDeviceCount => _InputDeviceCount(this); 86 | public Device GetInputDevice(int index) => _GetInputDevice(this, index); 87 | public Device GetOutputDevice(int index) => _GetOutputDevice(this, index); 88 | public int DefaultInputDeviceIndex => _DefaultInputDeviceIndex(this); 89 | public int DefaultOutputDeviceIndex => _DefaultOutputDeviceIndex(this); 90 | 91 | #endregion 92 | 93 | #region Unmanaged functions 94 | 95 | [DllImport(Config.DllName, EntryPoint="soundio_create")] 96 | extern static Context _Create(); 97 | 98 | [DllImport(Config.DllName, EntryPoint="soundio_destroy")] 99 | extern static void _Destroy(IntPtr context); 100 | 101 | [DllImport(Config.DllName, EntryPoint="soundio_connect")] 102 | extern static Error _Connect(Context context); 103 | 104 | [DllImport(Config.DllName, EntryPoint="soundio_connect_backend")] 105 | extern static Error _Connect(Context context, Backend backend); 106 | 107 | [DllImport(Config.DllName, EntryPoint="soundio_disconnect")] 108 | extern static void _Disconnect(Context context); 109 | 110 | [DllImport(Config.DllName, EntryPoint="soundio_flush_events")] 111 | extern static void _FlushEvents(Context context); 112 | 113 | [DllImport(Config.DllName, EntryPoint="soundio_output_device_count")] 114 | extern static int _OutputDeviceCount(Context context); 115 | 116 | [DllImport(Config.DllName, EntryPoint="soundio_input_device_count")] 117 | extern static int _InputDeviceCount(Context context); 118 | 119 | [DllImport(Config.DllName, EntryPoint="soundio_get_input_device")] 120 | extern static Device _GetInputDevice(Context context, int index); 121 | 122 | [DllImport(Config.DllName, EntryPoint="soundio_get_output_device")] 123 | extern static Device _GetOutputDevice(Context context, int index); 124 | 125 | [DllImport(Config.DllName, EntryPoint="soundio_default_input_device_index")] 126 | extern static int _DefaultInputDeviceIndex(Context context); 127 | 128 | [DllImport(Config.DllName, EntryPoint="soundio_default_output_device_index")] 129 | extern static int _DefaultOutputDeviceIndex(Context context); 130 | 131 | #endregion 132 | } 133 | } 134 | -------------------------------------------------------------------------------- /Assets/Test/DftBuffer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Unity.Collections; 4 | using Unity.Jobs; 5 | using Unity.Mathematics; 6 | using UnityEngine.Profiling; 7 | 8 | // DFT with the C# job system and the Burst compiler 9 | 10 | public sealed class DftBuffer : IDisposable 11 | { 12 | #region Public properties 13 | 14 | public int Width { get; private set; } 15 | public ReadOnlySpan Spectrum => _spectrum.GetReadOnlySpan(); 16 | 17 | #endregion 18 | 19 | #region IDisposable implementation 20 | 21 | public void Dispose() 22 | { 23 | if (_input .IsCreated) _input .Dispose(); 24 | if (_spectrum.IsCreated) _spectrum.Dispose(); 25 | if (_window .IsCreated) _window .Dispose(); 26 | if (_coeffsR .IsCreated) _coeffsR .Dispose(); 27 | if (_coeffsI .IsCreated) _coeffsI .Dispose(); 28 | } 29 | 30 | #endregion 31 | 32 | #region Public methods 33 | 34 | public DftBuffer(int width) 35 | { 36 | Width = width; 37 | 38 | // Hanning window 39 | var window = Enumerable.Range(0, Width). 40 | Select(n => 2 * math.PI * n / (Width - 1)). 41 | Select(x => 0.5f * (1 - math.cos(x))); 42 | 43 | // DFT coefficients 44 | var coeffs = Enumerable.Range(0, Width / 2 * Width). 45 | Select(i => (k: i / Width, n: i % Width)). 46 | Select(I => 2 * math.PI / Width * I.k * I.n); 47 | 48 | var coeffsR = coeffs.Select(x => math.cos(x)); 49 | var coeffsI = coeffs.Select(x => math.sin(x)); 50 | 51 | // Native array allocation and initialization 52 | var ator = Allocator.Persistent; 53 | _input = new NativeArray(Width , ator); 54 | _spectrum = new NativeArray(Width / 2 , ator); 55 | _window = new NativeArray(window .ToArray(), ator); 56 | _coeffsR = new NativeArray(coeffsR.ToArray(), ator); 57 | _coeffsI = new NativeArray(coeffsI.ToArray(), ator); 58 | } 59 | 60 | // Push audio data to the FIFO buffer. 61 | public void Push(ReadOnlySpan span) 62 | { 63 | var data = span.GetNativeSlice(); 64 | var length = span.Length; 65 | 66 | if (length == 0) return; 67 | 68 | if (length < Width) 69 | { 70 | // The data is smaller than the buffer: Dequeue and copy 71 | var part = Width - length; 72 | NativeArray.Copy(_input, Width - part, _input, 0, part); 73 | data.CopyTo(_input.GetSubArray(part, length)); 74 | } 75 | else 76 | { 77 | // The data is larger than the buffer: Simple fill 78 | data.Slice(length - Width).CopyTo(_input); 79 | } 80 | } 81 | 82 | // Analyze the input buffer to calculate spectrum data. 83 | public void Analyze() 84 | { 85 | Profiler.BeginSample("Spectrum Analyer DFT"); 86 | 87 | using (var temp = AllocateTempJobMemory(Width)) 88 | { 89 | // Preparation job (window function) 90 | var job1 = new PreparationJob 91 | { 92 | input = _input .Reinterpret(4), 93 | window = _window.Reinterpret(4), 94 | output = temp .Reinterpret(4), 95 | }; 96 | 97 | // DFT job 98 | var job2 = new DftJob 99 | { 100 | input = temp .Reinterpret(4), 101 | coeffsR = _coeffsR.Reinterpret(4), 102 | coeffsI = _coeffsI.Reinterpret(4), 103 | output = _spectrum 104 | }; 105 | 106 | // Dispatch and wait. 107 | var handle = new JobHandle(); 108 | handle = job1.Schedule(Width / 4, handle); 109 | handle = job2.Schedule(Width / 2, 4, handle); 110 | handle.Complete(); 111 | } 112 | 113 | Profiler.EndSample(); 114 | } 115 | 116 | #endregion 117 | 118 | #region Internal members 119 | 120 | NativeArray _input; 121 | NativeArray _spectrum; 122 | NativeArray _window; 123 | NativeArray _coeffsR; 124 | NativeArray _coeffsI; 125 | 126 | NativeArray AllocateTempJobMemory(int size) 127 | where T : unmanaged => new NativeArray 128 | (size, Allocator.TempJob, NativeArrayOptions.UninitializedMemory); 129 | 130 | #endregion 131 | 132 | #region Preparation job 133 | 134 | [Unity.Burst.BurstCompile(CompileSynchronously = true)] 135 | struct PreparationJob : IJobFor 136 | { 137 | [ReadOnly] public NativeArray input; 138 | [ReadOnly] public NativeArray window; 139 | [WriteOnly] public NativeArray output; 140 | 141 | public void Execute(int i) => output[i] = input[i] * window[i]; 142 | } 143 | 144 | #endregion 145 | 146 | #region DFT kernel job 147 | 148 | [Unity.Burst.BurstCompile(CompileSynchronously = true)] 149 | struct DftJob : IJobParallelFor 150 | { 151 | [ReadOnly] public NativeArray input; 152 | [ReadOnly] public NativeArray coeffsR; 153 | [ReadOnly] public NativeArray coeffsI; 154 | [WriteOnly] public NativeArray output; 155 | 156 | public void Execute(int i) 157 | { 158 | var offs = i * input.Length; 159 | 160 | var rl = 0.0f; 161 | var im = 0.0f; 162 | 163 | for (var n = 0; n < input.Length; n++) 164 | { 165 | var x_n = input[n]; 166 | rl += math.dot(x_n, coeffsR[offs + n]); 167 | im -= math.dot(x_n, coeffsI[offs + n]); 168 | } 169 | 170 | output[i] = math.sqrt(rl * rl + im * im) * 0.5f / input.Length; 171 | } 172 | } 173 | 174 | #endregion 175 | } 176 | -------------------------------------------------------------------------------- /Packages/jp.keijiro.libsoundio/Runtime/InStream.cs: -------------------------------------------------------------------------------- 1 | // libsoundio C# thin wrapper class library 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | using Microsoft.Win32.SafeHandles; 7 | 8 | namespace SoundIO 9 | { 10 | // SoundIoInStream struct representation (used in read-callback) 11 | [StructLayout(LayoutKind.Sequential)] 12 | public struct InStreamData 13 | { 14 | #region Struct data members 15 | 16 | internal IntPtr device; 17 | internal Format format; 18 | internal int sampleRate; 19 | internal ChannelLayout layout; 20 | internal double softwareLatency; 21 | internal IntPtr userData; 22 | internal IntPtr readCallback; 23 | internal IntPtr overflowCallback; 24 | internal IntPtr errorCallback; 25 | internal IntPtr name; 26 | internal byte nonTerminalHint; 27 | internal int bytesPerFrame; 28 | internal int bytesPerSample; 29 | internal Error layoutError; 30 | 31 | #endregion 32 | 33 | #region Struct member accessors 34 | 35 | public Format Format => format; 36 | public int SampleRate => sampleRate; 37 | public ChannelLayout Layout => layout; 38 | public double SoftwareLatency => softwareLatency; 39 | public IntPtr UserData => userData; 40 | public string Name => Marshal.PtrToStringAnsi(name); 41 | public bool NonTerminalHint => nonTerminalHint != 0; 42 | public int BytesPerFrame => bytesPerFrame; 43 | public int BytesPerSample => bytesPerSample; 44 | 45 | #endregion 46 | 47 | #region Data reader methods 48 | 49 | public unsafe Error BeginRead(out ChannelArea* areas, ref int frameCount) 50 | { 51 | return _BeginRead(ref this, out areas, ref frameCount); 52 | } 53 | 54 | public Error EndRead() 55 | { 56 | return _EndRead(ref this); 57 | } 58 | 59 | #endregion 60 | 61 | #region Unmanaged functions 62 | 63 | [DllImport(Config.DllName, EntryPoint="soundio_instream_begin_read")] 64 | unsafe extern static Error _BeginRead 65 | (ref InStreamData stream, out ChannelArea* areas, ref int frameCount); 66 | 67 | [DllImport(Config.DllName, EntryPoint="soundio_instream_end_read")] 68 | extern static Error _EndRead(ref InStreamData stream); 69 | 70 | #endregion 71 | } 72 | 73 | // SoundIoInStream struct wrapper class 74 | public class InStream : SafeHandleZeroOrMinusOneIsInvalid 75 | { 76 | #region SafeHandle implementation 77 | 78 | InStream() : base(true) {} 79 | 80 | protected override bool ReleaseHandle() 81 | { 82 | _Destroy(this.handle); 83 | return true; 84 | } 85 | 86 | unsafe ref InStreamData Data => ref Unsafe.AsRef((void*)handle); 87 | 88 | #endregion 89 | 90 | #region Struct member accessors 91 | 92 | public Format Format 93 | { 94 | get => Data.format; 95 | set => Data.format = value; 96 | } 97 | 98 | public int SampleRate 99 | { 100 | get => Data.sampleRate; 101 | set => Data.sampleRate = value; 102 | } 103 | 104 | public ChannelLayout Layout 105 | { 106 | get => Data.layout; 107 | set => Data.layout = value; 108 | } 109 | 110 | public double SoftwareLatency 111 | { 112 | get => Data.softwareLatency; 113 | set => Data.softwareLatency = value; 114 | } 115 | 116 | public IntPtr UserData 117 | { 118 | get => Data.userData; 119 | set => Data.userData = value; 120 | } 121 | 122 | public delegate void ReadCallbackDelegate(ref InStreamData stream, int frameCountMin, int frameCountMax); 123 | 124 | public ReadCallbackDelegate ReadCallback 125 | { 126 | get => Marshal.GetDelegateForFunctionPointer(Data.readCallback); 127 | set => Data.readCallback = Marshal.GetFunctionPointerForDelegate(value); 128 | } 129 | 130 | public delegate void OverflowCallbackDelegate(ref InStreamData stream); 131 | 132 | public OverflowCallbackDelegate OverflowCallback 133 | { 134 | get => Marshal.GetDelegateForFunctionPointer(Data.overflowCallback); 135 | set => Data.overflowCallback = Marshal.GetFunctionPointerForDelegate(value); 136 | } 137 | 138 | public delegate void ErrorCallbackDelegate(ref InStreamData stream, Error error); 139 | 140 | public ErrorCallbackDelegate ErrorCallback 141 | { 142 | get => Marshal.GetDelegateForFunctionPointer(Data.errorCallback); 143 | set => Data.errorCallback = Marshal.GetFunctionPointerForDelegate(value); 144 | } 145 | 146 | public string Name => Marshal.PtrToStringAnsi(Data.name); 147 | 148 | public bool NonTerminalHint 149 | { 150 | get => Data.nonTerminalHint != 0; 151 | set => Data.nonTerminalHint = value ? (byte)1 : (byte)0; 152 | } 153 | 154 | public int BytesPerFrame => Data.bytesPerFrame; 155 | public int BytesPerSample => Data.bytesPerSample; 156 | 157 | public Error LayoutError => Data.layoutError; 158 | 159 | #endregion 160 | 161 | #region Public properties and methods 162 | 163 | static public InStream Create(Device device) => _Create(device); 164 | 165 | public Error Open() => _Open(this); 166 | public Error Start() => _Start(this); 167 | public Error Pause(bool pause) => _Pause(this, pause ? (byte)1 : (byte)0); 168 | public Error GetLatency(out double latency) => _GetLatency(this, out latency); 169 | 170 | #endregion 171 | 172 | #region Unmanaged functions 173 | 174 | [DllImport(Config.DllName, EntryPoint="soundio_instream_destroy")] 175 | extern static void _Destroy(IntPtr stream); 176 | 177 | [DllImport(Config.DllName, EntryPoint="soundio_instream_create")] 178 | extern static InStream _Create(Device device); 179 | 180 | [DllImport(Config.DllName, EntryPoint="soundio_instream_open")] 181 | extern static Error _Open(InStream stream); 182 | 183 | [DllImport(Config.DllName, EntryPoint="soundio_instream_start")] 184 | extern static Error _Start(InStream stream); 185 | 186 | [DllImport(Config.DllName, EntryPoint="soundio_instream_pause")] 187 | extern static Error _Pause(InStream stream, byte pause); 188 | 189 | [DllImport(Config.DllName, EntryPoint="soundio_instream_get_latency")] 190 | extern static Error _GetLatency(InStream stream, out double latency); 191 | 192 | #endregion 193 | } 194 | } 195 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: 0.001 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: 0.001 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: 0.001 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: 0.001 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: 0.001 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: 0.001 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: 0.1 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: 0.1 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: 0.1 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: 0.19 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: 0.19 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: 0.001 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: 0.001 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: 0.001 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: 0.001 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: 0.001 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: 0.001 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: 0.001 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /Assets/SimpleDriver/InputStream.cs: -------------------------------------------------------------------------------- 1 | // Simple driver for libsoundio 2 | // https://github.com/keijiro/jp.keijiro.libsoundio 3 | 4 | using System; 5 | using System.Runtime.InteropServices; 6 | using InvalidOp = System.InvalidOperationException; 7 | 8 | namespace SoundIO.SimpleDriver 9 | { 10 | // 11 | // High-level wrapper class for SoundIoInStream 12 | // 13 | // - Manages an InStream object. 14 | // - Manages a sound input ring buffer. 15 | // - Provides the "last frame window" that exposes incoming sound data that 16 | // was received during the last frame. 17 | // - Implements callback functions for the InStream object. 18 | // 19 | public sealed class InputStream : IDisposable 20 | { 21 | #region Public properties and methods 22 | 23 | public int ChannelCount => _stream.Layout.ChannelCount; 24 | public int SampleRate => _stream.SampleRate; 25 | public float Latency => (float)_stream.SoftwareLatency; 26 | 27 | public bool IsValid => 28 | _stream != null && !_stream.IsInvalid && !_stream.IsClosed; 29 | 30 | public ReadOnlySpan LastFrameWindow => 31 | new ReadOnlySpan(_window, 0, _windowSize); 32 | 33 | public void Dispose() 34 | { 35 | _stream?.Dispose(); 36 | _device?.Dispose(); 37 | _self.Free(); 38 | } 39 | 40 | public void Update() 41 | { 42 | // Last frame window size 43 | var dt = UnityEngine.Time.deltaTime; 44 | _windowSize = Math.Min(_window.Length, CalculateBufferSize(dt)); 45 | 46 | lock (_ring) 47 | { 48 | // Copy the last frame data into the window buffer. 49 | if (_ring.FillCount >= _windowSize) 50 | _ring.Read(new Span(_window, 0, _windowSize)); 51 | else 52 | _windowSize = 0; // Underflow 53 | 54 | // Reset the buffer when it detects an overflow. 55 | // TODO: Is this the best strategy to deal with overflow? 56 | if (_ring.OverflowCount > 0) _ring.Clear(); 57 | } 58 | } 59 | 60 | #endregion 61 | 62 | #region Constructor 63 | 64 | public InputStream(Device deviceToOwn) 65 | { 66 | _self = GCHandle.Alloc(this); 67 | _device = deviceToOwn; 68 | _stream = InStream.Create(_device); 69 | 70 | try 71 | { 72 | if (_stream.IsInvalid) 73 | throw new InvalidOp("Stream allocation error"); 74 | 75 | if (_device.Layouts.Length == 0) 76 | throw new InvalidOp("No channel layout"); 77 | 78 | // Calculate the best latency. 79 | // TODO: Should we use the target frame rate instead of 1/60? 80 | var bestLatency = Math.Max(1.0 / 60, _device.SoftwareLatencyMin); 81 | 82 | // Stream properties 83 | _stream.Format = Format.Float32LE; 84 | _stream.Layout = _device.Layouts[0]; 85 | _stream.SoftwareLatency = bestLatency; 86 | _stream.ReadCallback = _readCallback; 87 | _stream.OverflowCallback = _overflowCallback; 88 | _stream.ErrorCallback = _errorCallback; 89 | _stream.UserData = GCHandle.ToIntPtr(_self); 90 | 91 | var err = _stream.Open(); 92 | 93 | if (err != Error.None) 94 | throw new InvalidOp($"Stream initialization error ({err})"); 95 | 96 | // We want the buffers to meet the following requirements: 97 | // - Doesn't overflow if the main thread pauses for 4 frames. 98 | // - Doesn't overflow if the callback is invoked 4 times a frame. 99 | var latency = Math.Max(_stream.SoftwareLatency, bestLatency); 100 | var bufferSize = CalculateBufferSize((float)(latency * 4)); 101 | 102 | // Ring/window buffer allocation 103 | _ring = new RingBuffer(bufferSize); 104 | _window = new byte[bufferSize]; 105 | 106 | // Start streaming. 107 | _stream.Start(); 108 | } 109 | catch 110 | { 111 | // Dispose the resources on an exception. 112 | _stream.Dispose(); 113 | _device.Dispose(); 114 | _stream = null; 115 | _device = null; 116 | throw; 117 | } 118 | } 119 | 120 | #endregion 121 | 122 | #region Internal objects 123 | 124 | // GC handle used to share 'this' pointer with unmanaged code 125 | GCHandle _self; 126 | 127 | // SoundIO objects 128 | Device _device; 129 | InStream _stream; 130 | 131 | // Input stream ring buffer 132 | // This object will be accessed from both the main/callback thread. 133 | // Must be locked when accessing it. 134 | RingBuffer _ring; 135 | 136 | // Buffer for the last frame window 137 | byte[] _window; 138 | int _windowSize; 139 | 140 | #endregion 141 | 142 | #region Internal function 143 | 144 | int CalculateBufferSize(float second) => 145 | sizeof(float) * ChannelCount * (int)(SampleRate * second); 146 | 147 | #endregion 148 | 149 | #region SoundIO callback delegates 150 | 151 | static InStream.ReadCallbackDelegate _readCallback = OnReadInStream; 152 | static InStream.OverflowCallbackDelegate _overflowCallback = OnOverflowInStream; 153 | static InStream.ErrorCallbackDelegate _errorCallback = OnErrorInStream; 154 | 155 | [AOT.MonoPInvokeCallback(typeof(InStream.ReadCallbackDelegate))] 156 | unsafe static void OnReadInStream(ref InStreamData stream, int min, int left) 157 | { 158 | // Recover the 'this' reference from the UserData pointer. 159 | var self = (InputStream)GCHandle.FromIntPtr(stream.UserData).Target; 160 | 161 | while (left > 0) 162 | { 163 | // Start reading the buffer. 164 | var count = left; 165 | ChannelArea* areas; 166 | stream.BeginRead(out areas, ref count); 167 | 168 | // When getting count == 0, we must stop reading 169 | // immediately without calling InStream.EndRead. 170 | if (count == 0) break; 171 | 172 | if (areas == null) 173 | { 174 | // We must do zero-fill when receiving a null pointer. 175 | lock (self._ring) 176 | self._ring.WriteEmpty(stream.BytesPerFrame * count); 177 | } 178 | else 179 | { 180 | // Determine the memory span of the input data with 181 | // assuming the data is tightly packed. 182 | // TODO: Is this assumption always true? 183 | var span = new ReadOnlySpan( 184 | (void*)areas[0].Pointer, 185 | areas[0].Step * count 186 | ); 187 | 188 | // Transfer the data to the ring buffer. 189 | lock (self._ring) self._ring.Write(span); 190 | } 191 | 192 | stream.EndRead(); 193 | 194 | left -= count; 195 | } 196 | } 197 | 198 | [AOT.MonoPInvokeCallback(typeof(InStream.OverflowCallbackDelegate))] 199 | static void OnOverflowInStream(ref InStreamData stream) 200 | { 201 | UnityEngine.Debug.LogWarning("InStream overflow"); 202 | } 203 | 204 | [AOT.MonoPInvokeCallback(typeof(InStream.ErrorCallbackDelegate))] 205 | static void OnErrorInStream(ref InStreamData stream, Error error) 206 | { 207 | UnityEngine.Debug.LogError($"InStream error ({error})"); 208 | } 209 | 210 | #endregion 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!129 &1 4 | PlayerSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 28 7 | productGUID: ce985197aef885349be98ba43583b158 8 | AndroidProfiler: 0 9 | AndroidFilterTouchesWhenObscured: 0 10 | AndroidEnableSustainedPerformanceMode: 0 11 | defaultScreenOrientation: 4 12 | targetDevice: 2 13 | useOnDemandResources: 0 14 | accelerometerFrequency: 60 15 | companyName: DefaultCompany 16 | productName: libsoundio-test 17 | defaultCursor: {fileID: 0} 18 | cursorHotspot: {x: 0, y: 0} 19 | m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1} 20 | m_ShowUnitySplashScreen: 0 21 | m_ShowUnitySplashLogo: 1 22 | m_SplashScreenOverlayOpacity: 1 23 | m_SplashScreenAnimation: 1 24 | m_SplashScreenLogoStyle: 1 25 | m_SplashScreenDrawMode: 0 26 | m_SplashScreenBackgroundAnimationZoom: 1 27 | m_SplashScreenLogoAnimationZoom: 1 28 | m_SplashScreenBackgroundLandscapeAspect: 1 29 | m_SplashScreenBackgroundPortraitAspect: 1 30 | m_SplashScreenBackgroundLandscapeUvs: 31 | serializedVersion: 2 32 | x: 0 33 | y: 0 34 | width: 1 35 | height: 1 36 | m_SplashScreenBackgroundPortraitUvs: 37 | serializedVersion: 2 38 | x: 0 39 | y: 0 40 | width: 1 41 | height: 1 42 | m_SplashScreenLogos: [] 43 | m_VirtualRealitySplashScreen: {fileID: 0} 44 | m_HolographicTrackingLossScreen: {fileID: 0} 45 | defaultScreenWidth: 1280 46 | defaultScreenHeight: 720 47 | defaultScreenWidthWeb: 960 48 | defaultScreenHeightWeb: 600 49 | m_StereoRenderingPath: 0 50 | m_ActiveColorSpace: 0 51 | unsupportedMSAAFallback: 0 52 | m_SpriteBatchMaxVertexCount: 65535 53 | m_SpriteBatchVertexThreshold: 300 54 | m_MTRendering: 1 55 | mipStripping: 0 56 | numberOfMipsStripped: 0 57 | numberOfMipsStrippedPerMipmapLimitGroup: {} 58 | m_StackTraceTypes: 010000000100000001000000010000000100000001000000 59 | iosShowActivityIndicatorOnLoading: -1 60 | androidShowActivityIndicatorOnLoading: -1 61 | iosUseCustomAppBackgroundBehavior: 0 62 | allowedAutorotateToPortrait: 1 63 | allowedAutorotateToPortraitUpsideDown: 1 64 | allowedAutorotateToLandscapeRight: 1 65 | allowedAutorotateToLandscapeLeft: 1 66 | useOSAutorotation: 1 67 | use32BitDisplayBuffer: 1 68 | preserveFramebufferAlpha: 0 69 | disableDepthAndStencilBuffers: 0 70 | androidStartInFullscreen: 1 71 | androidRenderOutsideSafeArea: 1 72 | androidUseSwappy: 0 73 | androidBlitType: 0 74 | androidResizeableActivity: 1 75 | androidDefaultWindowWidth: 1920 76 | androidDefaultWindowHeight: 1080 77 | androidMinimumWindowWidth: 400 78 | androidMinimumWindowHeight: 300 79 | androidFullscreenMode: 1 80 | androidAutoRotationBehavior: 1 81 | androidPredictiveBackSupport: 0 82 | androidApplicationEntry: 1 83 | defaultIsNativeResolution: 1 84 | macRetinaSupport: 1 85 | runInBackground: 1 86 | muteOtherAudioSources: 0 87 | Prepare IOS For Recording: 0 88 | Force IOS Speakers When Recording: 0 89 | deferSystemGesturesMode: 0 90 | hideHomeButton: 0 91 | submitAnalytics: 1 92 | usePlayerLog: 1 93 | dedicatedServerOptimizations: 1 94 | bakeCollisionMeshes: 0 95 | forceSingleInstance: 0 96 | useFlipModelSwapchain: 1 97 | resizableWindow: 0 98 | useMacAppStoreValidation: 0 99 | macAppStoreCategory: public.app-category.games 100 | gpuSkinning: 1 101 | meshDeformation: 2 102 | xboxPIXTextureCapture: 0 103 | xboxEnableAvatar: 0 104 | xboxEnableKinect: 0 105 | xboxEnableKinectAutoTracking: 0 106 | xboxEnableFitness: 0 107 | visibleInBackground: 1 108 | allowFullscreenSwitch: 1 109 | fullscreenMode: 3 110 | xboxSpeechDB: 0 111 | xboxEnableHeadOrientation: 0 112 | xboxEnableGuest: 0 113 | xboxEnablePIXSampling: 0 114 | metalFramebufferOnly: 0 115 | xboxOneResolution: 0 116 | xboxOneSResolution: 0 117 | xboxOneXResolution: 3 118 | xboxOneMonoLoggingLevel: 0 119 | xboxOneLoggingLevel: 1 120 | xboxOneDisableEsram: 0 121 | xboxOneEnableTypeOptimization: 0 122 | xboxOnePresentImmediateThreshold: 0 123 | switchQueueCommandMemory: 0 124 | switchQueueControlMemory: 16384 125 | switchQueueComputeMemory: 262144 126 | switchNVNShaderPoolsGranularity: 33554432 127 | switchNVNDefaultPoolsGranularity: 16777216 128 | switchNVNOtherPoolsGranularity: 16777216 129 | switchGpuScratchPoolGranularity: 2097152 130 | switchAllowGpuScratchShrinking: 0 131 | switchNVNMaxPublicTextureIDCount: 0 132 | switchNVNMaxPublicSamplerIDCount: 0 133 | switchMaxWorkerMultiple: 8 134 | switchNVNGraphicsFirmwareMemory: 32 135 | vulkanNumSwapchainBuffers: 3 136 | vulkanEnableSetSRGBWrite: 0 137 | vulkanEnablePreTransform: 0 138 | vulkanEnableLateAcquireNextImage: 0 139 | vulkanEnableCommandBufferRecycling: 1 140 | loadStoreDebugModeEnabled: 0 141 | visionOSBundleVersion: 1.0 142 | tvOSBundleVersion: 1.0 143 | bundleVersion: 0.1 144 | preloadedAssets: [] 145 | metroInputSource: 0 146 | wsaTransparentSwapchain: 0 147 | m_HolographicPauseOnTrackingLoss: 1 148 | xboxOneDisableKinectGpuReservation: 1 149 | xboxOneEnable7thCore: 1 150 | vrSettings: 151 | enable360StereoCapture: 0 152 | isWsaHolographicRemotingEnabled: 0 153 | enableFrameTimingStats: 0 154 | enableOpenGLProfilerGPURecorders: 1 155 | allowHDRDisplaySupport: 0 156 | useHDRDisplay: 0 157 | hdrBitDepth: 0 158 | m_ColorGamuts: 00000000 159 | targetPixelDensity: 30 160 | resolutionScalingMode: 0 161 | resetResolutionOnWindowResize: 0 162 | androidSupportedAspectRatio: 1 163 | androidMaxAspectRatio: 2.1 164 | androidMinAspectRatio: 1 165 | applicationIdentifier: {} 166 | buildNumber: 167 | Standalone: 0 168 | VisionOS: 0 169 | iPhone: 0 170 | tvOS: 0 171 | overrideDefaultApplicationIdentifier: 0 172 | AndroidBundleVersionCode: 1 173 | AndroidMinSdkVersion: 23 174 | AndroidTargetSdkVersion: 0 175 | AndroidPreferredInstallLocation: 1 176 | aotOptions: 177 | stripEngineCode: 1 178 | iPhoneStrippingLevel: 0 179 | iPhoneScriptCallOptimization: 0 180 | ForceInternetPermission: 0 181 | ForceSDCardPermission: 0 182 | CreateWallpaper: 0 183 | androidSplitApplicationBinary: 0 184 | keepLoadedShadersAlive: 0 185 | StripUnusedMeshComponents: 1 186 | strictShaderVariantMatching: 0 187 | VertexChannelCompressionMask: 4054 188 | iPhoneSdkVersion: 988 189 | iOSSimulatorArchitecture: 0 190 | iOSTargetOSVersionString: 13.0 191 | tvOSSdkVersion: 0 192 | tvOSSimulatorArchitecture: 0 193 | tvOSRequireExtendedGameController: 0 194 | tvOSTargetOSVersionString: 13.0 195 | VisionOSSdkVersion: 0 196 | VisionOSTargetOSVersionString: 1.0 197 | uIPrerenderedIcon: 0 198 | uIRequiresPersistentWiFi: 0 199 | uIRequiresFullScreen: 1 200 | uIStatusBarHidden: 1 201 | uIExitOnSuspend: 0 202 | uIStatusBarStyle: 0 203 | appleTVSplashScreen: {fileID: 0} 204 | appleTVSplashScreen2x: {fileID: 0} 205 | tvOSSmallIconLayers: [] 206 | tvOSSmallIconLayers2x: [] 207 | tvOSLargeIconLayers: [] 208 | tvOSLargeIconLayers2x: [] 209 | tvOSTopShelfImageLayers: [] 210 | tvOSTopShelfImageLayers2x: [] 211 | tvOSTopShelfImageWideLayers: [] 212 | tvOSTopShelfImageWideLayers2x: [] 213 | iOSLaunchScreenType: 0 214 | iOSLaunchScreenPortrait: {fileID: 0} 215 | iOSLaunchScreenLandscape: {fileID: 0} 216 | iOSLaunchScreenBackgroundColor: 217 | serializedVersion: 2 218 | rgba: 0 219 | iOSLaunchScreenFillPct: 100 220 | iOSLaunchScreenSize: 100 221 | iOSLaunchScreeniPadType: 0 222 | iOSLaunchScreeniPadImage: {fileID: 0} 223 | iOSLaunchScreeniPadBackgroundColor: 224 | serializedVersion: 2 225 | rgba: 0 226 | iOSLaunchScreeniPadFillPct: 100 227 | iOSLaunchScreeniPadSize: 100 228 | iOSLaunchScreenCustomStoryboardPath: 229 | iOSLaunchScreeniPadCustomStoryboardPath: 230 | iOSDeviceRequirements: [] 231 | iOSURLSchemes: [] 232 | macOSURLSchemes: [] 233 | iOSBackgroundModes: 0 234 | iOSMetalForceHardShadows: 0 235 | metalEditorSupport: 1 236 | metalAPIValidation: 1 237 | metalCompileShaderBinary: 0 238 | iOSRenderExtraFrameOnPause: 0 239 | iosCopyPluginsCodeInsteadOfSymlink: 0 240 | appleDeveloperTeamID: 241 | iOSManualSigningProvisioningProfileID: 242 | tvOSManualSigningProvisioningProfileID: 243 | VisionOSManualSigningProvisioningProfileID: 244 | iOSManualSigningProvisioningProfileType: 0 245 | tvOSManualSigningProvisioningProfileType: 0 246 | VisionOSManualSigningProvisioningProfileType: 0 247 | appleEnableAutomaticSigning: 0 248 | iOSRequireARKit: 0 249 | iOSAutomaticallyDetectAndAddCapabilities: 1 250 | appleEnableProMotion: 0 251 | shaderPrecisionModel: 0 252 | clonedFromGUID: c0afd0d1d80e3634a9dac47e8a0426ea 253 | templatePackageId: com.unity.template.3d@4.2.5 254 | templateDefaultScene: Assets/Scenes/SampleScene.unity 255 | useCustomMainManifest: 0 256 | useCustomLauncherManifest: 0 257 | useCustomMainGradleTemplate: 0 258 | useCustomLauncherGradleManifest: 0 259 | useCustomBaseGradleTemplate: 0 260 | useCustomGradlePropertiesTemplate: 0 261 | useCustomGradleSettingsTemplate: 0 262 | useCustomProguardFile: 0 263 | AndroidTargetArchitectures: 1 264 | AndroidSplashScreenScale: 0 265 | androidSplashScreen: {fileID: 0} 266 | AndroidKeystoreName: 267 | AndroidKeyaliasName: 268 | AndroidEnableArmv9SecurityFeatures: 0 269 | AndroidEnableArm64MTE: 0 270 | AndroidBuildApkPerCpuArchitecture: 0 271 | AndroidTVCompatibility: 0 272 | AndroidIsGame: 1 273 | AndroidEnableTango: 0 274 | androidEnableBanner: 1 275 | androidUseLowAccuracyLocation: 0 276 | androidUseCustomKeystore: 0 277 | m_AndroidBanners: 278 | - width: 320 279 | height: 180 280 | banner: {fileID: 0} 281 | androidGamepadSupportLevel: 0 282 | AndroidMinifyRelease: 0 283 | AndroidMinifyDebug: 0 284 | AndroidValidateAppBundleSize: 1 285 | AndroidAppBundleSizeToValidate: 150 286 | AndroidReportGooglePlayAppDependencies: 1 287 | androidSymbolsSizeThreshold: 800 288 | m_BuildTargetIcons: [] 289 | m_BuildTargetPlatformIcons: 290 | - m_BuildTarget: iPhone 291 | m_Icons: 292 | - m_Textures: [] 293 | m_Width: 180 294 | m_Height: 180 295 | m_Kind: 0 296 | m_SubKind: iPhone 297 | - m_Textures: [] 298 | m_Width: 120 299 | m_Height: 120 300 | m_Kind: 0 301 | m_SubKind: iPhone 302 | - m_Textures: [] 303 | m_Width: 167 304 | m_Height: 167 305 | m_Kind: 0 306 | m_SubKind: iPad 307 | - m_Textures: [] 308 | m_Width: 152 309 | m_Height: 152 310 | m_Kind: 0 311 | m_SubKind: iPad 312 | - m_Textures: [] 313 | m_Width: 76 314 | m_Height: 76 315 | m_Kind: 0 316 | m_SubKind: iPad 317 | - m_Textures: [] 318 | m_Width: 120 319 | m_Height: 120 320 | m_Kind: 3 321 | m_SubKind: iPhone 322 | - m_Textures: [] 323 | m_Width: 80 324 | m_Height: 80 325 | m_Kind: 3 326 | m_SubKind: iPhone 327 | - m_Textures: [] 328 | m_Width: 80 329 | m_Height: 80 330 | m_Kind: 3 331 | m_SubKind: iPad 332 | - m_Textures: [] 333 | m_Width: 40 334 | m_Height: 40 335 | m_Kind: 3 336 | m_SubKind: iPad 337 | - m_Textures: [] 338 | m_Width: 87 339 | m_Height: 87 340 | m_Kind: 1 341 | m_SubKind: iPhone 342 | - m_Textures: [] 343 | m_Width: 58 344 | m_Height: 58 345 | m_Kind: 1 346 | m_SubKind: iPhone 347 | - m_Textures: [] 348 | m_Width: 29 349 | m_Height: 29 350 | m_Kind: 1 351 | m_SubKind: iPhone 352 | - m_Textures: [] 353 | m_Width: 58 354 | m_Height: 58 355 | m_Kind: 1 356 | m_SubKind: iPad 357 | - m_Textures: [] 358 | m_Width: 29 359 | m_Height: 29 360 | m_Kind: 1 361 | m_SubKind: iPad 362 | - m_Textures: [] 363 | m_Width: 60 364 | m_Height: 60 365 | m_Kind: 2 366 | m_SubKind: iPhone 367 | - m_Textures: [] 368 | m_Width: 40 369 | m_Height: 40 370 | m_Kind: 2 371 | m_SubKind: iPhone 372 | - m_Textures: [] 373 | m_Width: 40 374 | m_Height: 40 375 | m_Kind: 2 376 | m_SubKind: iPad 377 | - m_Textures: [] 378 | m_Width: 20 379 | m_Height: 20 380 | m_Kind: 2 381 | m_SubKind: iPad 382 | - m_Textures: [] 383 | m_Width: 1024 384 | m_Height: 1024 385 | m_Kind: 4 386 | m_SubKind: App Store 387 | m_BuildTargetBatching: 388 | - m_BuildTarget: Standalone 389 | m_StaticBatching: 1 390 | m_DynamicBatching: 0 391 | - m_BuildTarget: tvOS 392 | m_StaticBatching: 1 393 | m_DynamicBatching: 0 394 | - m_BuildTarget: Android 395 | m_StaticBatching: 1 396 | m_DynamicBatching: 0 397 | - m_BuildTarget: iPhone 398 | m_StaticBatching: 1 399 | m_DynamicBatching: 0 400 | - m_BuildTarget: WebGL 401 | m_StaticBatching: 0 402 | m_DynamicBatching: 0 403 | m_BuildTargetShaderSettings: [] 404 | m_BuildTargetGraphicsJobs: 405 | - m_BuildTarget: MacStandaloneSupport 406 | m_GraphicsJobs: 0 407 | - m_BuildTarget: Switch 408 | m_GraphicsJobs: 1 409 | - m_BuildTarget: MetroSupport 410 | m_GraphicsJobs: 1 411 | - m_BuildTarget: AppleTVSupport 412 | m_GraphicsJobs: 0 413 | - m_BuildTarget: BJMSupport 414 | m_GraphicsJobs: 1 415 | - m_BuildTarget: LinuxStandaloneSupport 416 | m_GraphicsJobs: 1 417 | - m_BuildTarget: PS4Player 418 | m_GraphicsJobs: 1 419 | - m_BuildTarget: iOSSupport 420 | m_GraphicsJobs: 0 421 | - m_BuildTarget: WindowsStandaloneSupport 422 | m_GraphicsJobs: 1 423 | - m_BuildTarget: XboxOnePlayer 424 | m_GraphicsJobs: 1 425 | - m_BuildTarget: LuminSupport 426 | m_GraphicsJobs: 0 427 | - m_BuildTarget: AndroidPlayer 428 | m_GraphicsJobs: 0 429 | - m_BuildTarget: WebGLSupport 430 | m_GraphicsJobs: 0 431 | m_BuildTargetGraphicsJobMode: 432 | - m_BuildTarget: PS4Player 433 | m_GraphicsJobMode: 0 434 | - m_BuildTarget: XboxOnePlayer 435 | m_GraphicsJobMode: 0 436 | m_BuildTargetGraphicsAPIs: 437 | - m_BuildTarget: AndroidPlayer 438 | m_APIs: 150000000b000000 439 | m_Automatic: 1 440 | - m_BuildTarget: iOSSupport 441 | m_APIs: 10000000 442 | m_Automatic: 1 443 | - m_BuildTarget: AppleTVSupport 444 | m_APIs: 10000000 445 | m_Automatic: 1 446 | - m_BuildTarget: WebGLSupport 447 | m_APIs: 0b000000 448 | m_Automatic: 1 449 | m_BuildTargetVRSettings: 450 | - m_BuildTarget: Standalone 451 | m_Enabled: 0 452 | m_Devices: 453 | - Oculus 454 | - OpenVR 455 | m_DefaultShaderChunkSizeInMB: 16 456 | m_DefaultShaderChunkCount: 0 457 | openGLRequireES31: 0 458 | openGLRequireES31AEP: 0 459 | openGLRequireES32: 0 460 | m_TemplateCustomTags: {} 461 | mobileMTRendering: 462 | Android: 1 463 | iPhone: 1 464 | tvOS: 1 465 | m_BuildTargetGroupLightmapEncodingQuality: [] 466 | m_BuildTargetGroupLightmapSettings: [] 467 | m_BuildTargetGroupLoadStoreDebugModeSettings: [] 468 | m_BuildTargetNormalMapEncoding: [] 469 | m_BuildTargetDefaultTextureCompressionFormat: [] 470 | playModeTestRunnerEnabled: 0 471 | runPlayModeTestAsEditModeTest: 0 472 | actionOnDotNetUnhandledException: 1 473 | editorGfxJobOverride: 1 474 | enableInternalProfiler: 0 475 | logObjCUncaughtExceptions: 1 476 | enableCrashReportAPI: 0 477 | cameraUsageDescription: 478 | locationUsageDescription: 479 | microphoneUsageDescription: The sample program requires audio interface access. 480 | bluetoothUsageDescription: 481 | macOSTargetOSVersion: 11.0 482 | switchNMETAOverride: 483 | switchNetLibKey: 484 | switchSocketMemoryPoolSize: 6144 485 | switchSocketAllocatorPoolSize: 128 486 | switchSocketConcurrencyLimit: 14 487 | switchScreenResolutionBehavior: 2 488 | switchUseCPUProfiler: 0 489 | switchEnableFileSystemTrace: 0 490 | switchLTOSetting: 0 491 | switchApplicationID: 0x01004b9000490000 492 | switchNSODependencies: 493 | switchCompilerFlags: 494 | switchTitleNames_0: 495 | switchTitleNames_1: 496 | switchTitleNames_2: 497 | switchTitleNames_3: 498 | switchTitleNames_4: 499 | switchTitleNames_5: 500 | switchTitleNames_6: 501 | switchTitleNames_7: 502 | switchTitleNames_8: 503 | switchTitleNames_9: 504 | switchTitleNames_10: 505 | switchTitleNames_11: 506 | switchTitleNames_12: 507 | switchTitleNames_13: 508 | switchTitleNames_14: 509 | switchTitleNames_15: 510 | switchPublisherNames_0: 511 | switchPublisherNames_1: 512 | switchPublisherNames_2: 513 | switchPublisherNames_3: 514 | switchPublisherNames_4: 515 | switchPublisherNames_5: 516 | switchPublisherNames_6: 517 | switchPublisherNames_7: 518 | switchPublisherNames_8: 519 | switchPublisherNames_9: 520 | switchPublisherNames_10: 521 | switchPublisherNames_11: 522 | switchPublisherNames_12: 523 | switchPublisherNames_13: 524 | switchPublisherNames_14: 525 | switchPublisherNames_15: 526 | switchIcons_0: {fileID: 0} 527 | switchIcons_1: {fileID: 0} 528 | switchIcons_2: {fileID: 0} 529 | switchIcons_3: {fileID: 0} 530 | switchIcons_4: {fileID: 0} 531 | switchIcons_5: {fileID: 0} 532 | switchIcons_6: {fileID: 0} 533 | switchIcons_7: {fileID: 0} 534 | switchIcons_8: {fileID: 0} 535 | switchIcons_9: {fileID: 0} 536 | switchIcons_10: {fileID: 0} 537 | switchIcons_11: {fileID: 0} 538 | switchIcons_12: {fileID: 0} 539 | switchIcons_13: {fileID: 0} 540 | switchIcons_14: {fileID: 0} 541 | switchIcons_15: {fileID: 0} 542 | switchSmallIcons_0: {fileID: 0} 543 | switchSmallIcons_1: {fileID: 0} 544 | switchSmallIcons_2: {fileID: 0} 545 | switchSmallIcons_3: {fileID: 0} 546 | switchSmallIcons_4: {fileID: 0} 547 | switchSmallIcons_5: {fileID: 0} 548 | switchSmallIcons_6: {fileID: 0} 549 | switchSmallIcons_7: {fileID: 0} 550 | switchSmallIcons_8: {fileID: 0} 551 | switchSmallIcons_9: {fileID: 0} 552 | switchSmallIcons_10: {fileID: 0} 553 | switchSmallIcons_11: {fileID: 0} 554 | switchSmallIcons_12: {fileID: 0} 555 | switchSmallIcons_13: {fileID: 0} 556 | switchSmallIcons_14: {fileID: 0} 557 | switchSmallIcons_15: {fileID: 0} 558 | switchManualHTML: 559 | switchAccessibleURLs: 560 | switchLegalInformation: 561 | switchMainThreadStackSize: 1048576 562 | switchPresenceGroupId: 563 | switchLogoHandling: 0 564 | switchReleaseVersion: 0 565 | switchDisplayVersion: 1.0.0 566 | switchStartupUserAccount: 0 567 | switchSupportedLanguagesMask: 0 568 | switchLogoType: 0 569 | switchApplicationErrorCodeCategory: 570 | switchUserAccountSaveDataSize: 0 571 | switchUserAccountSaveDataJournalSize: 0 572 | switchApplicationAttribute: 0 573 | switchCardSpecSize: -1 574 | switchCardSpecClock: -1 575 | switchRatingsMask: 0 576 | switchRatingsInt_0: 0 577 | switchRatingsInt_1: 0 578 | switchRatingsInt_2: 0 579 | switchRatingsInt_3: 0 580 | switchRatingsInt_4: 0 581 | switchRatingsInt_5: 0 582 | switchRatingsInt_6: 0 583 | switchRatingsInt_7: 0 584 | switchRatingsInt_8: 0 585 | switchRatingsInt_9: 0 586 | switchRatingsInt_10: 0 587 | switchRatingsInt_11: 0 588 | switchRatingsInt_12: 0 589 | switchLocalCommunicationIds_0: 590 | switchLocalCommunicationIds_1: 591 | switchLocalCommunicationIds_2: 592 | switchLocalCommunicationIds_3: 593 | switchLocalCommunicationIds_4: 594 | switchLocalCommunicationIds_5: 595 | switchLocalCommunicationIds_6: 596 | switchLocalCommunicationIds_7: 597 | switchParentalControl: 0 598 | switchAllowsScreenshot: 1 599 | switchAllowsVideoCapturing: 1 600 | switchAllowsRuntimeAddOnContentInstall: 0 601 | switchDataLossConfirmation: 0 602 | switchUserAccountLockEnabled: 0 603 | switchSystemResourceMemory: 16777216 604 | switchSupportedNpadStyles: 22 605 | switchNativeFsCacheSize: 32 606 | switchIsHoldTypeHorizontal: 0 607 | switchSupportedNpadCount: 8 608 | switchEnableTouchScreen: 1 609 | switchSocketConfigEnabled: 0 610 | switchTcpInitialSendBufferSize: 32 611 | switchTcpInitialReceiveBufferSize: 64 612 | switchTcpAutoSendBufferSizeMax: 256 613 | switchTcpAutoReceiveBufferSizeMax: 256 614 | switchUdpSendBufferSize: 9 615 | switchUdpReceiveBufferSize: 42 616 | switchSocketBufferEfficiency: 4 617 | switchSocketInitializeEnabled: 1 618 | switchNetworkInterfaceManagerInitializeEnabled: 1 619 | switchDisableHTCSPlayerConnection: 0 620 | switchUseNewStyleFilepaths: 1 621 | switchUseLegacyFmodPriorities: 0 622 | switchUseMicroSleepForYield: 1 623 | switchEnableRamDiskSupport: 0 624 | switchMicroSleepForYieldTime: 25 625 | switchRamDiskSpaceSize: 12 626 | switchUpgradedPlayerSettingsToNMETA: 0 627 | ps4NPAgeRating: 12 628 | ps4NPTitleSecret: 629 | ps4NPTrophyPackPath: 630 | ps4ParentalLevel: 11 631 | ps4ContentID: ED1633-NPXX51362_00-0000000000000000 632 | ps4Category: 0 633 | ps4MasterVersion: 01.00 634 | ps4AppVersion: 01.00 635 | ps4AppType: 0 636 | ps4ParamSfxPath: 637 | ps4VideoOutPixelFormat: 0 638 | ps4VideoOutInitialWidth: 1920 639 | ps4VideoOutBaseModeInitialWidth: 1920 640 | ps4VideoOutReprojectionRate: 60 641 | ps4PronunciationXMLPath: 642 | ps4PronunciationSIGPath: 643 | ps4BackgroundImagePath: 644 | ps4StartupImagePath: 645 | ps4StartupImagesFolder: 646 | ps4IconImagesFolder: 647 | ps4SaveDataImagePath: 648 | ps4SdkOverride: 649 | ps4BGMPath: 650 | ps4ShareFilePath: 651 | ps4ShareOverlayImagePath: 652 | ps4PrivacyGuardImagePath: 653 | ps4ExtraSceSysFile: 654 | ps4NPtitleDatPath: 655 | ps4RemotePlayKeyAssignment: -1 656 | ps4RemotePlayKeyMappingDir: 657 | ps4PlayTogetherPlayerCount: 0 658 | ps4EnterButtonAssignment: 1 659 | ps4ApplicationParam1: 0 660 | ps4ApplicationParam2: 0 661 | ps4ApplicationParam3: 0 662 | ps4ApplicationParam4: 0 663 | ps4DownloadDataSize: 0 664 | ps4GarlicHeapSize: 2048 665 | ps4ProGarlicHeapSize: 2560 666 | playerPrefsMaxSize: 32768 667 | ps4Passcode: frAQBc8Wsa1xVPfvJcrgRYwTiizs2trQ 668 | ps4pnSessions: 1 669 | ps4pnPresence: 1 670 | ps4pnFriends: 1 671 | ps4pnGameCustomData: 1 672 | playerPrefsSupport: 0 673 | enableApplicationExit: 0 674 | resetTempFolder: 1 675 | restrictedAudioUsageRights: 0 676 | ps4UseResolutionFallback: 0 677 | ps4ReprojectionSupport: 0 678 | ps4UseAudio3dBackend: 0 679 | ps4UseLowGarlicFragmentationMode: 1 680 | ps4SocialScreenEnabled: 0 681 | ps4ScriptOptimizationLevel: 0 682 | ps4Audio3dVirtualSpeakerCount: 14 683 | ps4attribCpuUsage: 0 684 | ps4PatchPkgPath: 685 | ps4PatchLatestPkgPath: 686 | ps4PatchChangeinfoPath: 687 | ps4PatchDayOne: 0 688 | ps4attribUserManagement: 0 689 | ps4attribMoveSupport: 0 690 | ps4attrib3DSupport: 0 691 | ps4attribShareSupport: 0 692 | ps4attribExclusiveVR: 0 693 | ps4disableAutoHideSplash: 0 694 | ps4videoRecordingFeaturesUsed: 0 695 | ps4contentSearchFeaturesUsed: 0 696 | ps4CompatibilityPS5: 0 697 | ps4AllowPS5Detection: 0 698 | ps4GPU800MHz: 1 699 | ps4attribEyeToEyeDistanceSettingVR: 0 700 | ps4IncludedModules: [] 701 | ps4attribVROutputEnabled: 0 702 | monoEnv: 703 | splashScreenBackgroundSourceLandscape: {fileID: 0} 704 | splashScreenBackgroundSourcePortrait: {fileID: 0} 705 | blurSplashScreenBackground: 1 706 | spritePackerPolicy: 707 | webGLMemorySize: 16 708 | webGLExceptionSupport: 1 709 | webGLNameFilesAsHashes: 0 710 | webGLShowDiagnostics: 0 711 | webGLDataCaching: 1 712 | webGLDebugSymbols: 0 713 | webGLEmscriptenArgs: 714 | webGLModulesDirectory: 715 | webGLTemplate: APPLICATION:Default 716 | webGLAnalyzeBuildSize: 0 717 | webGLUseEmbeddedResources: 0 718 | webGLCompressionFormat: 1 719 | webGLWasmArithmeticExceptions: 0 720 | webGLLinkerTarget: 1 721 | webGLThreadsSupport: 0 722 | webGLDecompressionFallback: 0 723 | webGLInitialMemorySize: 32 724 | webGLMaximumMemorySize: 2048 725 | webGLMemoryGrowthMode: 2 726 | webGLMemoryLinearGrowthStep: 16 727 | webGLMemoryGeometricGrowthStep: 0.2 728 | webGLMemoryGeometricGrowthCap: 96 729 | webGLEnableWebGPU: 0 730 | webGLPowerPreference: 2 731 | webGLWebAssemblyTable: 0 732 | webGLWebAssemblyBigInt: 0 733 | webGLCloseOnQuit: 0 734 | webWasm2023: 0 735 | scriptingDefineSymbols: {} 736 | additionalCompilerArguments: {} 737 | platformArchitecture: {} 738 | scriptingBackend: 739 | Android: 0 740 | Standalone: 0 741 | il2cppCompilerConfiguration: {} 742 | il2cppCodeGeneration: {} 743 | il2cppStacktraceInformation: {} 744 | managedStrippingLevel: 745 | Android: 1 746 | EmbeddedLinux: 1 747 | GameCoreScarlett: 1 748 | GameCoreXboxOne: 1 749 | Nintendo Switch: 1 750 | PS4: 1 751 | PS5: 1 752 | QNX: 1 753 | ReservedCFE: 1 754 | VisionOS: 1 755 | WebGL: 1 756 | Windows Store Apps: 1 757 | XboxOne: 1 758 | iPhone: 1 759 | tvOS: 1 760 | incrementalIl2cppBuild: {} 761 | suppressCommonWarnings: 1 762 | allowUnsafeCode: 1 763 | useDeterministicCompilation: 1 764 | additionalIl2CppArgs: 765 | scriptingRuntimeVersion: 1 766 | gcIncremental: 0 767 | gcWBarrierValidation: 0 768 | apiCompatibilityLevelPerPlatform: {} 769 | editorAssembliesCompatibilityLevel: 1 770 | m_RenderingPath: 1 771 | m_MobileRenderingPath: 1 772 | metroPackageName: Template_3D 773 | metroPackageVersion: 774 | metroCertificatePath: 775 | metroCertificatePassword: 776 | metroCertificateSubject: 777 | metroCertificateIssuer: 778 | metroCertificateNotAfter: 0000000000000000 779 | metroApplicationDescription: Template_3D 780 | wsaImages: {} 781 | metroTileShortName: 782 | metroTileShowName: 0 783 | metroMediumTileShowName: 0 784 | metroLargeTileShowName: 0 785 | metroWideTileShowName: 0 786 | metroSupportStreamingInstall: 0 787 | metroLastRequiredScene: 0 788 | metroDefaultTileSize: 1 789 | metroTileForegroundText: 2 790 | metroTileBackgroundColor: {r: 0.13333334, g: 0.17254902, b: 0.21568628, a: 0} 791 | metroSplashScreenBackgroundColor: {r: 0.12941177, g: 0.17254902, b: 0.21568628, 792 | a: 1} 793 | metroSplashScreenUseBackgroundColor: 0 794 | syncCapabilities: 0 795 | platformCapabilities: {} 796 | metroTargetDeviceFamilies: {} 797 | metroFTAName: 798 | metroFTAFileTypes: [] 799 | metroProtocolName: 800 | vcxProjDefaultLanguage: 801 | XboxOneProductId: 802 | XboxOneUpdateKey: 803 | XboxOneSandboxId: 804 | XboxOneContentId: 805 | XboxOneTitleId: 806 | XboxOneSCId: 807 | XboxOneGameOsOverridePath: 808 | XboxOnePackagingOverridePath: 809 | XboxOneAppManifestOverridePath: 810 | XboxOneVersion: 1.0.0.0 811 | XboxOnePackageEncryption: 0 812 | XboxOnePackageUpdateGranularity: 2 813 | XboxOneDescription: 814 | XboxOneLanguage: 815 | - enus 816 | XboxOneCapability: [] 817 | XboxOneGameRating: {} 818 | XboxOneIsContentPackage: 0 819 | XboxOneEnhancedXboxCompatibilityMode: 0 820 | XboxOneEnableGPUVariability: 1 821 | XboxOneSockets: {} 822 | XboxOneSplashScreen: {fileID: 0} 823 | XboxOneAllowedProductIds: [] 824 | XboxOnePersistentLocalStorageSize: 0 825 | XboxOneXTitleMemory: 8 826 | XboxOneOverrideIdentityName: 827 | XboxOneOverrideIdentityPublisher: 828 | vrEditorSettings: {} 829 | cloudServicesEnabled: 830 | UNet: 1 831 | luminIcon: 832 | m_Name: 833 | m_ModelFolderPath: 834 | m_PortalFolderPath: 835 | luminCert: 836 | m_CertPath: 837 | m_SignPackage: 1 838 | luminIsChannelApp: 0 839 | luminVersion: 840 | m_VersionCode: 1 841 | m_VersionName: 842 | hmiPlayerDataPath: 843 | hmiForceSRGBBlit: 0 844 | embeddedLinuxEnableGamepadInput: 0 845 | hmiCpuConfiguration: 846 | hmiLogStartupTiming: 0 847 | qnxGraphicConfPath: 848 | apiCompatibilityLevel: 6 849 | captureStartupLogs: {} 850 | activeInputHandler: 0 851 | windowsGamepadBackendHint: 0 852 | cloudProjectId: 853 | framebufferDepthMemorylessMode: 0 854 | qualitySettingsNames: [] 855 | projectName: 856 | organizationId: 857 | cloudEnabled: 0 858 | legacyClampBlendShapeWeights: 0 859 | hmiLoadingImage: {fileID: 0} 860 | platformRequiresReadableAssets: 0 861 | virtualTexturingSupportEnabled: 0 862 | insecureHttpOption: 0 863 | androidVulkanDenyFilterList: [] 864 | androidVulkanAllowFilterList: [] 865 | --------------------------------------------------------------------------------