Commit b2aec8fb authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas

Auralizationmode hinzugefügt

parent 0623142f
......@@ -90,8 +90,8 @@ namespace VA
double ux, double uy, double uz)
{
NativeSetListenerOrientationVU(_NetClient, iSoundSourceID, vx, vy, vz, ux, uy, uz);
int i = 0;
}
public int LoadHRIRDataset(string FilePath, string Name)
{
Console.WriteLine("test");
......
......@@ -82,6 +82,17 @@ public class VAUAdapter : MonoBehaviour {
}
}
void OnEnable()
{
// if (GetComponent<VAUAuralizationMode>() != null)
// VAUAuralizationMode.AuraStringChanged += OnGlobalAuralizationModeChanged;
}
void OnGlobalAuralizationModeChanged(string AuraMode)
{
_VA.SetGlobalAuralizationMode(AuraMode);
}
void OnDisable()
{
VAUSoundSource[] SoundSources = FindObjectsOfType<VAUSoundSource>();
......@@ -98,5 +109,7 @@ public class VAUAdapter : MonoBehaviour {
_VA.DeleteListener(Listener.ID);
}
_VA.Disconnect();
// if (GetComponent<VAUAuralizationMode>() != null)
// VAUAuralizationMode.AuraStringChanged -= OnGlobalAuralizationModeChanged;
}
}
......@@ -3,24 +3,174 @@ using System.Collections;
public class VAUAuralizationMode : MonoBehaviour {
public bool All;
public bool Default;
public bool DirectSound;
public bool EarlyReflections;
public bool DiffuseDecay;
public bool SourceDirectivity;
public bool AirAbsorption;
public bool AtmosphericTemporalVariations;
public bool Scattering;
public bool Diffraction;
public bool NearFielEffects;
public bool DopplerShifts;
public bool SphericalSpreadingLoss;
private string AuraString = "";
public bool DirectSound = true;
public bool EarlyReflections = false;
public bool DiffuseDecay = false;
public bool SourceDirectivity = true;
public bool AirAbsorption = false;
public bool AtmosphericTemporalVariations = false;
public bool Scattering = false;
public bool Diffraction = false;
public bool NearFielEffects = false;
public bool DopplerShifts = true;
public bool SphericalSpreadingLoss = true;
private class AuralizationMode
{
public bool DirectSound = true;
public bool EarlyReflections = true;
public bool DiffuseDecay = true;
public bool SourceDirectivity = true;
public bool AirAbsorption = true;
public bool AtmosphericTemporalVariations = true;
public bool Scattering = true;
public bool Diffraction = true;
public bool NearFielEffects = true;
public bool DopplerShifts = true;
public bool SphericalSpreadingLoss = true;
public static bool operator ==(AuralizationMode left, AuralizationMode right)
{
int iCompare = 0;
iCompare += left.DirectSound != right.DirectSound ? 1 : 0;
iCompare += left.EarlyReflections != right.EarlyReflections ? 1 : 0;
iCompare += left.DiffuseDecay != right.DiffuseDecay ? 1 : 0;
iCompare += left.SourceDirectivity != right.SourceDirectivity ? 1 : 0;
iCompare += left.AirAbsorption != right.AirAbsorption ? 1 : 0;
iCompare += left.AtmosphericTemporalVariations != right.AtmosphericTemporalVariations ? 1 : 0;
iCompare += left.Scattering != right.Scattering ? 1 : 0;
iCompare += left.Diffraction != right.Diffraction ? 1 : 0;
iCompare += left.NearFielEffects != right.NearFielEffects ? 1 : 0;
iCompare += left.DopplerShifts != right.DopplerShifts ? 1 : 0;
iCompare += left.SphericalSpreadingLoss != right.SphericalSpreadingLoss ? 1 : 0;
return ( iCompare == 0 );
}
public static bool operator !=(AuralizationMode left, AuralizationMode right)
{
return !(left == right);
}
}
private AuralizationMode AuraModeShadow = new AuralizationMode();
public delegate void OnAuraStringChangedDelegate(string sAuraString);
public event OnAuraStringChangedDelegate AuraStringChanged;
void Update()
{
AuralizationMode AuraMode = UpdateAuraModeSettings();
if (AuraMode == AuraModeShadow)
return;
string AuraString = "";
if (AuraMode.DirectSound != AuraModeShadow.DirectSound)
{
AuraString = AuraMode.DirectSound ? "+DS" : "-DS";
AuraModeShadow.DirectSound = AuraMode.DirectSound;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.EarlyReflections != AuraModeShadow.EarlyReflections)
{
AuraString = AuraMode.EarlyReflections ? "+ER" : "-ER";
AuraModeShadow.EarlyReflections = AuraMode.EarlyReflections;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.DiffuseDecay != AuraModeShadow.DiffuseDecay)
{
AuraString = AuraMode.DiffuseDecay ? "+DD" : "-DD";
AuraModeShadow.DiffuseDecay = AuraMode.DiffuseDecay;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.SourceDirectivity != AuraModeShadow.SourceDirectivity)
{
AuraString = AuraMode.SourceDirectivity ? "+DIR" : "-DIR";
AuraModeShadow.SourceDirectivity = AuraMode.SourceDirectivity;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.AirAbsorption != AuraModeShadow.AirAbsorption)
{
AuraString = AuraMode.AirAbsorption ? "+AA" : "-AA";
AuraModeShadow.AirAbsorption = AuraMode.AirAbsorption;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.AtmosphericTemporalVariations != AuraModeShadow.AtmosphericTemporalVariations)
{
AuraString = AuraMode.AtmosphericTemporalVariations ? "+TV" : "-TV";
AuraModeShadow.AtmosphericTemporalVariations = AuraMode.AtmosphericTemporalVariations;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.Scattering != AuraModeShadow.Scattering)
{
AuraString = AuraMode.Scattering ? "+SC" : "-SC";
AuraModeShadow.Scattering = AuraMode.Scattering;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.Diffraction != AuraModeShadow.Diffraction)
{
AuraString = AuraMode.Diffraction ? "+DIF" : "-DIF";
AuraModeShadow.Diffraction = AuraMode.Diffraction;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.NearFielEffects != AuraModeShadow.NearFielEffects)
{
AuraString = AuraMode.NearFielEffects ? "+NF" : "-NF";
AuraModeShadow.NearFielEffects = AuraMode.NearFielEffects;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.DopplerShifts != AuraModeShadow.DopplerShifts)
{
AuraString = AuraMode.DopplerShifts ? "+DP" : "-DP";
AuraModeShadow.DopplerShifts = AuraMode.DopplerShifts;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
if (AuraMode.SphericalSpreadingLoss != AuraModeShadow.SphericalSpreadingLoss)
{
AuraString = AuraMode.SphericalSpreadingLoss ? "+SL" : "-SL";
AuraModeShadow.SphericalSpreadingLoss = AuraMode.SphericalSpreadingLoss;
if (AuraStringChanged != null)
AuraStringChanged(AuraString);
}
}
AuralizationMode UpdateAuraModeSettings()
{
AuralizationMode am = new AuralizationMode();
am.DirectSound = DirectSound;
am.EarlyReflections = EarlyReflections;
am.DiffuseDecay = DiffuseDecay;
am.SourceDirectivity = SourceDirectivity;
am.AirAbsorption = AirAbsorption;
am.AtmosphericTemporalVariations = AtmosphericTemporalVariations;
am.Scattering = Scattering;
am.Diffraction = Diffraction;
am.NearFielEffects = NearFielEffects;
am.DopplerShifts = DopplerShifts;
am.SphericalSpreadingLoss = SphericalSpreadingLoss;
return am;
}
}
......@@ -7,7 +7,6 @@ using VA;
public class VAUListener : MonoBehaviour {
public string listenername = "MyListener";
public int auramode = 123;
private int Listener;
private VANet _VA = null;
private Quaternion q;
......@@ -25,9 +24,12 @@ public class VAUListener : MonoBehaviour {
void Start()
{
_VA = VAUAdapter.VA;
Listener = _VA.CreateListener(listenername, auramode, VAUAdapter.DefaultHRIR);
Listener = _VA.CreateListener(listenername, 0, VAUAdapter.DefaultHRIR);
_VA.SetSoundSourceAuralizationMode(Listener, "all");
Debug.Log("Listener " + Listener + " created");
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
if (GetComponent<VAUAuralizationMode>() != null)
GetComponent<VAUAuralizationMode>().AuraStringChanged += OnListenerAuralizationModeChanged;
}
// Update is called once per frame
......@@ -47,4 +49,14 @@ public class VAUListener : MonoBehaviour {
//Vector3 t1_ogl = ( q_ogl * t1 ); // result: 0 0 -1
// Debug.Log(t1_ogl);
}
void OnListenerAuralizationModeChanged(string AuraMode)
{
_VA.SetListenerAuralizationMode(Listener, AuraMode);
}
void OnDisable()
{
if (GetComponent<VAUAuralizationMode>() != null)
GetComponent<VAUAuralizationMode>().AuraStringChanged -= OnListenerAuralizationModeChanged;
}
}
......@@ -6,7 +6,6 @@ using VA;
public class VAUSoundSource : MonoBehaviour {
public int AuralizationMode = 1;
public string directivitypath = "";
private int directivity;
private int Gain = 1;
......@@ -30,7 +29,8 @@ public class VAUSoundSource : MonoBehaviour {
void Start()
{
_VA = VAUAdapter.VA;
SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Gain);
SoundSource = _VA.CreateSoundSource(this.name, 0, Gain);
_VA.SetSoundSourceAuralizationMode(SoundSource, "all");
islooping = GetComponent<AudioSource>().loop;
if (directivitypath == "")
directivity = VAUAdapter.DefaultDirectivity;
......@@ -44,6 +44,10 @@ public class VAUSoundSource : MonoBehaviour {
_VA.SetAudiofileSignalSourcePlaybackAction(SignalSource, 2);
_VA.SetAudiofileSignalSourceIsLooping(SignalSource, islooping);
}
if (GetComponent<VAUAuralizationMode>() != null)
{
GetComponent<VAUAuralizationMode>().AuraStringChanged += OnSoundSourceAuralizationModeChanged;
}
}
// Update is called once per frame
......@@ -65,4 +69,13 @@ public class VAUSoundSource : MonoBehaviour {
//_VA.SetSoundSourceVolume(SoundSource, Volume); <- flaot ändern
}
void OnSoundSourceAuralizationModeChanged(string AuraMode)
{
_VA.SetSoundSourceAuralizationMode(SoundSource, AuraMode);
}
void OnDisable()
{
if (GetComponent<VAUAuralizationMode>() != null)
GetComponent<VAUAuralizationMode>().AuraStringChanged -= OnSoundSourceAuralizationModeChanged;
}
}
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