Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When do I need to use mixer pre-init as oppsed to just mixer.init?

What is the difference between pygame.mixer init and pygame.mixer pre init? I saw a tutorial and he used pre-init, but the explanation wasn't clear. Should I just use mixer init, or do both?

like image 317
marienbad Avatar asked Sep 13 '25 19:09

marienbad


1 Answers

The problem is that pygame.init(), which initialize all imported Pygame modules, calls pygame.mixer.init() with its default arguments, because

some platforms require the pygame.mixer to be initialized after the display modules have initialized.

as the documentation states.

To solve this problem and set proper default values for frequency, channels and buffersize you could call pygame.mixer.pre_init() to preset the default mixer init arguments before you call the pygame.init() toplevel function.

like image 50
elegent Avatar answered Sep 16 '25 07:09

elegent