What are the key differences between the Sound and Music classes in Pygame? What are the limitations of each? In what situation would one use one or the other? Is there a benefit to using them in an unintuitive way such as using Sound objects to play music files or visa-versa? Are there specifically issues with channel limitations, and do one or both have the potential to be dropped from their channel unreliably? What are the risks of playing music as a Sound?


1 Answer 1


In a game, music would be the a way to play background music and sound the way to play sound effects (ej. jumping, firing, etc).

Music is a special streaming channel of the Mixer. This means the file is streamed from disk in small chuncks and not loaded at once.

Pygame only supports one Music at a time but you can have several Sound objects playing at once, as long as you have available channels.

Music allows you to queue songs and set_endevent to receive an event when the track ends. Note that this can also be achieved by with Sounds using the Channel object.

If you need multiple sounds playing at a time, ie: music player with crossfade, you should use Channels + Sounds. If you only need one background music at a time and mayble multiple sound effects, use Music and Sounds.

  • \$\begingroup\$ A special scenario I am in suggests that I may need to use Sound to play my music. My concern is that it may cause my music to become unreliable due to non-guaranteed channels. Do you think this is a problem? \$\endgroup\$ Nov 5, 2013 at 17:35
  • 1
    \$\begingroup\$ You can set the number of channels (default 8), and Sounds only use a channel while they are playing. The channels are non-guaranteed only if you play more sounds at once than the number of channels you have. \$\endgroup\$
    – pmoleri
    Nov 5, 2013 at 19:49
  • \$\begingroup\$ So you are saying that I can manually, reliably, artificially limit how many channels are used, and thus prevent my problem? \$\endgroup\$ Nov 5, 2013 at 21:13
  • \$\begingroup\$ That's what I understand from the documentation, but I never tried to play that many simultaneous sounds. \$\endgroup\$
    – pmoleri
    Nov 6, 2013 at 12:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .