Updating VAUListener HRIR management

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