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

Re: [pygame] play sound delay



hi,Jason

thanks for reminding, so kind ~

That time I didn't know why the delay happened, so I remove all the
code that seems had the probability  ...

I use the "pygame.time.Clock.tick(40)"  ...  maybe they  cause the
same  result (processor usage decrease)?

Yu


2010/3/25 Jason M. Marshall <jmm0@xxxxxxxxx>:
> Yu,
> Also, it's a good idea to design the main loop to share time with other
> processes. I recommend that you put pygame.time.wait(5) in the loop. You
> won't be able to notice the delay, but your processor usage will decrease.
> Jason
> ________________________________
> From: yu <kkndyu@xxxxxxxxx>
> To: pygame-users@xxxxxxxx
> Sent: Thu, March 25, 2010 3:20:01 AM
> Subject: Re: [pygame] play sound delay
>
> thanks, Ian
>
> now I know the key is the size of buffer, The smaller, the less
> latency it will ...
>
> I'm new to  the coding of sound ... :(
>
> 2010/3/25 Ian Mallett <geometrian@xxxxxxxxx>:
>> Hi,
>>
>> Add the following line:
>> pygame.mixer.pre_init(frequency=22050, size=-16, channels=8, buffer=256)
>>
>> Immediately after these lines at the beginning of your file:
>> import pygame
>> from pygame.locals import *
>>
>> And before:
>> pygame.init()
>>
>> So:
>> import pygame
>> from pygame.locals import *
>> pygame.mixer.pre_init(frequency=22050, size=-16, channels=8, buffer=256)
>> pygame.init()
>> #Rest of your code
>>
>> Ian
>>
>
>