jolly-hair-41577
11/28/2025, 6:20 AMtall-airline-16756
11/28/2025, 6:20 AMtall-airline-16756
11/28/2025, 6:21 AMlet audioTrack = try LocalAudioTrack.createTrack(
options: AudioCaptureOptions(channelCount: 2)
)
1. The SDK uses Opus (WebRTC) which supports stereo; Chrome (WebRTC) will decode and play the stereo stream.
If you want, tell me how you’re capturing audio on macOS (AVAudioEngine, external device, file) and I’ll suggest the exact capture/output settings to ensure true stereo is preserved.
Sources: client-sdk-js | livekit/livekit_composite | DeepWiki | client-sdk-swift | livekit/livekit_composite | DeepWikijolly-hair-41577
11/28/2025, 6:21 AMtall-airline-16756
11/28/2025, 6:22 AMlet engine = AVAudioEngine()
let inputNode = engine.inputNode
let bus = 0
let stereoFormat = AVAudioFormat(commonFormat: .pcmFormatFloat32, sampleRate: 48000, channels: 2, interleaved: false)!
inputNode.installTap(onBus: bus, bufferSize: 512, format: stereoFormat) { buffer, when in
// handle buffer
}
try engine.start()
2) Supply that stereo PCM into the LiveKit track
• Create a LocalAudioTrack from your custom source / audio stream capture and feed the stereo PCM buffers. Ensure the track is created without forcing mono and uses 48 kHz channels=2.
3) Ensure system/session settings allow stereo
• Verify your macOS audio device supports 2 channels and, if applicable, set preferred channels:
let session = AVAudioSession.sharedInstance()
try session.setPreferredInputNumberOfChannels(2)
(Note: AVAudioSession applies to iOS/tvOS; for macOS use AVAudioEngine/AVAudioDevice I/O configurations.)
4) Verify on the receiver (Chrome)
• Chrome/WebRTC will decode Opus stereo and should present a stereo MediaStreamTrack if the publisher preserved two channels. Test with a stereo-capable output device and inspect the received track in the Chrome Web Audio API or devtools.
If you’d like, I can:
• Provide a sample that converts the tapped AVAudioEngine buffers into the exact API call for creating a custom LiveKit audio source, or
• Help debug if your current capture ends up mono (share a short snippet of your capture/publish code). Sources: Codecs and more | LiveKit docs | Camera & microphone | LiveKit docs