layeh / gumble

gumble is a Mumble client implementation in Go (golang)
https://pkg.go.dev/mod/layeh.com/gumble
Mozilla Public License 2.0
172 stars 55 forks source link

Transmit Stereo Audio #51

Open iotku opened 4 years ago

iotku commented 4 years ago

Since https://github.com/mumble-voip/mumble/pull/4209 has been merged (and will most likely be included in the Mumble 1.4.0 release) it would be nice to have the ability to transmit stereo audio implemented into gumble.

Presumably, at a quick uninformed glance, all that would need to change would be setting AudioChannels to 2 although it might be more complicated than that. https://github.com/layeh/gumble/blob/1ea1159c495624266a4adea43580748fd0fc9c57/gumble/audio.go#L30

Supposedly the "opus decoder can also automatically convert a stereo stream into a mono stream, so even if we transmit a stereo stream to an older version of mumble, it would still work." according to the author of the PR.

Regardless, it is probably sensible to default to mono still (since 1.4.0 hasn't released yet) with a configurable option to transmit in stereo.

iotku commented 2 years ago

Through random poking around I was somewhat successful in transmitting stereo audio without major glitches by changing in audio.go

AudioDefaultFrameSize = (AudioSampleRate / 100) * AudioChannels AudioChannels = 2

and in writeAudio() modifying raw to raw, err := encoder.Encode(a, len(a)/AudioChannels, dataBytes)

But there's some bleed through from the left & right channels to each other and I'm still pretty out of my depth here.

iotku commented 2 years ago

It appears it's due to mumble client settings, Enabling positional audio and headphones (under positional audio) check-boxes in the audio output settings appears to solve the issue with the bleeding