Skip to content

spatialisation

Niall Moody edited this page Dec 3, 2020 · 4 revisions

Spatialisation

Summary

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.

Working with Unity's default spatialisation

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:

  1. Set the Audio Source's AudioClip to our SpatialiserFix.wav sound file.

Audio Source AudioClip set to SpatialiserFix.wav

  1. Ensure the Audio Source is set to Play On Awake and Loop.

Audio Source Play On Awake and Loop set to true

  1. Set Spatial Blend to 1(3D).

Audio Source Spatial Blend slider set to 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:

Pure Data adc~ object output

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.

Working with spatializer plugins

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.

  1. Edit -> Project Settings... -> Audio.
  2. Set Spatializer Plugin to Steam Audio Spatializer (or, whatever plugin you're using).

Unity Audio Settings: Spatializer Plugin

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:

Audio Source Spatial Blend slider set to 3D

Audio Source Spatialize toggles

Other Spatializer Plugins: