Hi, Joshua. In my own projects I've noticed lag with some sounds that buffer tuning couldn't improve. Those I discovered were largely due to the shape of the sound: there is a minute delay introduced by the SDL call but it is almost unnoticeable when using a sound that has an immediate attack. I am noticing this same kind of thing with your demo sound. When I load this file into Audacity I see there is a short prelude of quiet until the peak decibels are produced, which is quite detectable to my ear. Once I edited out the quiet part with Audacity your demo produces a response that seems much more immediate. If modifying the sound file in this fashion does not solve your issue, it may be the way SDL uses your sound card which unfortunately I think cannot be tuned (someone please correct me if I'm wrong, I too would like to learn a new trick).
Hope this helps. Gumm On Thu, Dec 13, 2012 at 3:05 PM, Joshua_Blake <[email protected]> wrote: > sound_test.zip > <http://pygame-users.25799.n6.nabble.com/file/n407/sound_test.zip> > I'm uploading a zip of the demo with one of the sounds I a using. A copy of > the code is posted below. I did some more tests, and apparently in my > previous efforts I somehow was passing an incorrect value into the pre_init > call (which I'm assuming pygame was silently ignoring). So, after fixing > that, the demo and my game run fine. But only on my XP laptop. On the > desktop the demo runs fine, but the game still has the delay... what gives? > Is there something in my windows 7 audio system that could be causing the > delay? Or could it be in my game loop? If that's the case, why would it run > great on my way old laptop and not on the really nice new desktop? > > import pygame, sys > from pygame.constants import * > > pygame.mixer.pre_init(44100,-16,2,1024) > pygame.init() > > BACKGROUND_FILL = (217,204,185) > > display = pygame.display.set_mode((400,400)) > clock = pygame.time.Clock() > > sound_obj = pygame.mixer.Sound('some_sound.wav') > > while True: > clock.tick(30) > for event in pygame.event.get(): > if event.type == QUIT: > pygame.quit() > sys.exit() > > if event.type == MOUSEBUTTONDOWN: > sound_obj.play() > > display.fill(BACKGROUND_FILL) > pygame.display.update() > > > > > -- > View this message in context: > http://pygame-users.25799.n6.nabble.com/Pygame-sound-delay-problem-tp405p407.html > Sent from the pygame-users mailing list archive at Nabble.com. >
