Updating VAUListener HRIR management

parent dd7f874f
...@@ -6,11 +6,15 @@ using VA; ...@@ -6,11 +6,15 @@ using VA;
public class VAUListener : MonoBehaviour { public class VAUListener : MonoBehaviour {
public string listenername = "Listener"; public string Name = "Listener";
public int maxreverbZones = 2;
public int NumMaxReverbZones = 2;
public string VAAudioRenderer = "MyBinauralArtificialReverb"; public string VAAudioRenderer = "MyBinauralArtificialReverb";
private int Listener; public VAUHRIRDataset HRIR = null;
private int _ID;
private VANet _VA = null; private VANet _VA = null;
private Quaternion q; private Quaternion q;
private Transform t; private Transform t;
private AudioReverbZone[] reverbZones; private AudioReverbZone[] reverbZones;
...@@ -23,19 +27,22 @@ public class VAUListener : MonoBehaviour { ...@@ -23,19 +27,22 @@ public class VAUListener : MonoBehaviour {
{ {
get get
{ {
return Listener; return _ID;
} }
} }
// Use this for initialization
void Start() void Start()
{ {
_VA = VAUAdapter.VA; _VA = VAUAdapter.VA;
Listener = _VA.CreateListener(listenername); _ID = _VA.CreateListener(Name);
listenername += " " + Listener; _VA.SetListenerAuralizationMode(_ID, "all");
_VA.SetListenerAuralizationMode(Listener, "all"); if (HRIR)
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIRID); _VA.SetListenerHRIRDataset(_ID, HRIR.ID);
else if( VAUAdapter.DefaultHRIRID != -1 )
_VA.SetListenerHRIRDataset(_ID, VAUAdapter.DefaultHRIRID);
SetListenerPositionOrientation(); SetListenerPositionOrientation();
_VA.SetArtificalReverbarationTime(VAAudioRenderer, 0.3f); _VA.SetArtificalReverbarationTime(VAAudioRenderer, 0.3f);
reverbZones = FindObjectsOfType(typeof(AudioReverbZone)) as AudioReverbZone[]; reverbZones = FindObjectsOfType(typeof(AudioReverbZone)) as AudioReverbZone[];
} }
...@@ -45,9 +52,8 @@ public class VAUListener : MonoBehaviour { ...@@ -45,9 +52,8 @@ public class VAUListener : MonoBehaviour {
if (GetComponent<VAUAuralizationMode>() != null) if (GetComponent<VAUAuralizationMode>() != null)
GetComponent<VAUAuralizationMode>().AuraStringChanged += OnListenerAuralizationModeChanged; GetComponent<VAUAuralizationMode>().AuraStringChanged += OnListenerAuralizationModeChanged;
} }
// Update is called once per frame void Update ()
void Update ()
{ {
SetListenerPositionOrientation(); SetListenerPositionOrientation();
SetActiveReverbZones(); SetActiveReverbZones();
...@@ -63,8 +69,8 @@ public class VAUListener : MonoBehaviour { ...@@ -63,8 +69,8 @@ public class VAUListener : MonoBehaviour {
Vector3 view = q * Vector3.forward; Vector3 view = q * Vector3.forward;
Vector3 view_ogl = new Vector3(view.x, view.y, -view.z); Vector3 view_ogl = new Vector3(view.x, view.y, -view.z);
Vector3 up_ogl = new Vector3(up.x, up.y, -up.z); Vector3 up_ogl = new Vector3(up.x, up.y, -up.z);
_VA.SetListenerPosition(Listener, t.transform.position.x, t.transform.position.y, -t.transform.position.z); _VA.SetListenerPosition(_ID, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetListenerOrientationVU(Listener, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z); _VA.SetListenerOrientationVU(_ID, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
} }
void SetActiveReverbZones() void SetActiveReverbZones()
...@@ -76,7 +82,7 @@ public class VAUListener : MonoBehaviour { ...@@ -76,7 +82,7 @@ public class VAUListener : MonoBehaviour {
int i = 0; int i = 0;
foreach (AudioReverbZone reverbZone in reverbZones) foreach (AudioReverbZone reverbZone in reverbZones)
{ {
if (i >= maxreverbZones) if (i >= NumMaxReverbZones)
break; break;
float actDistance = Vector3.Distance(reverbZone.transform.position, gameObject.transform.position); float actDistance = Vector3.Distance(reverbZone.transform.position, gameObject.transform.position);
if ((actDistance < reverbZone.maxDistance)) if ((actDistance < reverbZone.maxDistance))
...@@ -115,7 +121,7 @@ public class VAUListener : MonoBehaviour { ...@@ -115,7 +121,7 @@ public class VAUListener : MonoBehaviour {
void OnListenerAuralizationModeChanged(string AuraMode) void OnListenerAuralizationModeChanged(string AuraMode)
{ {
_VA.SetListenerAuralizationMode(Listener, AuraMode); _VA.SetListenerAuralizationMode(_ID, AuraMode);
} }
void OnDisable() void OnDisable()
...@@ -126,6 +132,6 @@ public class VAUListener : MonoBehaviour { ...@@ -126,6 +132,6 @@ public class VAUListener : MonoBehaviour {
void OnDestroy() void OnDestroy()
{ {
_VA.DeleteListener(Listener); _VA.DeleteListener(_ID);
} }
} }
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