WIP

parent 5e3237d5
......@@ -15,12 +15,10 @@ public class VAUAdapter : MonoBehaviour
public static int Port = 12340;
public static string AdditionalSearchPath = ""; // Provide further paths where VA should look for audio files, directivities and HRIRs.
public static bool ResetOnAwake = true;
public static bool DeactivateUnitySoundOnAwake = true;
public static bool ResetOnStart = true;
public static bool ResetOnStop = true;
public static bool DeactivateUnitySoundOnAwake = true;
public static string DefaultHRIRPath = "$(DefaultHRIR)";
private static int _DefaultHRIRID = -1;
private static VANet _VA = null;
// No public construction allowed
......@@ -41,47 +39,29 @@ public class VAUAdapter : MonoBehaviour
private static void Init()
{
if (!_VA.Connect(Server, Port))
if (!VA.Connect(Server, Port))
{
Debug.LogError("Could not connect to VA server on " + Server + " using port " + Port);
return;
}
if( ResetOnStart )
VA.Reset ();
// Add Asset folder as search path for VA (only works if VA is running on same host PC)
if (!_VA.AddSearchPath(Application.dataPath))
if (!VA.AddSearchPath(Application.dataPath))
Debug.LogError("Could not add application assets folder to VA search path, VA server running on remote host?");
if (AdditionalSearchPath.Length > 0)
{
_VA.AddSearchPath(AdditionalSearchPath);
VA.AddSearchPath(AdditionalSearchPath);
// ... append more if required.
}
if (ResetOnAwake)
_VA.Reset();
if (DefaultHRIRPath.Length > 0)
_DefaultHRIRID = _VA.CreateDirectivityFromFile(DefaultHRIRPath);
}
public static int DefaultHRIRID
{
get
{
return _DefaultHRIRID;
}
}
// Use this for initialization
void OnEnable()
{
if (_VA == null)
_VA = new VANet();
Init();
if (DeactivateUnitySoundOnAwake)
DeactivateUnitySound();
......@@ -91,12 +71,14 @@ public class VAUAdapter : MonoBehaviour
void OnGlobalAuralizationModeChanged(string AuraMode)
{
_VA.SetGlobalAuralizationMode(AuraMode);
VA.SetGlobalAuralizationMode(AuraMode);
}
void OnDestroy()
{
_VA.Disconnect();
{
if( ResetOnStop )
VA.Reset ();
VA.Disconnect();
}
void DeactivateUnitySound()
......@@ -106,6 +88,7 @@ public class VAUAdapter : MonoBehaviour
{
audioSource.enabled = false;
}
AudioListener[] audioListeners = FindObjectsOfType(typeof(AudioListener)) as AudioListener[];
foreach (AudioListener audioListener in audioListeners)
{
......
......@@ -6,18 +6,16 @@ public class VAUConfig : MonoBehaviour {
public string Server = VAUAdapter.Server;
public int Port = VAUAdapter.Port;
public string DefaultHRIR = "$(DefaultHRIR)";
public string DemoSound = "$(DemoSound)";
public string AdditionalSearchPath = "";
public bool ResetOnStart = true;
public bool ResetOnStop = true;
// Use this for initialization
void Awake () {
void Awake()
{
VAUAdapter.Server = Server;
VAUAdapter.Port = Port;
}
// Update is called once per frame
void Update () {
VAUAdapter.ResetOnStart = ResetOnStart;
VAUAdapter.ResetOnStop = ResetOnStop;
}
}
......@@ -2,12 +2,15 @@
using System.Collections.Generic;
using UnityEngine;
public class VAUDirectivity : MonoBehaviour {
protected int _ID = -1; // Stores the internal id that is assigned by VA
public class VAUDirectivity : MonoBehaviour
{
[Tooltip("Absolute or relative path (relative to Assets folder), also use AddSearchPath for special folders.")]
public string FilePath = "";
public string Name = ""; // Versatile name for this directivity
protected string FilePath = "";
[Tooltip("Versatile name for this directivity")]
protected string Name = "";
protected int _ID = -1; // Stores the internal id that is assigned by VA
public int ID
{
......@@ -17,7 +20,7 @@ public class VAUDirectivity : MonoBehaviour {
}
}
void Start ()
void OnEnable()
{
if (FilePath.Length > 0)
_ID = VAUAdapter.VA.CreateDirectivityFromFile(FilePath);
......
......@@ -36,8 +36,6 @@ public class VAUListener : VAUSoundReceiver {
VAUAdapter.VA.SetSoundReceiverAuralizationMode(_ID, "all");
if (Directivity)
VAUAdapter.VA.SetSoundReceiverDirectivity(_ID, Directivity.ID);
else if( VAUAdapter.DefaultHRIRID != -1 )
VAUAdapter.VA.SetSoundReceiverDirectivity(_ID, VAUAdapter.DefaultHRIRID);
VAUAdapter.VA.SetSoundReceiverAnthropometricData(_ID, HeadWidth, HeadHeight, HeadDepth);
ShadowHeadWidth = HeadWidth;
......
......@@ -35,8 +35,6 @@ public class VAUSoundReceiver : MonoBehaviour {
VAUAdapter.VA.SetSoundReceiverAuralizationMode(_ID, "all");
if (Directivity)
VAUAdapter.VA.SetSoundReceiverDirectivity(_ID, Directivity.ID);
else if( VAUAdapter.DefaultHRIRID != -1 )
VAUAdapter.VA.SetSoundReceiverDirectivity(_ID, VAUAdapter.DefaultHRIRID);
SetSoundReceiverPositionOrientation();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment