Spatial audio does not work with audio streams
See original GitHub issueI’m trying to use this as part of a voice chat feature in a game that implements CEF. However, it doesn’t seem to apply any 3D effects to the voice stream. I tested a normal sound (ogg) and it worked as expected, with the audio becoming quieter as the player moved away from the other and the direction in the speakers changing as well. With an audio stream from a microphone, using window.URL.createObjectURL(stream)
to get the source, it only plays the sound as if it were a normal sound - it doesn’t matter where my player is in the game; the sound is the same volume and direction.
I’m curious as to if this even works with spatial audio. I tried using a different library (HowlerJS), but I read that audio streams are not supported with their spatial audio. Is this the same case here?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top GitHub Comments
Hi Benank,
I have a feeling you need to explicitly have WebAudio handle the stream via a createMediaStreamSource() function call and then pipe it’s output to our renderer. See https://developer.mozilla.org/en-US/docs/Web/API/AudioContext/createMediaStreamSource for more details.
Please feel free to post some example code as well so I can help you better. 😃
Cheers, Drew
@benank Wow, I didn’t really expect that you’d respond at all, and the fact that you responded so quickly is blowing me away, especially given that you’re sharing code.
I really appreciate it. 😃
As it turns out, at the same time as you were typing this, I was able to figure it out based on your earlier hint: https://github.com/resonance-audio/resonance-audio-web-sdk/issues/34#issuecomment-819902221
Thank you so much! This is really cool.