I have a live kit setup which will send 48Khz audi...
# ask-ai
c
I have a live kit setup which will send 48Khz audio to mqtt gateway which is nodejs application and resampled to 24khz and i am passing that to a esp32 device where 24khz is resampled to 16khz and played for one device voice is working perfectly but if i we add too many devices it is giving issue flickering issue in voice
t
Thanks for reaching out, abilash. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
I understand how frustrating audio flickering can be when streaming to multiple devices, so let’s explore some helpful steps together: • Enable Audio RED (Redundant Encoding): This is a great way to boost audio quality by sending extra copies of audio data, which helps recover from any packet loss you might encounter. • Increase AudioSource Queue Size: If you notice frame capture failures, try increasing the
queue_size_ms
parameter (for example, to 2000ms) to give your system more buffer for audio data. • Ensure Proper Audio Device Management: Setting up your preferred audio devices and output behavior carefully can make a big difference in keeping playback smooth and consistent. • Handle Browser Audio Playback Policies: For web platforms, make sure audio playback starts programmatically (like using
startAudio()
) to avoid any surprises. • Avoid Blocking Frame Pushes: Pushing audio and video frames in parallel helps prevent sync issues or flickering, keeping everything running nicely together. • Use Acoustic Echo Cancellation (AEC): Turning on AEC and using headphones can really help reduce feedback and keep your audio crisp and clear. I hope these suggestions make your multi-device streaming experience much smoother! Please feel free to reach out if you’d like any guidance on putting these into practice—I’m here to help. Sources: shared_swift/LiveKitPlugin.swift | src/room/Room.ts | Debugging Audio/Video Sync Issues in LiveKit Publishing | README.md | Codecs and more | LiveKit Docs
c
what all i can do from livekit side
t
I understand how frustrating audio flickering can be, and I’m here to help you through it. From the LiveKit side, here are some steps you can try to improve your audio experience: • Enable Audio RED (Redundant Encoding): This helps enhance audio quality by sending extra copies of audio data, which can recover lost packets. You can turn this on in the server configuration under the
audio
section. • Adjust AudioSource Queue Size: If you’re using custom audio sources, setting the
queue_size_ms
parameter between 1000–2000ms can help prevent frame drops when the system is under load. • Synchronize Audio and Video Push Timing: Try pushing audio and video frames simultaneously using separate tasks to reduce delays and jitter. • Configure Audio Session Settings: For iOS/macOS, setting the audio category and mode (like
playAndRecord
with
voiceChat
) can ensure smoother routing and avoid interruptions. • Disable Communication Mode Workaround (Android): If you’re on Android, you might want to disable the silent audio track workaround so you can manage audio interruptions more directly. • Manage Renderer Lifecycle: Make sure the audio and video renderers are handled properly throughout their lifecycle to keep playback stable. These tips are designed to help improve your audio stability and reduce flickering. If you’d like, I’m happy to walk you through detailed steps for any specific platform or feature—just let me know! Sources: Resolving "InvalidState - failed to capture frame" errors in AudioSource | CHANGELOG.md | livekit-android-sdk/src/main/java/io/livekit/android/LiveKitOverrides.kt | shared_swift/LiveKitPlugin.swift | CHANGELOG.md
c
class *AudioSource*(sample_rate: int, num_channels: int, queue_size_ms: int = 1000, loop: asyncio.AbstractEventLoop | None = None) In this what if i set num_channels to 3 what will happen what is the purpose of it
t
I’m glad you asked about the
num_channels
parameter in
AudioSource
! This setting tells the system how many audio channels to expect for each audio frame—like 1 for mono or 2 for stereo. So, if you set
num_channels
to 3, it means the audio source is expecting 3-channel audio frames (such as left, center, and right). The audio data should be arranged accordingly, with three samples per time step (for example, L-C-R-L-C-R). That said, while the SDK does let you set
num_channels=3
, most WebRTC backends and client platforms typically support only mono (1 channel) or stereo (2 channels). Using 3 channels might cause some hiccups like rejected frames, audio distortion, or even silence during playback. To get the best experience, I’d recommend sticking with mono or stereo audio. If you’re working with multi-channel audio, it might be helpful to downmix it to stereo or mono before sending it to LiveKit. If you’d like, I’m here to help guide you through how to do that conversion—just let me know!