-
Notifications
You must be signed in to change notification settings - Fork 17
spatialisation
By default, Unity will not apply spatialisation to Pure Data patches running via LibPdInstance, only to soundfiles played via Unity's AudioSource Component. There are a few different solutions to this, each with their own advantages and drawbacks.
Applying Unity's built-in spatialisation to our PD patches is unfortunately a little convoluted. For this method we need to use a special sound file (included in this repository) in our Audio Source, and use an adc~
object in our PD patch to apply the Audio Source spatialisation to the output of our PD patch.
The necessary steps are:
In Unity:
- Set the Audio Source's AudioClip to our SpatialiserFix.wav sound file.
- Ensure the Audio Source is set to Play On Awake and Loop.
- Set Spatial Blend to 1(3D).
In Pure Data:
Multiply the output of your patch with the stereo input from an adc~
object, like the section highlighted in blue here:
This will effectively apply the spatialisation that Unity applies to Audio Sources by default, to the output of our PD patch. For more information, see the LibPdIntegrationExamples project, and particularly the comments in the FilteredNoise-ADC.pd patch.
Alternatively you can work with a custom spatialisation framework, using a Spatializer Plugin. Spatializer Plugins make implementation a bit simpler, but they do require you to import a spatialisation framework into your project. The following example uses Steam Audio, but the steps are identical regardless of which framework you use.
It should be noted that Spatializer Plugins are almost always intended for VR (i.e. headphone) use. So this approach may not make sense if you're building a project intended for speaker output.
- Edit -> Project Settings... -> Audio.
- Set Spatializer Plugin to Steam Audio Spatializer (or, whatever plugin you're using).
Then, for each Audio Source in your scene, set the Spatial Blend slider to 1(3D) and toggle the Spatialize and Spatialize Post Effects options:
Other Spatializer Plugins: