Commit 5e7a1355 authored by Maurice Tayeb Andreas's avatar Maurice Tayeb Andreas

VAU Skripts hinzugefügt

parent d531082b
This diff is collapsed.
using UnityEngine;
using UnityEditor;
using System;
using System.Collections;
using System.Collections.Generic;
using VA;
// Adapter to VA (singleton)
public class VAUAdapter : MonoBehaviour {
public static string HostIP = "localhost";
public static int Port = 12340;
public static string DefaultHRIRPath = "$(DefaultHRIR)";
private static int defaulthrir;
private static VANet _VA = new VANet();
// No public construction allowed
private VAUAdapter() {}
public static VANet VA
{
get
{
bool b = _VA.IsConnected();
if (!_VA.IsConnected())
{
Debug.Log("Connected to VAServer throught VA.");
Init();
}
return _VA;
}
}
private static void Init()
{
Debug.Log("Connected to VAServer through Init.");
_VA.Connect(HostIP, Port);
_VA.Reset();
//defaulthrir = _VA.LoadHRIRDataset(DefaultHRIRPath, "DefaultHRIR");
}
public static int DefaultHRIR
{
get
{
return defaulthrir;
}
}
float yaw()
{
return 0f;
}
// Use this for initialization
void Awake()
{
//var dllDirectory = @"Assets/Plugins/VAUnity/bin";
//var dllDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
//var dllDirectory = @"C:/Users/Public/Documents/Unity Projects/Standard Assets Example Project/Assets/Plugins/VAUnity/bin"; // w
// var dllDirectory = System.Reflection.Assembly.GetExecutingAssembly().Location + @"../../Plugins/VAUnity/bin";
//Environment.SetEnvironmentVariable( "PATH", Environment.GetEnvironmentVariable("PATH") + ";" + dllDirectory );
if (!_VA.IsConnected())
{
Debug.Log("Connected to VAServer through Awake.");
Init();
}
//string audiofilepath = Application.dataPath.Remove(Application.dataPath.Length - 6) + AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip);
//string id = _VA.CreateAudiofileSignalSource(audiofilepath, "ita_test");
//Debug.Log(audiofilepath);
//Debug.Log(id);
}
// Update is called once per frame
void Update ()
{
}
void OnDestroy ()
{
_VA.Disconnect();
}
}
using UnityEngine;
using System;
using System.Collections;
using VA;
public class VAUListener : MonoBehaviour {
int Listener;
private VANet _VA = VAUAdapter.VA;
// Use this for initialization
void Start()
{
Listener = _VA.CreateListener("MyListener", 123, VAUAdapter.DefaultHRIR);
}
// Update is called once per frame
void Update ()
{
Transform t = GetComponent<Transform>();
_VA.SetListenerPosition(Listener, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetListenerOrientationYPR(Listener, -t.transform.rotation.eulerAngles.x, -t.transform.rotation.eulerAngles.y, t.transform.rotation.eulerAngles.z);
}
}
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using VA;
public class VAUSoundSource : MonoBehaviour {
private int SoundSource;
public int AuralizationMode = 1;
[Range(0.0f, 100.0f)]
public double Volume = 70;
public string SignalSource = "";
private VANet _VA = VAUAdapter.VA;
// Use this for initialization
void Start()
{
SoundSource = _VA.CreateSoundSource(this.name, AuralizationMode, Volume);
if (GetComponent<AudioSource>() != null)
{
SignalSource = _VA.CreateAudiofileSignalSource( AssetDatabase.GetAssetPath(GetComponent<AudioSource>().clip), this.name + "_signal");
_VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
Debug.Log(SignalSource);
_VA.SetAudiofileSignalSourcePlaybackAction(SignalSource, 2);
}
//if( SignalSource == "" )
//{
// AudioClip AudioSourceClip = GetComponent<AudioSource>().clip;
// string SignalSourcePath = AssetDatabase.GetAssetPath(AudioSourceClip);
// Debug.Log(SignalSourcePath);
// //SignalSource = _VA.LoadAudiofileSignalSource(SignalSourcePath);
//}
//if ( SignalSource != "" )
// _VA.SetSoundSourceSignalSource(SoundSource, SignalSource);
}
// Update is called once per frame
void Update()
{
//position and oritentation -> VA
Transform t = GetComponent<Transform>();
_VA.SetSoundSourcePosition(SoundSource, t.transform.position.x, t.transform.position.y, -t.transform.position.z);
_VA.SetSoundSourceOrientationYPR(SoundSource, -t.transform.rotation.eulerAngles.x, -t.transform.rotation.y, t.transform.rotation.eulerAngles.z);
}
}
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