📝 Worksheet← Lesson← Course
BitWithBite
Pygame Mastery · Quick Reference

Sound System Cheat Sheet

Pygame Mastery
In one line: pygame.mixer.music for one background track, pygame.mixer.Sound for many overlapping effects, both with volume and fade control.

Key Ideas

1Music vs Sound. mixer.music streams ONE long track (background music). mixer.Sound loads fully into RAM for instant, overlapping playback (SFX).
2Channels. Every Sound.play() grabs a free Channel automatically — default 8, raise with set_num_channels() if sounds get cut off.
3Volume. set_volume(0.0-1.0) works on both music and individual Sounds independently.
4Fade In/Out. music.play(fade_ms=1000) fades in; music.fadeout(800) fades out smoothly instead of an abrupt cut.
5Looping. music.play(loops=-1) repeats forever — standard for background music.
6Audio Manager. Centralize all sound loading/playing in one class instead of scattering mixer calls across the codebase.

Core Calls

pygame.mixer.music.load(path)
pygame.mixer.music.play(loops=-1)
pygame.mixer.music.set_volume(0.6)
pygame.mixer.music.fadeout(800)
sfx = pygame.mixer.Sound(path)
sfx.set_volume(0.8)
sfx.play()
MusicCh 0Ch 1
Music streams continuously on one track while Sound effects grab free Channels for short, independent bursts.