I'm currently using LiveKit Unity SDK. I've create...
# ask-ai
m
I'm currently using LiveKit Unity SDK. I've created audio transmission and reception processing, but is there a way to convert the received audio into spatial audio? When I create it according to the sample, it doesn't seem to follow the AudioSource settings.
t
Thanks for reaching out, kyuri. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The LiveKit Unity SDK does support spatial audio, but you’ll need to set it up manually. Basically, the SDK links the audio streams it receives to Unity's
AudioSource
component, which handles spatialization features like 3D rolloff and Doppler effects. Here’s how you can get spatial audio working: • Make sure the
AudioSource
component has spatialization turned on by setting its Spatial Blend to 3D. • Tweak settings like rolloff scale and Doppler factor to get the sound just right. • Keep the
AudioSource
position updated dynamically to match where participants are in your scene. If you want, I’m happy to share detailed steps or some code examples to help you get started! Just let me know. Sources: Samples~/Basic/ProjectSettings/ProjectSettings.asset | TestProject~/ProjectSettings/AudioManager.asset | Real-time audio and video in the Metaverse | Real-time audio and video in the Metaverse | src/controller/SpatialAudioController.tsx
m
I've set up the AudioSource exactly as instructed, but the settings don't seem to be taking effect. Even when I tried setting the Volume value to 0, there was no change.
t
If you’re noticing that the
AudioSource
settings aren’t affecting the received audio, it might be because of how the LiveKit Unity SDK handles remote audio. The SDK connects the incoming audio streams straight to the
AudioSource
component, but some settings—like volume tweaks or spatialization—might not kick in automatically. Here are a few things you can try: • Make sure the
AudioSource
is properly linked to the
AudioStream
and is active in your scene. • Double-check if the SDK is overriding or resetting the
AudioSource
component during playback. • Try adjusting the
AudioSource
properties through a script after the
AudioStream
has initialized to see if your changes take effect. If you’re still running into trouble, just let me know—I’m here to help! Sources: Runtime/Scripts/Proto/AudioFrame.cs
m
The settings for volume and pitch have been applied, but changing the Spatial Blend and Stereo Pan settings does not produce any change in the sound. Do you know why?
t
The Spatial Blend and Stereo Pan settings in Unity's
AudioSource
might not work quite as you'd expect with the LiveKit Unity SDK because the SDK handles audio through WebRTC, which skips over Unity's usual spatialization system. So, Unity's spatial audio settings won’t be applied to the audio streams you receive. But don’t worry! To get those spatial audio effects, you can: • Manually tweak the position and volume of the
AudioSource
in your scene to create a spatial feel. • Use external DSP or audio mixing tools if you want more advanced spatialization options. If you want, I’m here to help guide you through making these adjustments—just let me know! Sources: Runtime/Scripts/Proto/AudioFrame.cs | src/controller/SpatialAudioController.tsx | LivekitUnitySampleApp/Assets/LivekitSamples.cs | Using WebRTC + React + WebAudio to create spatial audio
m
Adjusting the volume can reproduce the sense of distance, but it doesn't convey direction. I want to convey direction.
t
To help you get that directional feel for received audio, you can use Unity's 3D audio system along with the LiveKit Unity SDK. Here’s a friendly little guide on how to set up directional audio: • Make sure the
AudioSource
has Spatial Blend set to 1.0 (that means fully 3D). • Keep the
AudioSource
position updated dynamically so it matches where the remote participant is in your scene. • Tweak settings like rolloff mode, min distance, and max distance to get that nice, natural volume drop-off. Unity’s audio engine will take care of stereo panning and volume changes based on where the AudioListener and AudioSource are in relation to each other. If you want, I’m happy to share some detailed code examples or help you out further—just let me know! Sources: README.md | LivekitUnitySampleApp/ProjectSettings/AudioManager.asset | README.md | Runtime/Scripts/Proto/AudioFrame.cs
m
Even when set to 1, Spatial Blend does not apply. Please consider another method.
Please answer the question.
?
Are you okey?