Skip to content
Snippets Groups Projects
Commit 79ce0e30 authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas
Browse files

Adding artificial reverb support (tests)

parent 805f2a12
Branches
Tags
No related merge requests found
......@@ -7,11 +7,16 @@ using VA;
public class VAUListener : MonoBehaviour {
public string listenername = "Listener";
public int maxreverbZones = 2;
public string VAAudioRenderer = "MyBinauralArtificialReverb";
private int Listener;
private VANet _VA = null;
private Quaternion q;
private Transform t;
private AudioReverbZone[] reverbZones;
private AudioReverbZone[] shadowReverbZones;
private double currentArtificialReverberationTime = 1;
public int ID
{
get
......@@ -30,16 +35,22 @@ public class VAUListener : MonoBehaviour {
Debug.Log(listenername + " created");
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
SetListenerPositionOrientation();
_VA.SetArtificalReverbarationTime(VAAudioRenderer, 2);
}
void OnEnable()
{
if (GetComponent<VAUAuralizationMode>() != null)
GetComponent<VAUAuralizationMode>().AuraStringChanged += OnListenerAuralizationModeChanged;
}
// Update is called once per frame
void Update ()
{
SetListenerPositionOrientation();
SetActiveReverbZones();
}
//uses the View- and Up-Vector to transmit the position of the listener to VA
void SetListenerPositionOrientation()
{
......@@ -53,6 +64,46 @@ public class VAUListener : MonoBehaviour {
_VA.SetListenerOrientationVU(Listener, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
}
void SetActiveReverbZones()
{
double actReverbTime = currentArtificialReverberationTime;
reverbZones = FindObjectsOfType(typeof(AudioReverbZone)) as AudioReverbZone[];
if (reverbZones == shadowReverbZones)
return;
if (reverbZones == null)
{
if (actReverbTime != currentArtificialReverberationTime)
_VA.SetArtificalReverbarationTime(VAAudioRenderer, actReverbTime);
return;
}
shadowReverbZones = reverbZones;
int i = 0;
foreach (AudioReverbZone reverbZone in reverbZones)
{
float actdistance = Vector3.Distance(reverbZone.transform.position, gameObject.transform.position);
if (actdistance < reverbZone.maxDistance)
{
if (i <= maxreverbZones)
{
actReverbTime += reverbZone.decayTime;
i++;
}
if (actdistance > reverbZone.minDistance)
{
}
}
}
if ( i > 0)
actReverbTime /= i;
if( actReverbTime != currentArtificialReverberationTime)
_VA.SetArtificalReverbarationTime(VAAudioRenderer, actReverbTime);
}
void OnListenerAuralizationModeChanged(string AuraMode)
{
_VA.SetListenerAuralizationMode(Listener, AuraMode);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment