Hi Jasper. Try the fourth answer here <https://stackoverflow.com/questions/57960451/how-can-i-play-a-portion-of-an-audio-file-in-a-loop-in-pygame>, by Ted Klein Bergman.

On 7/13/2021 4:24 PM, Jasper Phillips wrote:
I'm working on a networked action game with rollback netcode, and so I need to play sound effects starting an arbitrary amount of time from the beginning of the file so they sync up with game events.

pygame.mixer.music does this via set_pos()... but apparently there's no corresponding method when playing effects directly via a Channel. Unfortunate, as I need to use Channels!

The best I've come up with is to use Sound.get_raw(), trim the starting bytes off then, create a new Sound.  But this fails several different ways, I'm guessing because I'm arbitrarily slicing the bytes and there's some format details I don't know.


Does anyone have any tips for hacking raw Sound data, or perhaps some better approach?

-Jasper

Reply via email to