Updated Unity2Libpd scene to work with OculusSpatializer plugin.
This commit is contained in:
parent
9bec3b1b1f
commit
ff116c45e1
7 changed files with 189 additions and 85 deletions
|
|
@ -1,15 +1,40 @@
|
||||||
SpatialiseScene Notes
|
SpatialiseScene Notes
|
||||||
---------------------
|
---------------------
|
||||||
This scene demonstrates how to spatialise PD patches within Unity. Due to the
|
This scene demonstrates a couple of methods for spatialising Pure Data patches
|
||||||
way Unity spatialises sound, this is a slightly involved process.
|
in Unity.
|
||||||
|
|
||||||
|
|
||||||
|
OculusSpatializer Plugin Method
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
This is the simplest method of spatialising patches in Unity. It requires the
|
||||||
|
following steps:
|
||||||
|
|
||||||
|
For the project:
|
||||||
|
1.) Edit -> Project Settings... -> Audio.
|
||||||
|
2.) Set Spatializer Plugin to OculusSpatializer.
|
||||||
|
|
||||||
|
For each Audio Source in the scene:
|
||||||
|
1.) Toggle 'Spatialize' and 'Spatialize Post Effect' on.
|
||||||
|
|
||||||
|
In testing it, the OculusSpatializer plugin seems to attenuate the sound quite
|
||||||
|
aggressively, so an alternative approach is also included.
|
||||||
|
|
||||||
|
|
||||||
|
Alternative Method
|
||||||
|
------------------
|
||||||
|
|
||||||
|
This method makes use of Unity's default audio spatialisation framework. It is a
|
||||||
|
bit more involved than the OculusSpatializer approach, but doesn't attenuate the
|
||||||
|
sound as aggressively.
|
||||||
|
|
||||||
The first thing to note is that, by default, Unity only spatialises
|
The first thing to note is that, by default, Unity only spatialises
|
||||||
AudioSources. It won't apply spatialisation to any other audio producing
|
AudioSources. It won't apply spatialisation to any other audio producing
|
||||||
Components (like LibPdInstance). In order to get around that limitation, we'll
|
Components (like LibPdInstance). In order to get around that limitation, we'll
|
||||||
need to cheat the system a bit.
|
need to cheat the system a bit.
|
||||||
|
|
||||||
After adding an AudioSource and LibPdInstance to a GameObject in your scene, the
|
After adding an AudioSource and LibPdInstance to a GameObject in your scene,
|
||||||
steps you'll need to take to spatialise your PD patch are:
|
the steps you'll need to take to spatialise your PD patch are:
|
||||||
|
|
||||||
1.) Set the AudioSource's AudioClip to the included SpatialiserFix.wav file.
|
1.) Set the AudioSource's AudioClip to the included SpatialiserFix.wav file.
|
||||||
2.) Set the AudioSource to Play On Awake and Loop.
|
2.) Set the AudioSource to Play On Awake and Loop.
|
||||||
|
|
@ -18,23 +43,5 @@ steps you'll need to take to spatialise your PD patch are:
|
||||||
your patch before feeding it to the dac~ object.
|
your patch before feeding it to the dac~ object.
|
||||||
|
|
||||||
This process will ensure that the spatialisation applied to the AudioSource gets
|
This process will ensure that the spatialisation applied to the AudioSource gets
|
||||||
applied to the output of your patch. See FilteredNoise.pd for more information.
|
applied to the output of your patch. See FilteredNoise-ADC.pd for more
|
||||||
|
information.
|
||||||
|
|
||||||
Conversely, if you don't want to apply any spatialisation to your patch, you
|
|
||||||
don't need to do any of the aforementioned steps.
|
|
||||||
|
|
||||||
|
|
||||||
Alternative Approach
|
|
||||||
--------------------
|
|
||||||
An alternative, less-involved approach is to use Unity's OculusSpatializer
|
|
||||||
plugin. When I tested it, this seemed to apply some odd filtering to the sound,
|
|
||||||
so it's not used in this project, but you may prefer this approach.
|
|
||||||
|
|
||||||
To use the OculusSpatializer plugin, the steps are:
|
|
||||||
|
|
||||||
1.) Edit -> Project Settings... -> Audio.
|
|
||||||
2.) Set Spatializer Plugin to OculusSpatializer.
|
|
||||||
|
|
||||||
This will spatialise all audio for you, without any need for the aforementioned
|
|
||||||
SpatialiserFix file and adc~ object in each patch.
|
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,8 @@ When called, SendBang() and SendFloat() will both send a bang or a float
|
||||||
Steps necessary for sending a bang to a patch:
|
Steps necessary for sending a bang to a patch:
|
||||||
|
|
||||||
1.) In your patch, add a receive object, and give it a name (e.g. receive test).
|
1.) In your patch, add a receive object, and give it a name (e.g. receive test).
|
||||||
2.) In the C# script you will use to trigger the bang, call SendBang() with the
|
2.) In the C# script you will use to trigger the bang, call SendBang() with
|
||||||
name of the receive object as its parameter
|
the name of the receive object as its parameter
|
||||||
(e.g. pdPatch.SendBang("test");).
|
(e.g. pdPatch.SendBang("test");).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -971,6 +971,68 @@ MonoBehaviour:
|
||||||
patchDir: /StreamingAssets/PdAssets/Unity2LibPdPatches/
|
patchDir: /StreamingAssets/PdAssets/Unity2LibPdPatches/
|
||||||
patch: {fileID: 102900000, guid: 7341d6c8b5ae80f4b9c3e55c68de573e, type: 3}
|
patch: {fileID: 102900000, guid: 7341d6c8b5ae80f4b9c3e55c68de573e, type: 3}
|
||||||
pipePrintToConsole: 0
|
pipePrintToConsole: 0
|
||||||
|
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 &1103632481
|
--- !u!82 &1103632481
|
||||||
AudioSource:
|
AudioSource:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -980,14 +1042,14 @@ AudioSource:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
OutputAudioMixerGroup: {fileID: 0}
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
m_audioClip: {fileID: 8300000, guid: 0dcf45c10555ee943b10c474b1d1fee2, type: 3}
|
m_audioClip: {fileID: 0}
|
||||||
m_PlayOnAwake: 1
|
m_PlayOnAwake: 1
|
||||||
m_Volume: 1
|
m_Volume: 1
|
||||||
m_Pitch: 1
|
m_Pitch: 1
|
||||||
Loop: 1
|
Loop: 0
|
||||||
Mute: 0
|
Mute: 0
|
||||||
Spatialize: 0
|
Spatialize: 1
|
||||||
SpatializePostEffects: 0
|
SpatializePostEffects: 1
|
||||||
Priority: 128
|
Priority: 128
|
||||||
DopplerLevel: 1
|
DopplerLevel: 1
|
||||||
MinDistance: 1
|
MinDistance: 1
|
||||||
|
|
@ -1354,6 +1416,68 @@ MonoBehaviour:
|
||||||
patchDir: /StreamingAssets/PdAssets/Unity2LibPdPatches/
|
patchDir: /StreamingAssets/PdAssets/Unity2LibPdPatches/
|
||||||
patch: {fileID: 102900000, guid: 131d5aebbccdcfb4cb9e49d9daf8227c, type: 3}
|
patch: {fileID: 102900000, guid: 131d5aebbccdcfb4cb9e49d9daf8227c, type: 3}
|
||||||
pipePrintToConsole: 0
|
pipePrintToConsole: 0
|
||||||
|
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 &1212949217
|
--- !u!82 &1212949217
|
||||||
AudioSource:
|
AudioSource:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
@ -1363,14 +1487,14 @@ AudioSource:
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
serializedVersion: 4
|
serializedVersion: 4
|
||||||
OutputAudioMixerGroup: {fileID: 0}
|
OutputAudioMixerGroup: {fileID: 0}
|
||||||
m_audioClip: {fileID: 8300000, guid: 0dcf45c10555ee943b10c474b1d1fee2, type: 3}
|
m_audioClip: {fileID: 0}
|
||||||
m_PlayOnAwake: 1
|
m_PlayOnAwake: 1
|
||||||
m_Volume: 1
|
m_Volume: 1
|
||||||
m_Pitch: 1
|
m_Pitch: 1
|
||||||
Loop: 1
|
Loop: 0
|
||||||
Mute: 0
|
Mute: 0
|
||||||
Spatialize: 0
|
Spatialize: 1
|
||||||
SpatializePostEffects: 0
|
SpatializePostEffects: 1
|
||||||
Priority: 128
|
Priority: 128
|
||||||
DopplerLevel: 1
|
DopplerLevel: 1
|
||||||
MinDistance: 1
|
MinDistance: 1
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,7 @@
|
||||||
#N canvas 481 50 704 553 10;
|
#N canvas 481 50 704 424 10;
|
||||||
#X obj 35 195 adc~;
|
|
||||||
#X obj 6 190 cnv 16 60 80 empty empty Spatialise_Output 40 -12 0 16
|
|
||||||
-260584 -66577 0;
|
|
||||||
#X obj 6 107 cnv 16 162 60 empty empty Amplitude_Envelope 24 -12 0
|
#X obj 6 107 cnv 16 162 60 empty empty Amplitude_Envelope 24 -12 0
|
||||||
16 -179694 -66577 0;
|
16 -179694 -66577 0;
|
||||||
#X obj 14 253 dac~;
|
#X obj 14 187 dac~;
|
||||||
#X obj 32 194 adc~;
|
|
||||||
#X obj 14 230 *~;
|
|
||||||
#X obj 39 230 *~;
|
|
||||||
#X obj 14 18 osc~ 440;
|
#X obj 14 18 osc~ 440;
|
||||||
#X obj 14 148 *~;
|
#X obj 14 148 *~;
|
||||||
#X obj 84 134 vline~;
|
#X obj 84 134 vline~;
|
||||||
|
|
@ -15,10 +9,6 @@
|
||||||
#X msg 131 119 0 10;
|
#X msg 131 119 0 10;
|
||||||
#X obj 131 65 receive VolumeDown;
|
#X obj 131 65 receive VolumeDown;
|
||||||
#X obj 84 46 receive VolumeUp;
|
#X obj 84 46 receive VolumeUp;
|
||||||
#X text 70 206 See FilteredNoise.pd in;
|
|
||||||
#X text 70 217 the Spatialisation scene;
|
|
||||||
#X text 71 228 for an explanation of;
|
|
||||||
#X text 70 238 this structure.;
|
|
||||||
#X text 5 1 Sine Oscillator;
|
#X text 5 1 Sine Oscillator;
|
||||||
#X text 83 27 These receive objects are how we receive;
|
#X text 83 27 These receive objects are how we receive;
|
||||||
#X text 200 39 signals from our Unity;
|
#X text 200 39 signals from our Unity;
|
||||||
|
|
@ -28,15 +18,11 @@
|
||||||
#X text 193 84 VolumeDown will trigger;
|
#X text 193 84 VolumeDown will trigger;
|
||||||
#X text 258 95 a ramp of the;
|
#X text 258 95 a ramp of the;
|
||||||
#X text 194 106 oscillator's amplitude.;
|
#X text 194 106 oscillator's amplitude.;
|
||||||
#X connect 4 0 5 1;
|
#X connect 2 0 3 0;
|
||||||
#X connect 4 1 6 1;
|
#X connect 3 0 1 0;
|
||||||
#X connect 5 0 3 0;
|
#X connect 3 0 1 1;
|
||||||
#X connect 6 0 3 1;
|
#X connect 4 0 3 1;
|
||||||
#X connect 7 0 8 0;
|
#X connect 5 0 4 0;
|
||||||
|
#X connect 6 0 4 0;
|
||||||
|
#X connect 7 0 6 0;
|
||||||
#X connect 8 0 5 0;
|
#X connect 8 0 5 0;
|
||||||
#X connect 8 0 6 0;
|
|
||||||
#X connect 9 0 8 1;
|
|
||||||
#X connect 10 0 9 0;
|
|
||||||
#X connect 11 0 9 0;
|
|
||||||
#X connect 12 0 11 0;
|
|
||||||
#X connect 13 0 10 0;
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
#N canvas 365 101 635 495 10;
|
#N canvas 365 101 635 374 10;
|
||||||
#X obj 68 152 cnv 16 54 80 empty empty Spatialisation_Output 32 -12
|
#X obj 73 164 dac~;
|
||||||
0 16 -260584 -66577 0;
|
|
||||||
#X obj 73 214 dac~;
|
|
||||||
#X obj 91 155 adc~;
|
|
||||||
#X obj 73 191 *~;
|
|
||||||
#X obj 98 190 *~;
|
|
||||||
#X obj 7 111 osc~;
|
#X obj 7 111 osc~;
|
||||||
#X obj 73 125 *~;
|
#X obj 73 125 *~;
|
||||||
#X obj 91 57 vline~;
|
#X obj 91 57 vline~;
|
||||||
|
|
@ -20,21 +15,13 @@
|
||||||
#X text 137 66 applies to both the;
|
#X text 137 66 applies to both the;
|
||||||
#X text 136 77 oscillator's frequency \,;
|
#X text 136 77 oscillator's frequency \,;
|
||||||
#X text 136 88 and its amplitude.;
|
#X text 136 88 and its amplitude.;
|
||||||
#X text 125 166 See FilteredNoise.pd in;
|
#X connect 1 0 2 0;
|
||||||
#X text 124 175 the Spatialisation scene;
|
#X connect 2 0 0 0;
|
||||||
#X text 125 185 for an explanation of;
|
#X connect 2 0 0 1;
|
||||||
#X text 124 195 this structure.;
|
#X connect 3 0 5 0;
|
||||||
#X connect 2 0 3 1;
|
#X connect 3 0 6 0;
|
||||||
#X connect 2 1 4 1;
|
#X connect 4 0 1 0;
|
||||||
#X connect 3 0 1 0;
|
#X connect 5 0 2 1;
|
||||||
#X connect 4 0 1 1;
|
|
||||||
#X connect 5 0 6 0;
|
|
||||||
#X connect 6 0 3 0;
|
|
||||||
#X connect 6 0 4 0;
|
#X connect 6 0 4 0;
|
||||||
#X connect 7 0 9 0;
|
#X connect 7 0 3 0;
|
||||||
#X connect 7 0 10 0;
|
#X connect 8 0 7 0;
|
||||||
#X connect 8 0 5 0;
|
|
||||||
#X connect 9 0 6 1;
|
|
||||||
#X connect 10 0 8 0;
|
|
||||||
#X connect 11 0 7 0;
|
|
||||||
#X connect 12 0 11 0;
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 134 KiB After Width: | Height: | Size: 168 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 179 KiB After Width: | Height: | Size: 250 KiB |
Loading…
Reference in a new issue