soundscape-community / soundscape-web-client

Intelligent navigation on any platform
MIT License
2 stars 2 forks source link

spatial audio not spatial: either left or right #22

Closed sebastianovide closed 3 months ago

sebastianovide commented 3 months ago

Hello,

I've just found this project, and the first thing I did was test it on my Android phone. I can hear the spatial audio sounds, but they don't seem truly spatial. The sounds come from either the right or left side depending on my phone's orientation relative to the beacon. However, the volumes from both sides are not regulated, so it doesn't give me the sensation that the sound is coming from the beacon's location.

Is this a bug or a feature that hasn't been implemented yet?

Thanks.

steinbro commented 3 months ago

Thanks for the feedback! We gladly welcome testing on Android, so feel free to add anything else to GitHub issue #1.

I think your observation is accurate, and may be related to how we're normalizing distances. The positional audio is not fainter if a location is farther away; it is always the same volume, consistent with the Soundscape app. We do this by figuring out our angle from the location, and then placing the sound a fixed distance away from us at that angle. I can imagine if that distance is too short, the audio spatializer might effectively send 100% of the audio to one channel or the other, as if the sound source were right up against our head. It should be easy to simply increase that fixed distance to make the sound sources further away, which may feel more realistic . https://github.com/soundscape-community/soundscape-web-client/blob/main/app/js/spatial/location.js#L46

steinbro commented 3 months ago

My previous comment was partially correct, though I found a more insidious bug: our Y and Z axes were swapped, i.e. we were passing the forward/behind position of the audio as the argument for the above/below position. Can you give it another try and see if it sounds better? There are plenty more parameters to tweak in the WebAudio PannerNode API. For starters, I set the pannerModel to HRTF, which should be more worthy of spatial audio for AR/VR.

sebastianovide commented 3 months ago

yes, better indeed... now I hear real spatial.... I'll test it properly better later on. The tricky part of testing it is that the map is not displaying the beacon that I'm going to...

steinbro commented 3 months ago

The active beacon should now be plotted on the visual map.

sebastianovide commented 3 months ago

waw !!! super @steinbro ... It seems to work... I'll close this