[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Static on looping music


I am having some trouble with playing music in my project.
- Platform is Windows XP. Running Python 2.5.4 and Pygame 1.8.1
- The song is in .ogg format and plays fine in both VLC and iTunes
- When playing the song for the first time in a pygame program it
plays fine
- When the music begins again when looping, there is a significant
audible static.

I was wondering if there is a problem with my code or the song file
itself and what steps I can take to fix it in either case. I have
tried the solution of putting a pygame.mixer.pre_init(44100, -16, 2,
4096) statement before pygame.init() but that seems to make the
problem worse.

Code Sample that reproduces the problem:

import pygame
from pygame.locals import *
import os
from sys import exit

screen =  pygame.display.set_mode((200,200),0, 32)
clock = pygame.time.Clock()

pygame.mixer.music.play(-1) # Play and Loop Forever
while True:
    for event in pygame.event.get():
        if event.type == QUIT:


Test script and music file

Thank you in advance