Pygame sound delay - Not related to buffer/sampling

后端 未结 2 515
情话喂你
情话喂你 2021-01-15 19:47

I am trying to play simple wav files in my little game whenever the user hovers over a button, a little click sound is played (same goes for when the button is actually pres

相关标签:
2条回答
  • 2021-01-15 20:05

    THE ANSWER:

    I wound up initiating the mixer with pre_init settings, then quitting the mixer, then initiating it again:

    pygame.mixer.pre_init(22050, -16, 2, 1024)
    pygame.init()
    pygame.mixer.quit()
    pygame.mixer.init(22050, -16, 2, 1024)
    

    Now it works just fine.

    0 讨论(0)
  • 2021-01-15 20:14

    In my case I found that it's sufficient to just quit the mixer before it's started (even if it's never been started before):

    pygame.mixer.quit()
    pygame.mixer.init(44100, -16, 2, 1024)
    
    0 讨论(0)
提交回复
热议问题