CC: Tweaked

CC: Tweaked

59M Downloads

Speaker emit speaker_audio_empty when they start playing audio

EntityinArray opened this issue · 6 comments

commented

Minecraft Version

1.21.x

Version

1.111.0

Details

Doing speaker.playAudio() will cause speakers to emit speaker_audio_empty event when they start playing.

commented

So once you've started playing audio with a speaker, you don't ever want to stop. It's much better to feed samples into the speaker's internal buffer than maintain your own separate buffer.

The tricky bit is, of course, making sure you don't run out of samples. As far as I'm aware (I'm afraid I've not done much with audio streaming myself, so don't know all the tricks), the only way to do that is to make the program receiving audio lag behind the sending program by one or two seconds.

commented

Thanks for the report! This seems like expected behaviour to me — when a speaker starts playing audio, it hasn't built up a buffer yet, and so requests more audio from the user.

commented

ok, thank you. and the maximum buffer size inside the speaker is 128 * 1024 samples, right?

commented

Yep!

commented

sorry if this is not an appropriate place for questions.
I'm receiving an audio stream over modem in chunks of 16*1024 that I store in local buffer = {}

is there any way to prevent speaker from voiding buffer into itself instantly? i want to have a buffer delay to prevent stuttering

commented

this could be solved if I could get speakers current buffer queue size, but I don't see any way to do that