Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

unity spatializer user params (script)

Discussion in 'Documentation' started by scottcolburn, Sep 27, 2018.

  1. scottcolburn

    scottcolburn

    Joined:
    Sep 18, 2018
    Posts:
    1
    I'm trying to find documentation on what the parameters are controled in this script. It comes with the Native Audio SDK demo where you choose the spatialization via "demo spatializer". In the demo, there is a scene called Spatilization and this script is on all the audio sources, but i can't find any documentation explaining what the script does.

    See attached file of the script attached to the audio source in the demo

    Here's the script

    // The spatialization API is only supported by the final Unity 5.2 version and newer.
    // If you get script compile errors in this file, comment out the line below.
    #define ENABLE_SPATIALIZER_API
    using UnityEngine;
    using System.Collections;
    public class SpatializerUserParams : MonoBehaviour
    {
    #if ENABLE_SPATIALIZER_API
    public bool EnableSpatialization = true;
    public float DistanceAttn = 1.0f;
    public float FixedVolume = 0.0f;
    public float CustomRolloff = 0.0f;
    #endif
    void Start()
    {
    }
    void Update()
    {
    var source = GetComponent<AudioSource>();
    #if ENABLE_SPATIALIZER_API
    source.SetSpatializerFloat(0, DistanceAttn);
    source.SetSpatializerFloat(1, FixedVolume);
    source.SetSpatializerFloat(2, CustomRolloff);
    source.GetSpatializerFloat(0, out DistanceAttn); // Get back clipped parameters from plugin
    source.GetSpatializerFloat(1, out FixedVolume);
    source.GetSpatializerFloat(2, out CustomRolloff);
    source.spatialize = EnableSpatialization;
    #endif
    }
    }
     

    Attached Files: