// Use this for initialization
 void Start()
 {
     listener = Camera.main.gameObject.GetComponent <NVAR_Listener>();
     mesh     = gameObject.GetComponent <MeshFilter>().mesh;
     NVAR.CreateMaterial(listener.context, out material);
     NVAR.CreateMesh(listener.context, out NVAR_mesh, gameObject.transform.localToWorldMatrix, mesh.vertices, mesh.triangles, mesh.triangles.Length / 3, material);
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     NVAR.SetListenerLocation(context, gameObject.transform.position);
     NVAR.SetListenerOrientation(context, gameObject.transform.forward, gameObject.transform.up);
     if (traceWaitHandle.WaitOne(0))
     {
         NVAR.TraceAudio(context, traceWaitHandle.SafeWaitHandle.DangerousGetHandle());
     }
 }
 // Use this for initialization
 void Start()
 {
     listener    = Camera.main.gameObject.GetComponent <NVAR_Listener>();
     audioSource = GetComponent <AudioSource>();
     baseClip    = audioSource.clip;
     NVAR.CreateSource(listener.context, NVAR.EffectPreset.Medium, out NVARsource);
     audioSource.clip = AudioClip.Create("NVARAudio", baseClip.samples, 2, baseClip.frequency, false);
     audioSource.Play();
     frameCount = updateLength;
 }
 // Update is called once per frame
 void Update()
 {
     if (frameCount == updateLength)
     //if (Input.GetKeyDown("down"))
     {
         ApplyFilter();
         frameCount = 0;
     }
     frameCount++;
     //ApplyFilter();
     NVAR.SetSourceLocation(NVARsource, gameObject.transform.position);
 }
    private void ApplyFilter()
    {
        int bufferLength = (int)((1 / listener.minFramerate) * updateLength * baseClip.frequency);

        float[]   audioDataIn = new float[bufferLength];
        float[][] audioDataOut;
        int       filterStart = NextZeroCrossing();

        baseClip.GetData(audioDataIn, filterStart);
        NVAR.ApplySourceFilters(NVARsource, out audioDataOut, audioDataIn, audioDataIn.Length);
        NVAR.ApplySourceFilters(NVARsource, out audioDataOut, audioDataIn, audioDataIn.Length); //might be unneccessary
        audioSource.clip.SetData(ParallelToWeaved(audioDataOut), filterStart);
    }
Beispiel #6
0
 private void OnDisable()
 {
     NVAR.Destroy(context);
     NVAR.Finalize();
 }
Beispiel #7
0
 // Use this for initialization
 void Awake()
 {
     traceWaitHandle = new EventWaitHandle(true, EventResetMode.AutoReset);
     NVAR.Initialize(0);
     NVAR.Create(out context, "VRWA-Unity", NVAR.EffectPreset.Low);
 }