diff --git a/Assets/Images/SpatialisationImages/BlueAudioSource.png b/Assets/Images/SpatialisationImages/BlueAudioSource.png index b2a3c09..3aafb05 100644 Binary files a/Assets/Images/SpatialisationImages/BlueAudioSource.png and b/Assets/Images/SpatialisationImages/BlueAudioSource.png differ diff --git a/Assets/Images/SpatialisationImages/GreenAudioSource.png b/Assets/Images/SpatialisationImages/GreenAudioSource.png new file mode 100644 index 0000000..01148fb Binary files /dev/null and b/Assets/Images/SpatialisationImages/GreenAudioSource.png differ diff --git a/Assets/Images/SpatialisationImages/GreenAudioSource.png.meta b/Assets/Images/SpatialisationImages/GreenAudioSource.png.meta new file mode 100644 index 0000000..f51b7d5 --- /dev/null +++ b/Assets/Images/SpatialisationImages/GreenAudioSource.png.meta @@ -0,0 +1,106 @@ +fileFormatVersion: 2 +guid: c50d11482e66d184f9c800fc21203a8b +TextureImporter: + fileIDToRecycleName: {} + externalObjects: {} + serializedVersion: 5 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: 8 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - serializedVersion: 2 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: Standalone + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + - serializedVersion: 2 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + vertices: [] + indices: + edges: [] + weights: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat b/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat new file mode 100644 index 0000000..cdb3227 --- /dev/null +++ b/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: GreenAudioSource + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 2800000, guid: c50d11482e66d184f9c800fc21203a8b, type: 3} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 1, b: 1, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat.meta b/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat.meta new file mode 100644 index 0000000..a81efb8 --- /dev/null +++ b/Assets/Images/SpatialisationImages/Materials/GreenAudioSource.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 586d054146c25994a9c7ca9ff85701a4 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 2100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Images/SpatialisationImages/RedAudioSource.png b/Assets/Images/SpatialisationImages/RedAudioSource.png index abf8700..c18116f 100644 Binary files a/Assets/Images/SpatialisationImages/RedAudioSource.png and b/Assets/Images/SpatialisationImages/RedAudioSource.png differ diff --git a/Assets/Materials/Green Sphere Material.mat b/Assets/Materials/Green Sphere Material.mat new file mode 100644 index 0000000..c8289e2 --- /dev/null +++ b/Assets/Materials/Green Sphere Material.mat @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Green Sphere Material + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.354 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 0.21960784, g: 0.5764706, b: 0.33822948, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/Green Sphere Material.mat.meta b/Assets/Materials/Green Sphere Material.mat.meta new file mode 100644 index 0000000..4caaef5 --- /dev/null +++ b/Assets/Materials/Green Sphere Material.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1a64bb011787acd448e61d0add544e33 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scenes/SpatialiseScene.unity b/Assets/Scenes/SpatialiseScene.unity index 96464e9..fa04ab5 100644 --- a/Assets/Scenes/SpatialiseScene.unity +++ b/Assets/Scenes/SpatialiseScene.unity @@ -148,6 +148,68 @@ MonoBehaviour: patchDir: /StreamingAssets/PdAssets/SpatialisationPatches/ patch: {fileID: 102900000, guid: 55f52df84da09804c81d203410a4fdde, type: 3} pipePrintToConsole: 1 + pureDataEvents: + Bang: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Float: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringFloatEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Symbol: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + List: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Message: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + midiEvents: + MidiNoteOn: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiControlChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiProgramChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPitchBend: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPolyAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiByte: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null --- !u!82 &27935066 AudioSource: m_ObjectHideFlags: 0 @@ -336,13 +398,15 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 1648548012} - - {fileID: 2036315274} - {fileID: 1984785756} - - {fileID: 1490087609} + - {fileID: 2036315274} + - {fileID: 1664882003} + - {fileID: 1814864771} - {fileID: 1975205260} + - {fileID: 1490087609} - {fileID: 288967916} m_Father: {fileID: 0} - m_RootOrder: 7 + m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &170076733 GameObject: @@ -424,7 +488,7 @@ GameObject: - component: {fileID: 178383051} - component: {fileID: 178383050} m_Layer: 0 - m_Name: Moving Sphere + m_Name: Moving Sphere - Unity Spatialisation m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -454,10 +518,72 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 14496bc842cc2dd40b3da723e07b976d, type: 3} m_Name: m_EditorClassIdentifier: - patchName: FilteredNoise + patchName: FilteredNoise-ADC patchDir: /StreamingAssets/PdAssets/SpatialisationPatches/ - patch: {fileID: 102900000, guid: 0f0b3965e1ca19a479d4cc4e00cd2810, type: 3} + patch: {fileID: 102900000, guid: 8d059ad70b1caa34abcb319fba07da55, type: 3} pipePrintToConsole: 1 + pureDataEvents: + Bang: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Float: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringFloatEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Symbol: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + List: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Message: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + midiEvents: + MidiNoteOn: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiControlChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiProgramChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPitchBend: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPolyAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiByte: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null --- !u!82 &178383052 AudioSource: m_ObjectHideFlags: 0 @@ -614,11 +740,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 178383049} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 0, y: 3, z: 30} + m_LocalPosition: {x: 0, y: 3, z: 40} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 6 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &222970854 GameObject: @@ -834,11 +960,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 288967915} m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: 1.1, y: 0.01, z: -3.1} + m_LocalPosition: {x: 3.7869995, y: 0.01, z: -3.464} m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} m_Children: [] m_Father: {fileID: 144170969} - m_RootOrder: 5 + m_RootOrder: 7 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!102 &288967917 TextMesh: @@ -847,8 +973,8 @@ TextMesh: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 288967915} - m_Text: "(note the use of a looping\n SpatialiserFix Soundfile;\n see FilteredNoise.pd - for\n more details)" + m_Text: "(note the use of a looping\n SpatialiserFix Soundfile;\n see FilteredNoise-ADC.pd\n + for more details)" m_OffsetZ: 0 m_CharacterSize: 0.03 m_LineSpacing: 1 @@ -1154,6 +1280,279 @@ MeshFilter: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 440634029} m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!1 &779449923 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 779449930} + - component: {fileID: 779449929} + - component: {fileID: 779449928} + - component: {fileID: 779449927} + - component: {fileID: 779449926} + - component: {fileID: 779449925} + - component: {fileID: 779449924} + m_Layer: 0 + m_Name: Moving Sphere - OculusSpatializer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &779449924 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3819b4d1512a80c4bb840f900fdebf13, type: 3} + m_Name: + m_EditorClassIdentifier: + objectToMove: {fileID: 779449930} + radius: 10 +--- !u!114 &779449925 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 14496bc842cc2dd40b3da723e07b976d, type: 3} + m_Name: + m_EditorClassIdentifier: + patchName: FilteredNoise + patchDir: /StreamingAssets/PdAssets/SpatialisationPatches/ + patch: {fileID: 102900000, guid: 0f0b3965e1ca19a479d4cc4e00cd2810, type: 3} + pipePrintToConsole: 1 + pureDataEvents: + Bang: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Float: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringFloatEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Symbol: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + List: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + Message: + m_PersistentCalls: + m_Calls: [] + m_TypeName: StringStringObjArrEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + midiEvents: + MidiNoteOn: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiControlChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiProgramChange: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPitchBend: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiPolyAftertouch: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null + MidiByte: + m_PersistentCalls: + m_Calls: [] + m_TypeName: IntIntEvent, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!82 &779449926 +AudioSource: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Enabled: 1 + serializedVersion: 4 + OutputAudioMixerGroup: {fileID: 0} + m_audioClip: {fileID: 0} + m_PlayOnAwake: 1 + m_Volume: 1 + m_Pitch: 1 + Loop: 0 + Mute: 0 + Spatialize: 1 + SpatializePostEffects: 1 + Priority: 128 + DopplerLevel: 1 + MinDistance: 1 + MaxDistance: 500 + Pan2D: 0 + rolloffMode: 0 + BypassEffects: 0 + BypassListenerEffects: 0 + BypassReverbZones: 0 + rolloffCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + - serializedVersion: 3 + time: 1 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + panLevelCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + spreadCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + reverbZoneMixCustomCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 1 + inSlope: 0 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.33333334 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 +--- !u!135 &779449927 +SphereCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!23 &779449928 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 2100000, guid: 1a64bb011787acd448e61d0add544e33, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &779449929 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0} +--- !u!4 &779449930 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 779449923} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 3, z: 30} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 6 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &917451453 GameObject: m_ObjectHideFlags: 0 @@ -1382,11 +1781,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1490087608} m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 2, y: 0.01, z: -1.65} - m_LocalScale: {x: 1.5, y: 2.818, z: 1} + m_LocalPosition: {x: 4.677, y: 0.01, z: -1.88} + m_LocalScale: {x: 1.5, y: 2.944672, z: 1} m_Children: [] m_Father: {fileID: 144170969} - m_RootOrder: 3 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!64 &1490087610 MeshCollider: @@ -1567,21 +1966,11 @@ TextMesh: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1648548011} - m_Text: 'This scene demonstrates how to - - spatialise PD patches in Unity. - - - The Red sphere (FilteredSound.pd) - - is spatialised, while the Blue sphere - - (SineDrone.pd) is not. - - - Look at the AudioSources for the 2 - - spheres to see how this is done:' + m_Text: "This scene demonstrates how to\r\nspatialise PD patches in Unity.\r\n\nThe + Green (FilteredSound.pd) and\r\nRed + (FilteredSound-ADC.pd)\nspheres are spatialised, while the\nBlue + sphere (SineDrone.pd) is not.\n\nLook at the AudioSources for the + 3\nspheres to see how this is done:" m_OffsetZ: 0 m_CharacterSize: 0.03 m_LineSpacing: 1 @@ -1630,6 +2019,94 @@ MeshRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: 0 +--- !u!1 &1664882002 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1664882003} + - component: {fileID: 1664882005} + - component: {fileID: 1664882004} + m_Layer: 0 + m_Name: Green Audio Source Label + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1664882003 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1664882002} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 1.29, y: 0.01, z: 0.038000107} + m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} + m_Children: [] + m_Father: {fileID: 144170969} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!102 &1664882004 +TextMesh: + serializedVersion: 3 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1664882002} + m_Text: 'Green Sphere + + (OculusSpatializer method)' + m_OffsetZ: 0 + m_CharacterSize: 0.03 + m_LineSpacing: 1 + m_Anchor: 0 + m_Alignment: 1 + m_TabSize: 4 + m_FontSize: 56 + m_FontStyle: 0 + m_RichText: 1 + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_Color: + serializedVersion: 2 + rgba: 2818572288 +--- !u!23 &1664882005 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1664882002} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 10100, guid: 0000000000000000e000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 --- !u!1 &1739204888 GameObject: m_ObjectHideFlags: 0 @@ -1690,6 +2167,93 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1814864770 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 1814864771} + - component: {fileID: 1814864774} + - component: {fileID: 1814864773} + - component: {fileID: 1814864772} + m_Layer: 0 + m_Name: Green Audio Source Screenshot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1814864771 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1814864770} + m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} + m_LocalPosition: {x: 2.32, y: 0.01, z: -1.92} + m_LocalScale: {x: 1.5, y: 3.024, z: 1.0000005} + m_Children: [] + m_Father: {fileID: 144170969} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} +--- !u!64 &1814864772 +MeshCollider: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1814864770} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 3 + m_Convex: 0 + m_CookingOptions: 14 + m_SkinWidth: 0.01 + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &1814864773 +MeshRenderer: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1814864770} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RenderingLayerMask: 4294967295 + m_Materials: + - {fileID: 2100000, guid: 586d054146c25994a9c7ca9ff85701a4, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 +--- !u!33 &1814864774 +MeshFilter: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1814864770} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} --- !u!1 &1975205259 GameObject: m_ObjectHideFlags: 0 @@ -1714,11 +2278,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1975205259} m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: 1.55, y: 0.01, z: 0} + m_LocalPosition: {x: 3.9199998, y: 0.01, z: 0.038000107} m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} m_Children: [] m_Father: {fileID: 144170969} - m_RootOrder: 4 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!102 &1975205261 TextMesh: @@ -1727,12 +2291,14 @@ TextMesh: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1975205259} - m_Text: Red Sphere + m_Text: 'Red Sphere + + (alternative method)' m_OffsetZ: 0 m_CharacterSize: 0.03 m_LineSpacing: 1 m_Anchor: 0 - m_Alignment: 0 + m_Alignment: 1 m_TabSize: 4 m_FontSize: 56 m_FontStyle: 0 @@ -1800,11 +2366,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 1984785755} m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068} - m_LocalPosition: {x: -0.46, y: 0.01, z: 0} + m_LocalPosition: {x: -0.45, y: 0.01, z: -0.15} m_LocalScale: {x: 1, y: 1.0000005, z: 1.0000005} m_Children: [] m_Father: {fileID: 144170969} - m_RootOrder: 2 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!102 &1984785757 TextMesh: @@ -1975,11 +2541,11 @@ Transform: m_PrefabInternal: {fileID: 0} m_GameObject: {fileID: 2036315273} m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068} - m_LocalPosition: {x: 0, y: 0.01, z: -1.65} - m_LocalScale: {x: 1.5, y: 2.812, z: 1} + m_LocalPosition: {x: 0, y: 0.01, z: -1.88} + m_LocalScale: {x: 1.5, y: 2.9385245, z: 1} m_Children: [] m_Father: {fileID: 144170969} - m_RootOrder: 1 + m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0} --- !u!64 &2036315275 MeshCollider: diff --git a/Assets/Scripts/LibPdInstance.cs b/Assets/Scripts/LibPdInstance.cs index 88fad19..7cff263 100644 --- a/Assets/Scripts/LibPdInstance.cs +++ b/Assets/Scripts/LibPdInstance.cs @@ -24,10 +24,42 @@ using System; using UnityEngine; using UnityEditor; +using UnityEngine.Events; using System.Collections.Generic; using System.Runtime.InteropServices; using System.Runtime.CompilerServices; +#region UnityEvent types +//------------------------------------------------------------------------------ +/// Single string parameter event type (used for Bang events). +[System.Serializable] +public class StringEvent : UnityEvent {} + +/// String + float parameter event type (used for Float events). +[System.Serializable] +public class StringFloatEvent : UnityEvent {} + +/// String + string parameter event type (used for Symbol events). +[System.Serializable] +public class StringStringEvent : UnityEvent {} + +/// String + object array parameter event type (used for List events). +[System.Serializable] +public class StringObjArrEvent : UnityEvent {} + +/// String + object array parameter event type (used for Message events). +[System.Serializable] +public class StringStringObjArrEvent : UnityEvent {} + +/// Int + int + int parameter event type (used for various MIDI events). +[System.Serializable] +public class IntIntIntEvent : UnityEvent {} + +/// Int + int parameter event type (used for various MIDI events). +[System.Serializable] +public class IntIntEvent : UnityEvent {} +#endregion + /// /// Unity Component for running a Pure Data patch. Uses libpd's new multiple /// instance support, so you can run multiple LibPdInstances in your scene. @@ -214,10 +246,8 @@ public class LibPdInstance : MonoBehaviour { int n); #endregion - #region delegate/libpd callback declarations + #region libpd delegate/callback declarations //-------------------------------------------------------------------------- - // Delegates/libpd callbacks. - //-Print hook--------------------------------------------------------------- // We don't make the print hook publicly available (for now), so it's just a //single static delegate. @@ -243,11 +273,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdBangHook bangHook; - /// Public delegate for receiving bang events. - public delegate void LibPdBang(string receiver); - /// Bang event; subscribe to this to receive bangs. - public static event LibPdBang Bang = delegate{}; - //-Float hook--------------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdFloatHook([In] [MarshalAs(UnmanagedType.LPStr)] string symbol, @@ -258,11 +283,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdFloatHook floatHook; - /// Public delegate for receiving float events. - public delegate void LibPdFloat(string receiver, float val); - /// Bang event; subscribe to this to receive floats. - public static event LibPdFloat Float = delegate{}; - //-Symbol hook-------------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdSymbolHook([In] [MarshalAs(UnmanagedType.LPStr)] string symbol, @@ -273,11 +293,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdSymbolHook symbolHook; - /// Public delegate for receiving symbol events. - public delegate void LibPdSymbol(string receiver, string val); - /// Bang event; subscribe to this to receive symbols. - public static event LibPdSymbol Symbol = delegate{}; - //-List hook---------------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdListHook([In] [MarshalAs(UnmanagedType.LPStr)] string source, @@ -289,11 +304,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdListHook listHook; - /// Public delegate for receiving lists. - public delegate void LibPdList(string source, object[] args); - /// Bang event; subscribe to this to receive lists. - public static event LibPdList List = delegate{}; - //-Message hook------------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMessageHook([In] [MarshalAs(UnmanagedType.LPStr)] string source, @@ -306,13 +316,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMessageHook messageHook; - /// Public delegate for receiving messages. - public delegate void LibPdMessage(string source, - string symbol, - object[] args); - /// Bang event; subscribe to this to messages. - public static event LibPdMessage Message = delegate{}; - //-MIDI Note On hook-------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiNoteOnHook(int channel, @@ -324,11 +327,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiNoteOnHook noteOnHook; - /// Public delegate for receiving MIDI note on events. - public delegate void LibPdMidiNoteOn(int channel, int pitch, int velocity); - /// Bang event; subscribe to this to receive MIDI note on events. - public static event LibPdMidiNoteOn MidiNoteOn = delegate {}; - //-MIDI Control Change hook------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiControlChangeHook(int channel, @@ -340,13 +338,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiControlChangeHook controlChangeHook; - /// Public delegate for receiving MIDI control change events. - public delegate void LibPdMidiControlChange(int channel, - int controller, - int value); - /// Bang event; subscribe to this to receive MIDI control change events. - public static event LibPdMidiControlChange MidiControlChange = delegate {}; - //-MIDI Program Change hook------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiProgramChangeHook(int channel, int program); @@ -356,11 +347,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiProgramChangeHook programChangeHook; - /// Public delegate for receiving MIDI program change events. - public delegate void LibPdMidiProgramChange(int channel, int program); - /// Bang event; subscribe to this to receive MIDI program change events. - public static event LibPdMidiProgramChange MidiProgramChange = delegate {}; - //-MIDI Pitch Bend hook----------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiPitchBendHook(int channel, int value); @@ -370,11 +356,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiPitchBendHook pitchBendHook; - /// Public delegate for receiving MIDI pitch bend events. - public delegate void LibPdMidiPitchBend(int channel, int value); - /// Bang event; subscribe to this to receive MIDI pitch bend events. - public static event LibPdMidiPitchBend MidiPitchBend = delegate {}; - //-MIDI Aftertouch hook----------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiAftertouchHook(int channel, int value); @@ -384,11 +365,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiAftertouchHook aftertouchHook; - /// Public delegate for receiving MIDI aftertouch events. - public delegate void LibPdMidiAftertouch(int channel, int value); - /// Bang event; subscribe to this to receive MIDI aftertouch events. - public static event LibPdMidiAftertouch MidiAftertouch = delegate {}; - //-MIDI Polyphonic Aftertouch hook------------------------------------------ [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiPolyAftertouchHook(int channel, int pitch, int value); @@ -398,11 +374,6 @@ public class LibPdInstance : MonoBehaviour { private LibPdMidiPolyAftertouchHook polyAftertouchHook; - /// Public delegate for receiving MIDI polyphonic aftertouch events. - public delegate void LibPdMidiPolyAftertouch(int channel, int pitch, int value); - /// Bang event; subscribe to this to receive MIDI polyphonic aftertouch events. - public static event LibPdMidiPolyAftertouch MidiPolyAftertouch = delegate {}; - //-MIDI Byte hook----------------------------------------------------------- [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void LibPdMidiByteHook(int channel, int value); @@ -411,11 +382,6 @@ public class LibPdInstance : MonoBehaviour { private static extern void libpd_set_midibytehook(LibPdMidiByteHook hook); private LibPdMidiByteHook midiByteHook; - - /// Public delegate for receiving MIDI byte events. - public delegate void LibPdMidiByte(int channel, int value); - /// Bang event; subscribe to this to receive MIDI byte events. - public static event LibPdMidiByte MidiByte = delegate {}; #endregion #region member variables @@ -465,6 +431,46 @@ public class LibPdInstance : MonoBehaviour { /// Global variable used to ensure we don't initialise LibPd more than once. private static bool pdInitialised = false; #endregion + + #region events + //-------------------------------------------------------------------------- + /// Events placed in a struct so they don't clutter up the Inspector by default. + [System.Serializable] + public struct PureDataEvents { + /// UnityEvent that will be invoked whenever we recieve a bang from the PD patch. + public StringEvent Bang; + /// UnityEvent that will be invoked whenever we recieve a float from the PD patch. + public StringFloatEvent Float; + /// UnityEvent that will be invoked whenever we recieve a symbol from the PD patch. + public StringStringEvent Symbol; + /// UnityEvent that will be invoked whenever we recieve a list from the PD patch. + public StringObjArrEvent List; + /// UnityEvent that will be invoked whenever we recieve a message from the PD patch. + public StringStringObjArrEvent Message; + }; + [Header("libpd -> Unity Events")] + public PureDataEvents pureDataEvents; + + /// Events placed in a struct so they don't clutter up the Inspector by default. + [System.Serializable] + public struct MidiEvents { + /// UnityEvent that will be invoked whenever we recieve a MIDI note on from the PD patch. + public IntIntIntEvent MidiNoteOn; + /// UnityEvent that will be invoked whenever we recieve a MIDI CC from the PD patch. + public IntIntIntEvent MidiControlChange; + /// UnityEvent that will be invoked whenever we recieve a MIDI program change from the PD patch. + public IntIntEvent MidiProgramChange; + /// UnityEvent that will be invoked whenever we recieve a MIDI pitch bend from the PD patch. + public IntIntEvent MidiPitchBend; + /// UnityEvent that will be invoked whenever we recieve a MIDI aftertouch from the PD patch. + public IntIntEvent MidiAftertouch; + /// UnityEvent that will be invoked whenever we recieve a polyphonic MIDI aftertouch from the PD patch. + public IntIntIntEvent MidiPolyAftertouch; + /// UnityEvent that will be invoked whenever we recieve a MIDI byte from the PD patch. + public IntIntEvent MidiByte; + }; + public MidiEvents midiEvents; + #endregion #region MonoBehaviour methods //-------------------------------------------------------------------------- @@ -530,6 +536,32 @@ public class LibPdInstance : MonoBehaviour { else pipePrintToConsole = pipePrintToConsoleStatic; + if(pureDataEvents.Bang == null) + pureDataEvents.Bang = new StringEvent(); + if(pureDataEvents.Float == null) + pureDataEvents.Float = new StringFloatEvent(); + if(pureDataEvents.Symbol == null) + pureDataEvents.Symbol = new StringStringEvent(); + if(pureDataEvents.List == null) + pureDataEvents.List = new StringObjArrEvent(); + if(pureDataEvents.Message == null) + pureDataEvents.Message = new StringStringObjArrEvent(); + + if(midiEvents.MidiNoteOn == null) + midiEvents.MidiNoteOn = new IntIntIntEvent(); + if(midiEvents.MidiControlChange == null) + midiEvents.MidiControlChange = new IntIntIntEvent(); + if(midiEvents.MidiProgramChange == null) + midiEvents.MidiProgramChange = new IntIntEvent(); + if(midiEvents.MidiPitchBend == null) + midiEvents.MidiPitchBend = new IntIntEvent(); + if(midiEvents.MidiAftertouch == null) + midiEvents.MidiAftertouch = new IntIntEvent(); + if(midiEvents.MidiPolyAftertouch == null) + midiEvents.MidiPolyAftertouch = new IntIntIntEvent(); + if(midiEvents.MidiByte == null) + midiEvents.MidiByte = new IntIntEvent(); + // Calc numTicks. int bufferSize; int noOfBuffers; @@ -906,21 +938,21 @@ public class LibPdInstance : MonoBehaviour { /// Receive bang messages. void BangOutput(string symbol) { - Bang(symbol); + pureDataEvents.Bang.Invoke(symbol); } //-------------------------------------------------------------------------- /// Receive float messages. void FloatOutput(string symbol, float val) { - Float(symbol, val); + pureDataEvents.Float.Invoke(symbol, val); } //-------------------------------------------------------------------------- /// Receive symbol messages. void SymbolOutput(string symbol, string val) { - Symbol(symbol, val); + pureDataEvents.Symbol.Invoke(symbol, val); } //-------------------------------------------------------------------------- @@ -929,7 +961,7 @@ public class LibPdInstance : MonoBehaviour { { var args = ConvertList(argc, argv); - List(source, args); + pureDataEvents.List.Invoke(source, args); } //-------------------------------------------------------------------------- @@ -938,56 +970,56 @@ public class LibPdInstance : MonoBehaviour { { var args = ConvertList(argc, argv); - Message(source, symbol, args); + pureDataEvents.Message.Invoke(source, symbol, args); } //-------------------------------------------------------------------------- /// Receive MIDI note on messages. void MidiNoteOnOutput(int channel, int pitch, int velocity) { - MidiNoteOn(channel, pitch, velocity); + midiEvents.MidiNoteOn.Invoke(channel, pitch, velocity); } //-------------------------------------------------------------------------- /// Receive MIDI control change messages. void MidiControlChangeOutput(int channel, int controller, int value) { - MidiControlChange(channel, controller, value); + midiEvents.MidiControlChange.Invoke(channel, controller, value); } //-------------------------------------------------------------------------- /// Receive MIDI program change messages. void MidiProgramChangeOutput(int channel, int program) { - MidiProgramChange(channel, program); + midiEvents.MidiProgramChange.Invoke(channel, program); } //-------------------------------------------------------------------------- /// Receive MIDI pitch bend messages. void MidiPitchBendOutput(int channel, int value) { - MidiPitchBend(channel, value); + midiEvents.MidiPitchBend.Invoke(channel, value); } //-------------------------------------------------------------------------- /// Receive MIDI aftertouch messages. void MidiAftertouchOutput(int channel, int value) { - MidiAftertouch(channel, value); + midiEvents.MidiAftertouch.Invoke(channel, value); } //-------------------------------------------------------------------------- /// Receive MIDI polyphonic aftertouch messages. void MidiPolyAftertouchOutput(int channel, int pitch, int value) { - MidiPolyAftertouch(channel, pitch, value); + midiEvents.MidiPolyAftertouch.Invoke(channel, pitch, value); } //-------------------------------------------------------------------------- /// Receive MIDI byte messages. void MidiByteOutput(int channel, int value) { - MidiByte(channel, value); + midiEvents.MidiByte.Invoke(channel, value); } #endregion diff --git a/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd new file mode 100644 index 0000000..9e4789d --- /dev/null +++ b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd @@ -0,0 +1,137 @@ +#N canvas -2 28 471 717 10; +#X obj 11 259 cnv 16 54 96 empty empty Spatialise_Output 32 -12 0 16 +-260584 -66577 0; +#X obj 10 21 cnv 16 214 212 empty empty Noise_Generation 4 -12 0 16 +-179694 -66577 0; +#X obj 15 331 dac~; +#X obj 15 25 noise~; +#X obj 33 169 vline~; +#X obj 33 99 random 200; +#X obj 33 122 + 400; +#X msg 33 145 \$1 1000; +#X obj 33 73 metro 1000; +#X obj 15 190 vcf~ 4; +#X msg 106 150 \$1 1000; +#X obj 106 87 random 21; +#X obj 106 127 + 4; +#X obj 106 176 line; +#X obj 33 43 loadbang; +#X obj 33 263 adc~; +#X obj 15 303 *~; +#X obj 39 303 *~; +#X obj 160 130 loadbang; +#X obj 160 153 delay 100; +#X msg 160 176 2 250; +#X obj 160 200 vline~; +#X obj 15 214 *~; +#X text 69 258 <- This section is what; +#X text 88 268 ensures our noise is; +#X text 88 279 spatialised in Unity; +#X text 108 305 Click here for an; +#X text 140 317 explanation:; +#N canvas 464 55 1066 681 explanation 0; +#X text 9 20 AudioSource Components.; +#X text 10 6 By default \, Unity only spatialises; +#X text 6 54 the AudioSource in a GameObject's chain; +#X text 7 66 will not have their output spatialised.; +#X text 8 43 Any sound generating Components following; +#X text 7 107 system by using a special soundfile; +#X text 4 119 (SpatialiserFix.wav) in the AudioSource \,; +#X text 7 131 and feeding the output of the AudioSource; +#X text 5 143 (which Unity has now spatialised for us); +#X text 8 156 into the audio input of our PD patch.; +#X text 8 96 To get around this we need to cheat the; +#X text 7 195 constant dc value of +1 (for this reason; +#X text 7 207 you should NOT attempt to play it through; +#X text 7 221 your speakers). When Unity applies its; +#X text 6 234 default spatialisation to it \, this gives; +#X text 8 246 us a stereo input which effectively; +#X text 7 259 contains the levels of the left & right; +#X text 8 270 channels for our patch.; +#X text 8 183 The SpatialiserFix file contains a; +#X text 6 309 output by these levels then gives us a; +#X text 6 321 correctly spatialised output.; +#X text 7 297 Simply multiplying our patch's stereo; +#N canvas 0 50 450 250 (subpatch) 0; +#X array SpatialiserFix 100 float 5; +#A 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 +1; +#X coords 0 1.2 100 -1.2 100 70 1 0 0; +#X restore 400 35 graph; +#X obj 400 122 hsl 128 16 0 1 0 0 empty PanReceive Pan_Control -2 -8 +0 14 -262144 -1 -1 0 1; +#N canvas 20 81 626 466 spatialisation 0; +#X obj 7 8 inlet; +#X obj 251 14 loadbang; +#X msg 251 31 0; +#X obj 226 60 f; +#X obj 285 59 + 1; +#X obj 75 156 *; +#X obj 15 154 -; +#X msg 3 131 1; +#X obj 31 177 *; +#X obj 225 80 % 100; +#X obj 66 101 tabread SpatialiserFix; +#X msg 82 33 bang; +#X obj 75 186 s RightOutput; +#X obj 31 203 s LeftOutput; +#X connect 0 0 6 1; +#X connect 0 0 11 0; +#X connect 0 0 5 0; +#X connect 1 0 2 0; +#X connect 2 0 3 1; +#X connect 3 0 4 0; +#X connect 3 0 9 0; +#X connect 4 0 3 1; +#X connect 5 0 12 0; +#X connect 6 0 8 0; +#X connect 7 0 6 0; +#X connect 8 0 13 0; +#X connect 9 0 10 0; +#X connect 10 0 8 1; +#X connect 10 0 5 1; +#X connect 10 0 7 0; +#X connect 11 0 3 0; +#X restore 398 151 pd spatialisation; +#X obj 451 186 vsl 32 96 0 1 0 0 empty RightOutput R 10 -9 0 16 -262144 +-1 -1 0 1; +#X obj 399 186 vsl 32 96 0 1 0 0 empty LeftOutput L 12 -9 0 16 -262144 +-1 -1 0 1; +#X text 322 59 AudioSource; +#X text 354 130 Unity; +#X text 293 141 Spatialisation:; +#X text 319 212 AudioSource; +#X text 347 223 Output:; +#X text 290 3 Effectively \, what we are doing is:; +#X text 291 71 Soundfile Input:; +#X text 437 288 |; +#X text 437 296 v; +#X text 376 309 Fed to our patch via; +#X text 391 321 its adc~ object.; +#X connect 23 0 24 0; +#X restore 128 337 pd explanation; +#X connect 3 0 9 0; +#X connect 4 0 9 1; +#X connect 5 0 6 0; +#X connect 6 0 7 0; +#X connect 7 0 4 0; +#X connect 8 0 5 0; +#X connect 8 0 11 0; +#X connect 9 0 22 0; +#X connect 10 0 13 0; +#X connect 11 0 12 0; +#X connect 12 0 10 0; +#X connect 13 0 9 2; +#X connect 14 0 8 0; +#X connect 15 0 16 1; +#X connect 15 1 17 1; +#X connect 16 0 2 0; +#X connect 17 0 2 1; +#X connect 18 0 19 0; +#X connect 19 0 20 0; +#X connect 20 0 21 0; +#X connect 21 0 22 1; +#X connect 22 0 16 0; +#X connect 22 0 17 0; diff --git a/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd.meta b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd.meta new file mode 100644 index 0000000..c2c6d76 --- /dev/null +++ b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise-ADC.pd.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8d059ad70b1caa34abcb319fba07da55 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise.pd b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise.pd index 95e30cb..e971f3e 100644 --- a/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise.pd +++ b/Assets/StreamingAssets/PdAssets/SpatialisationPatches/FilteredNoise.pd @@ -1,137 +1,38 @@ -#N canvas -8 8 471 717 10; -#X obj 11 259 cnv 16 54 96 empty empty Spatialise_Output 32 -12 0 16 --260584 -66577 0; -#X obj 10 21 cnv 16 214 212 empty empty Noise_Generation 4 -12 0 16 --179694 -66577 0; -#X obj 15 331 dac~; -#X obj 15 25 noise~; -#X obj 33 169 vline~; -#X obj 33 99 random 200; -#X obj 33 122 + 400; -#X msg 33 145 \$1 1000; -#X obj 33 73 metro 1000; -#X obj 15 190 vcf~ 4; -#X msg 106 150 \$1 1000; -#X obj 106 87 random 21; -#X obj 106 127 + 4; -#X obj 106 176 line; -#X obj 33 43 loadbang; -#X obj 33 263 adc~; -#X obj 15 303 *~; -#X obj 39 303 *~; -#X obj 160 130 loadbang; -#X obj 160 153 delay 100; -#X msg 160 176 2 250; -#X obj 160 200 vline~; -#X obj 15 214 *~; -#X text 69 258 <- This section is what; -#X text 88 268 ensures our noise is; -#X text 88 279 spatialised in Unity; -#X text 108 305 Click here for an; -#X text 140 317 explanation:; -#N canvas 464 55 1066 681 explanation 0; -#X text 9 20 AudioSource Components.; -#X text 10 6 By default \, Unity only spatialises; -#X text 6 54 the AudioSource in a GameObject's chain; -#X text 7 66 will not have their output spatialised.; -#X text 8 43 Any sound generating Components following; -#X text 7 107 system by using a special soundfile; -#X text 4 119 (SpatialiserFix.wav) in the AudioSource \,; -#X text 7 131 and feeding the output of the AudioSource; -#X text 5 143 (which Unity has now spatialised for us); -#X text 8 156 into the audio input of our PD patch.; -#X text 8 96 To get around this we need to cheat the; -#X text 7 195 constant dc value of +1 (for this reason; -#X text 7 207 you should NOT attempt to play it through; -#X text 7 221 your speakers). When Unity applies its; -#X text 6 234 default spatialisation to it \, this gives; -#X text 8 246 us a stereo input which effectively; -#X text 7 259 contains the levels of the left & right; -#X text 8 270 channels for our patch.; -#X text 8 183 The SpatialiserFix file contains a; -#X text 6 309 output by these levels then gives us a; -#X text 6 321 correctly spatialised output.; -#X text 7 297 Simply multiplying our patch's stereo; -#N canvas 0 50 450 250 (subpatch) 0; -#X array SpatialiserFix 100 float 5; -#A 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 -1; -#X coords 0 1.2 100 -1.2 100 70 1 0 0; -#X restore 400 35 graph; -#X obj 400 122 hsl 128 16 0 1 0 0 empty PanReceive Pan_Control -2 -8 -0 14 -262144 -1 -1 0 1; -#N canvas 20 81 626 466 spatialisation 0; -#X obj 7 8 inlet; -#X obj 251 14 loadbang; -#X msg 251 31 0; -#X obj 226 60 f; -#X obj 285 59 + 1; -#X obj 75 156 *; -#X obj 15 154 -; -#X msg 3 131 1; -#X obj 31 177 *; -#X obj 225 80 % 100; -#X obj 66 101 tabread SpatialiserFix; -#X msg 82 33 bang; -#X obj 75 186 s RightOutput; -#X obj 31 203 s LeftOutput; -#X connect 0 0 6 1; -#X connect 0 0 11 0; -#X connect 0 0 5 0; -#X connect 1 0 2 0; -#X connect 2 0 3 1; -#X connect 3 0 4 0; -#X connect 3 0 9 0; -#X connect 4 0 3 1; -#X connect 5 0 12 0; -#X connect 6 0 8 0; -#X connect 7 0 6 0; -#X connect 8 0 13 0; -#X connect 9 0 10 0; -#X connect 10 0 8 1; -#X connect 10 0 5 1; -#X connect 10 0 7 0; -#X connect 11 0 3 0; -#X restore 398 151 pd spatialisation; -#X obj 451 186 vsl 32 96 0 1 0 0 empty RightOutput R 10 -9 0 16 -262144 --1 -1 0 1; -#X obj 399 186 vsl 32 96 0 1 0 0 empty LeftOutput L 12 -9 0 16 -262144 --1 -1 0 1; -#X text 322 59 AudioSource; -#X text 354 130 Unity; -#X text 293 141 Spatialisation:; -#X text 319 212 AudioSource; -#X text 347 223 Output:; -#X text 290 3 Effectively \, what we are doing is:; -#X text 291 71 Soundfile Input:; -#X text 437 288 |; -#X text 437 296 v; -#X text 376 309 Fed to our patch via; -#X text 391 321 its adc~ object.; -#X connect 23 0 24 0; -#X restore 128 337 pd explanation; -#X connect 3 0 9 0; -#X connect 4 0 9 1; -#X connect 5 0 6 0; -#X connect 6 0 7 0; -#X connect 7 0 4 0; -#X connect 8 0 5 0; -#X connect 8 0 11 0; -#X connect 9 0 22 0; -#X connect 10 0 13 0; +#N canvas 657 74 443 510 10; +#X obj 9 234 dac~; +#X obj 9 6 noise~; +#X obj 27 150 vline~; +#X obj 27 80 random 200; +#X msg 27 126 \$1 1000; +#X obj 27 54 metro 1000; +#X obj 9 171 vcf~ 4; +#X msg 100 131 \$1 1000; +#X obj 100 68 random 21; +#X obj 100 157 line; +#X obj 27 24 loadbang; +#X obj 154 111 loadbang; +#X obj 154 134 delay 100; +#X msg 154 157 2 250; +#X obj 154 181 vline~; +#X obj 9 195 *~; +#X obj 27 103 + 600; +#X obj 100 108 + 9; +#X connect 1 0 6 0; +#X connect 2 0 6 1; +#X connect 3 0 16 0; +#X connect 4 0 2 0; +#X connect 5 0 3 0; +#X connect 5 0 8 0; +#X connect 6 0 15 0; +#X connect 7 0 9 0; +#X connect 8 0 17 0; +#X connect 9 0 6 2; +#X connect 10 0 5 0; #X connect 11 0 12 0; -#X connect 12 0 10 0; -#X connect 13 0 9 2; -#X connect 14 0 8 0; -#X connect 15 0 16 1; -#X connect 15 1 17 1; -#X connect 16 0 2 0; -#X connect 17 0 2 1; -#X connect 18 0 19 0; -#X connect 19 0 20 0; -#X connect 20 0 21 0; -#X connect 21 0 22 1; -#X connect 22 0 16 0; -#X connect 22 0 17 0; +#X connect 12 0 13 0; +#X connect 13 0 14 0; +#X connect 14 0 15 1; +#X connect 15 0 0 0; +#X connect 15 0 0 1; +#X connect 16 0 4 0; +#X connect 17 0 7 0; diff --git a/Assets/Unity - Shortcut.lnk b/Assets/Unity - Shortcut.lnk deleted file mode 100644 index ab5e520..0000000 Binary files a/Assets/Unity - Shortcut.lnk and /dev/null differ diff --git a/ProjectSettings/AudioManager.asset b/ProjectSettings/AudioManager.asset index 4f31e74..4c668a9 100644 --- a/ProjectSettings/AudioManager.asset +++ b/ProjectSettings/AudioManager.asset @@ -11,7 +11,7 @@ AudioManager: m_DSPBufferSize: 1024 m_VirtualVoiceCount: 512 m_RealVoiceCount: 32 - m_SpatializerPlugin: + m_SpatializerPlugin: OculusSpatializer m_AmbisonicDecoderPlugin: m_DisableAudio: 0 m_VirtualizeEffects: 1 diff --git a/ToDo.txt b/ToDo.txt index 4419401..bce1796 100644 --- a/ToDo.txt +++ b/ToDo.txt @@ -1,6 +1,6 @@ LibPd Integration Examples -------------------------- -- Generate documentation from LibPdInstance.cs. +- Add OculusSpatializer example. Further down the line: ----------------------