googlearchive / tango-examples-unity

Project Tango [deprecated] UnitySDK Example Projects
https://developers.google.com/ar
Apache License 2.0
470 stars 242 forks source link

GVR Spatial Audio not Functioning as Expected #82

Closed rampartisan closed 7 years ago

rampartisan commented 7 years ago

Hey,

I am attempting to utilise the GVR spatialiser plugin in my tango project which is an ever so slightly adapted version of the mesh builder with occlusion example. I eventually managed to work my way through to a successful compile, through using a blank project, importing GVR SDK, then Tango SDK and a few horrible edits of the android manifests.

The audio is currently playing and appears to be spatialised, when I select a new world position for the AR marker the HRTF appears to change and does indeed sound like it is coming from the direction. However all "head" (phone) rotation and movement does not work, the HRTF filters appear unchanged.

I currently have only GVRAudio related objects within my scene, is it possible that the GVR Audio Listener needs a GVR associated object in order to determine its positon/rotation (like a GVR head?) I haven't used GVR before this project and really only want the spatialiser, I am currently having to use oculus and would really like the extra features from GVR.

And is there an accepted standard way to integrate GVR and Tango?

Thanks

bopangzz commented 7 years ago

Unfortunately, GVR and Tango do not work nicely together. But you should be able to only add the GVR Audio plugin to your Tango project by making a small change in the code. I did some test and I got GVR Audio working with Tango. Here is what I did:

  1. Create an empty Unity project.
  2. Import Tango Unity Plugin.
  3. Import the following files from Unity GVR Plugin:
    • GvrAudio.cs
    • GvrAudioListener.cs
    • GvrAudioRoom.cs
    • GvrAudioSoundField.cs
    • GvrAudioSource.cs
    • BaseAndroidDevice.cs
    • Pose3D.cs
    • gvr_audio.jar
    • libaudioplugingvrunity.so
    • libgvrunity.so(from GVRBackwardsCompatibility.unity)
    • gvr_android_common(from GVRBackwardsCompatibility.unity)
  4. Change BaseAndroidDevice to NOT inherit from BaseVRDevice.
  5. Open the AugmentedReality Scene.
  6. Select Gvr Audio Spatializer as the Spatializer Plugin in the Edit > Project Settings > Audio : Spatializer Plugin dropdown menu.
  7. Add GvrAudioListener and AudioListener to Tango AR Camera
  8. Add GvrAudioSource to an object in the scene.
  9. Build and Run the AugmentedReality Scene.

Result: I can hear the spatialized audio and it changes correctly according to my phone(camera) location.

rampartisan commented 7 years ago

Hey,

I can confirm that this method works, thank you very much! I can happily use GVR spatialisation again!

I actually solved the problem myself, the solution is not as elegant as yours though: Import GVR package, Import Tango package, Then edit all android manifest's to min version 19 and max version 24.

This then worked for me, but is obviously a little hacky.

Do you have any info on how spatial audio / GVR will integrate with tango in the future?

bopangzz commented 7 years ago

We probably will make GVR Audio easier to separate from the reset GVR Unity plugin.