googlevr / gvr-unity-sdk

Google VR SDK for Unity
http://developers.google.com/vr/unity/
Other
2.71k stars 1.09k forks source link

Head Tracking not affecting sound #386

Closed sbmhome closed 7 years ago

sbmhome commented 7 years ago

I'm developing within Unity 5.4.1, HTC VIVE and using GVR for Audio. If I move a GVRAudiosource around the player, I can hear that the sound does pan between headphones.

It doesn't however, change if I turn my head. Whether I'm looking at the audio source or looking away from it, the sound NEVER changes. This prevents it from sounding truly spatialized.

Questions:

  1. Do I have to Manually get the headset tracked by GVR?

  2. I noticed that "Enable HRTF" gets greyed out and stays checked when I press play in Unity. But whether I uncheck it or I leave it checked (before pressing play)....the audio sounds exactly the same under all circumstances. That gives me the impression that its not working and it seems to be what is preventing me from turning my head and the audio changing (sounding spatialized).

  3. If I hover over HRTF it informs me that Binaural audio wont work if the stereo quality is set globally. I'm assuming the its referring to the "Default Speaker Mode" in the AudioManager of Unity? The issue for me is that I get no audio output except for if I use stereo. Also, there is no direction on what should be changed in order to get HRTF to actually work.

Anyone with any help will be much appreciated...this has been driving me nuts for the past few days.

anokta commented 7 years ago

Hi,

The audio features and prefabs in the SDK target Google VR platforms by default.

In order to add GVR audio to a HTC Vive scene, please ensure that the GvrAudioListener component is attached to the camera game object where the Unity AudioListener component is attached to. It should be "Camera (ears)" game object in "Camera (head)" if you are using SteamVR's default [CameraRig] prefab. Please also make sure that the Spatializer Plugin in Project Settings -> Audio is selected as "GVR Audio Spatializer".

The stereo quality mode refers to the global rendering quality of the audio plugin which you can select in the Inspector view via the GvrAudioListener component. This setting is independent from the speaker mode (which should be stereo channels), and is recommended to be set as "High" for the high quality HRTF binaural rendering.

HRTF rendering per individual audio sources can be toggled on/off during Edit mode only (i.e., not in runtime, which is why you see them as grayed out). Likewise, it is recommended to keep this checked for high quality rendering, otherwise, the audio source will be rendered by stereo panning only.

sbmhome commented 7 years ago

Thanks for the reply. It looks like I have everything setup correctly...as the AudioListener is indeed set to "High". Thanks for explaining the speaker mode...thats where there was some confusion on my end.

I can hear audio...and the stereo panning does work, But it seems that the audio doesn't change based on my head movement.

In other words, if I keep my head still and move the GVRAudioSource around I can hear tell that I just move it from my left to right. HOWEVER, if I leave the GVRAudioSource in one place and turn my head 360 degrees...I cant pinpoint the location of the sound. The sound doesn't change based on HMD movement.

This makes the sound coming from it the same regardless of where I look. It seems as though only distance and occulsion work properly for me. I fooled around with all of the setting as can't get the audio to sound "different" when I turn my head.

anokta commented 7 years ago

Could you verify if the game object that the GvrAudioListener is attached to (i.e., "Camera (ears)") moves/rotates as expected when you use the HMD? The GvrAudioListener component updates the listener transformation properties of the internal system using the Transform component of this corresponding game object. Therefore, that is the only place I can think of which the issue could be caused by.

We can't seem to reproduce the issue using a HTC Vive device on our end, so any specific setup information and/or an example project that you are able to reproduce the issue would be very helpful.

sbmhome commented 7 years ago

You hit the nail on the head.

I did have the GvrAudioListener attached to the "Camera (ears)", however the transform was not being updated. I did a quick test by attaching the GvrAudioListener to the "Camera (eye)", (which the transform IS moving)...and the sound is working as expected!

That means I need to figure out why the transform for the "Camera (ears)" isn't updating...but that's another issue. Thanks again!