Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Audio playback stutter #23

Open
duarm opened this issue May 5, 2024 · 10 comments
Open

Audio playback stutter #23

duarm opened this issue May 5, 2024 · 10 comments

Comments

@duarm
Copy link

duarm commented May 5, 2024

Thanks for making lua-mumble!

Same as #5, audio playback via

local stream, err = client:play("music.ogg", 1, 1.0)

stutters from time to time (every 10~20 seconds), tested with a 48000Hz 2ch ogg file.

@bkacjios
Copy link
Owner

bkacjios commented May 5, 2024

What hardware are you running this on? What is the servers max bitrate? If it's every 20-30 seconds I'm wondering if the ping/pong is somehow to blame..

@duarm
Copy link
Author

duarm commented May 5, 2024

I'm running both the bot and the server on my own machine. Not sure which hardware is relevant but assuming my cpu: AMD Ryzen 5 3600. My mumble-server.ini says bandwidth=558000, I'm printing the PING PONG messages and periodically, after around 1~3 seconds every 2 PONGS, a stutter happens, it's somewhat consistent so I think it's a good guess.

Built myself from source, I'm on arch.
protobuf-c 1.5.0-2
libev 4.33-2

@bkacjios
Copy link
Owner

bkacjios commented May 5, 2024

Thank you. Cool. I have a similar setup as you. I'll have a few ideas on what may be the cause.

bkacjios added a commit that referenced this issue May 7, 2024
Beginnings of 1.4 and 1.5 client support.
Fixed mumble.client:transmit always sending data through TCP tunnel.
Added mumble.channel:set/getVolumeAdjustment.
Client will now authorize to the server as a bot.
Set priority on timers to try and help with issue #23.
Update OCB library to latest.
Break out of mumble.loop on SIGINT.
Added new mumble.buffer metatable.
@bkacjios
Copy link
Owner

bkacjios commented May 9, 2024

Mind trying my async-connect branch? I added some changes which I think helped with the audio stuttering. Plus it uses the new audio packet format that was introduced in mumble 1.5.

To use this branch, mumble.connect is no longer blocking, which means you have to use auth in a OnConnect hook.

client:hook("OnConnect", function(client)
	print("OnConnect", client)
	client:auth("TestBot")
end)

@duarm
Copy link
Author

duarm commented May 9, 2024

Tested a bit and it got worse, It depends on the bitrate of the song I think, some high bitrate sections completely destroys the quality and stutters a lot, and the audio quality is much degraded, although I noticed the quality was not that great in the previous version either.

image
audio.webm

@bkacjios
Copy link
Owner

bkacjios commented May 9, 2024

I really don't get it.. Here's a recording I made of the bot playing a 48000hz, 2 channel, ogg file. To me, it sounds perfect.

image

Mumble-2024-05-09-13-01-14-192.168.1.205-TestBot.zip

Try messing around with this...

client:setAudioQuality(mumble.quality.LOW) -- LOW, MEDIUM, HIGH, BEST are all valid options
client:getEncoder():setBitRate(10000) -- Manually set the bitrate to whatever you want. 10k bitrate sounds AFWUL.

I need to rename setAudioQuality, since it's what the "audio per packet" setting in the mumble client does.

It basically sets how many audio frames we send per packet.
LOW = 10
MEDIUM = 20
HIGH = 40
BEST = 60

More = higher latency and less chances for stutter. However, it can quickly cause it to overflow the packet buffer, making it stutter.

I think in your case, you would actually want it LOW. Still, setAudioQuality will try to automatically adjust the bitrate of the encoder to work for the servers settings.

You should be seeing a message like this in the console when running the bot.

[MUMBLE -  WARN] Server maximum network bandwidth is only 558 kbit/s. Audio quality auto-adjusted to 96 kbit/s (20 ms)

@duarm
Copy link
Author

duarm commented May 9, 2024

I've been fiddling with the values and setting audio to BEST seems to make it much better (both quality and stutter-wise). Sometimes when I change a song (via client:play()), the beggining of the new song stutters a lot but after 1 or 2 seconds it stabilizes, I'll do a more extensive test eventually, it's much better now

@bkacjios
Copy link
Owner

bkacjios commented May 9, 2024

Very very strange.. But good to know.

@bkacjios
Copy link
Owner

bkacjios commented May 9, 2024

I'm starting to think the audio issues is a bug with mumble itself. I've had my bot playing a song on loop for a few hours now. It's been totally fine. I reconnected myself (not the bot) to the server and suddenly the audio was stuttering like crazy. Reconnecting again fixed it. Not sure what's going on there.

@davidebeatrici
Copy link

Related: mumble-voip/mumble#6415

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants