cc-tweaked / CC-Tweaked

Just another ComputerCraft fork
https://tweaked.cc
881 stars 206 forks source link

speakers.playAudio sometimes plays only on the next call #1874

Open EntityinArray opened 4 days ago

EntityinArray commented 4 days ago

Minecraft Version

1.21.x

Version

1.111.1

Details

Hello, thank you for your work on this amazing mod.

I discovered a weird issue with speakers. Executing speakers.playAudio() with certain timing has a chance to not play sound at all. The audio chunk gets postponed until next function call, at which speakers play 2 chunks one after another.

(speaker is driven properly, waiting for speaker_audio_empty e.t.c., just like in the wiki) https://pastebin.com/2UDbQaZD

Video that demonstrates the issue:

https://github.com/cc-tweaked/CC-Tweaked/assets/18554021/01bd9332-6b84-425f-8fb3-dacbd3cc9dea

EntityinArray commented 4 days ago

I also tried changing chunk length from 16000 to 48000, still can reproduce

https://github.com/cc-tweaked/CC-Tweaked/assets/18554021/baba045d-a0f5-4b93-be1d-35a6a5aa9ca7

My theory is that there seems to be a time window, when speaker finishes playing its chunk, during which sending more audio in causes it to not play anything. It plays 2 chunks (old and new one) after you call play again