Aufgrund einer Wartung wird GitLab am 26.10. zwischen 8:00 und 9:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 26.10. between 8:00 and 9:00 am.

Commit 0623142f authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas
Browse files

Skript Oberfäche um AuralizationModes einfach an und auszustellen

Destroy funktion angepasst funktioniert aber noch nicht richtig
parent cdef7bdc
......@@ -90,6 +90,7 @@ 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)
{
......@@ -98,9 +99,9 @@ namespace VA
{
return NativeLoadHRIRDataset(_NetClient, FilePath, Name);
}
catch(Exception e)
catch
{
e.ToString();
Console.WriteLine("ErrorError");
}
return -1;
}
......@@ -218,6 +219,33 @@ namespace VA
{
NativeSetSoundSourceDirectivity(_NetClient, iSoundSourceID, iDirectivityID);
}
public void SetSoundSourcePositionOrientationVU(int iSoundSourceID,
double px, double py, double pz,
double vx, double vy, double vz,
double ux, double uy, double uz)
{
NativeSetSoundSourcePositionOrientationVU(_NetClient, iSoundSourceID,
px, py, pz,
vx, vy, vz,
ux, uy, uz);
}
public void SetGlobalAuralizationMode(string sAuralizationMode)
{
NativeSetGlobalAuralizationMode(_NetClient, sAuralizationMode);
}
public void SetListenerAuralizationMode(int iListenerID, string sAuralizationMode)
{
NativeSetListenerAuralizationMode(_NetClient, iListenerID, sAuralizationMode);
}
public void SetSoundSourceAuralizationMode(int iSoundSourceID, string sAuralizationMode)
{
NativeSetSoundSourceAuralizationMode(_NetClient, iSoundSourceID, sAuralizationMode);
}
/*
* Native imported functions from C++ unmanaged library declared private, so they can not be accessed
* directly through C# class method
......@@ -279,7 +307,7 @@ namespace VA
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeGetSoundSourceSignalSource( IntPtr pClient, int iSoundSourceID );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetSoundSourceSignalSource( IntPtr pClient, int iSoundSourceID, string sSignalSourceID );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetSoundSourceAuralizationMode( IntPtr pClient, int iSoundSourceID );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetSoundSourceAuralizationMode( IntPtr pClient, int iSoundSourceID, int iAuralizationMode );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetSoundSourceAuralizationMode( IntPtr pClient, int iSoundSourceID, string iAuralizationMode );
//[ DllImport( "VANetCSWrapper" ) ] private static extern void GetSoundSourceParameters( IntPtr pClient, int iID, CVAStruct oArgs );
//[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetSoundSourceParameters( IntPtr pClient, int iID, CVAStruct oParams, CVAStruct& oResult );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetSoundSourceDirectivity( IntPtr pClient, int iSoundSourceID );
......@@ -340,7 +368,7 @@ namespace VA
[ DllImport( "VANetCSWrapper" ) ] private static extern void GetListenerName( IntPtr pClient, int iListenerID, char cName );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetListenerName( IntPtr pClient, int iListenerID, string sName );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetListenerAuralizationMode( IntPtr pClient, int iListenerID );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetListenerAuralizationMode( IntPtr pClient, int iListenerID, int iAuralizationMode );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetListenerAuralizationMode( IntPtr pClient, int iListenerID, string sAuralizationMode );
//[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeGetListenerParameters( IntPtr pClient, int iID, const CVAStruct& oArgs, CVAStruct& oResult );
//[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetListenerParameters( IntPtr pClient, int iID, const CVAStruct& oParams );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetListenerHRIRDataset( IntPtr pClient, int iListenerID );
......@@ -417,7 +445,7 @@ namespace VA
[ DllImport( "VANetCSWrapper" ) ] private static extern bool NativeIsOutputMuted( IntPtr pClient );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetOutputMuted( IntPtr pClient, bool bMuted );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetGlobalAuralizationMode( IntPtr pClient );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetGlobalAuralizationMode( IntPtr pClient, int iAuralizationMode );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetGlobalAuralizationMode( IntPtr pClient, string sAuralizationMode );
[ DllImport( "VANetCSWrapper" ) ] private static extern int NativeGetActiveListener( IntPtr pClient );
[ DllImport( "VANetCSWrapper" ) ] private static extern void NativeSetActiveListener( IntPtr pClient, int iListenerID );
[ DllImport( "VANetCSWrapper" ) ] private static extern double NativeGetCoreClock( IntPtr pClient );
......
......@@ -11,9 +11,10 @@ public class VAUAdapter : MonoBehaviour {
private static string HostIP = "localhost";
public static string GlobalAuralizationMode = "all";
private static int Port = 12340;
private static string DefaultHRIRPath = "$(DefaultHRIR)";
private static string DefaultDirectivityPath = "$(HumanDir)";
private static string DefaultDirectivityPath = "$(Trumpet)";
private static int defaulthrir;
private static int defaultdirectivity;
private static VANet _VA = null;
......@@ -43,7 +44,8 @@ public class VAUAdapter : MonoBehaviour {
_VA.Connect(HostIP, Port);
_VA.Reset();
defaulthrir = _VA.LoadHRIRDataset(DefaultHRIRPath, "DefaultHRIR");
//defaultdirectivity = _VA.LoadDirectivity(DefaultDirectivityPath, "DefaultDirectivity");
defaultdirectivity = _VA.LoadDirectivity(DefaultDirectivityPath, "DefaultDirectivity");
_VA.SetGlobalAuralizationMode(GlobalAuralizationMode);
}
catch(ExternalException e)
{
......@@ -79,17 +81,22 @@ public class VAUAdapter : MonoBehaviour {
Init();
}
}
// Update is called once per frame
void Update ()
void OnDisable()
{
}
void OnDestroy()
{
Debug.Log("Disconnected from Server.");
VAUSoundSource[] SoundSources = FindObjectsOfType<VAUSoundSource>();
foreach (VAUSoundSource SoundSource in SoundSources)
{
Debug.Log("SoundSouce " + SoundSource.ID + " deleted.");
_VA.DeleteSoundSource(SoundSource.ID);
}
VAUListener[] Listeners = FindObjectsOfType<VAUListener>();
foreach (VAUListener Listener in Listeners)
{
Debug.Log("Listener " + Listener.ID + " deleted.");
_VA.DeleteListener(Listener.ID);
}
_VA.Disconnect();
}
}
using UnityEngine;
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 = "";
void Update()
{
}
}
......@@ -10,15 +10,23 @@ public class VAUListener : MonoBehaviour {
public int auramode = 123;
private int Listener;
private VANet _VA = null;
private Vector3 viewvec = new Vector3(0, 0, 1);
private Vector3 upvec = new Vector3(0, 1, 0);
private Quaternion q;
private Transform t;
public int ID
{
get
{
return Listener;
}
}
// Use this for initialization
void Start()
{
_VA = VAUAdapter.VA;
Listener = _VA.CreateListener(listenername, auramode, VAUAdapter.DefaultHRIR);
Debug.Log("Listener " + Listener + " created");
_VA.SetListenerHRIRDataset(Listener, VAUAdapter.DefaultHRIR);
}
......@@ -27,8 +35,8 @@ public class VAUListener : MonoBehaviour {
{
t = GetComponent<Transform>();
q = t.rotation;
Vector3 up = q * upvec;
Vector3 view = q * viewvec;
Vector3 up = q * Vector3.up;
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);
......@@ -39,12 +47,4 @@ public class VAUListener : MonoBehaviour {
//Vector3 t1_ogl = ( q_ogl * t1 ); // result: 0 0 -1
// Debug.Log(t1_ogl);
}
void OnDestroy()
{
int i = _VA.DeleteListener(Listener);
}
}
......@@ -7,24 +7,35 @@ using VA;
public class VAUSoundSource : MonoBehaviour {
public int AuralizationMode = 1;
[Range(0.0f, 10.0f)]
public int Volume = 1;
public string directivitypath = "";
private int directivity;
private int Gain = 1;
public string SignalSource = "";
private VANet _VA = null;
private int SoundSource;
private Vector3 viewvec = new Vector3(0, 0, 1);
private Vector3 upvec = new Vector3(0, 1, 0);
private Quaternion q;
private Transform t;
private bool islooping;
private bool ismuted;
public int ID
{
get
{
return SoundSource;
}
}
// Use this for initialization
void Start()
{
_VA = VAUAdapter.VA;
SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Volume);
SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Gain);
islooping = GetComponent<AudioSource>().loop;
if (directivitypath == "")
directivity = VAUAdapter.DefaultDirectivity;
else
directivity = _VA.LoadDirectivity(directivitypath, "SoundSource " + SoundSource + " Directivity");
if (GetComponent<AudioSource>() != null)
{
SignalSource = _VA.CreateAudiofileSignalSource( AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip), this.name + "_signal");
......@@ -41,23 +52,17 @@ public class VAUSoundSource : MonoBehaviour {
//position and oritentation -> VA
t = GetComponent<Transform>();
q = t.rotation;
Vector3 up = q * upvec;
Vector3 view = q * viewvec;
Vector3 up = q * Vector3.up;
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.SetSoundSourcePosition(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetSoundSourceOrientationVU(SoundSource, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
_VA.SetSoundSourcePositionOrientationVU(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
//_VA.SetSoundSourceOrientationVU(SoundSource, view_ogl.x, view_ogl.y, view_ogl.z, up_ogl.x, up_ogl.y, up_ogl.z);
//_VA.SetSoundSourcePosition(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
ismuted = GetComponent<AudioSource>().mute;
_VA.SetSoundSourceMuted(SoundSource, ismuted);
//_VA.SetSoundSourceVolume(SoundSource, Volume); <- flaot ändern
}
void OnDestroy()
{
_VA.DeleteSoundSource(SoundSource);
//_VA.DeleteSignalSource(SignalSource);
}
}
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