Re: pygame sound very slow to respond

  • From: "Alex Hall" <mehgcap@xxxxxxxxx>
  • To: <programmingblind@xxxxxxxxxxxxx>
  • Date: Sun, 13 Sep 2009 21:47:07 -0400

No; Windows Mail, Edsharp, a couple Explorer windows... on a dual core with 4gb 
ram? I guess I am just lucky. By any chance, are you running no screen reader, 
or one that is not jaws?


Have a great day,
Alex
New email address: mehgcap@xxxxxxxxx
  ----- Original Message ----- 
  From: BlueScale 
  To: programmingblind@xxxxxxxxxxxxx 
  Sent: Sunday, September 13, 2009 8:51 PM
  Subject: Re: pygame sound very slow to respond


  Hi,
  Very strange, when I run this program the sound happens instantly.  Is there 
a lot of other stuff taking up cpu time too?


       

  On Sun, 2009-09-13 at 19:32 -0400, Alex Hall wrote: 
Hi all,
Below is the code of an example pygame program that plays a sound when a key 
is pressed. However, the sound is slow to happen, a bit less than a second 
from keypress to sound play. A second is a long time to wait in a game... 
Why is it so slow? Is it because the ogg decoding takes a while? No, that 
would only be slow to load, not to play. I don't know, but I can't imagine 
games from this if it takes so long to respond.


Begin Code:
# start playing a sound when a key is pressed
# exit if the letter "q" or the "escape" key is pressed

# import the pygame module
import pygame

# start pygame
pygame.init()

# load a sound file into memory
sound = pygame.mixer.Sound("bird.ogg")

# start the display (required by the event loop)
pygame.display.set_mode((320, 200))

# loop forever (until a break occurs)
while True:
 # wait for an event
 event = pygame.event.wait()
 # if the event is about a keyboard button that have been pressed...
 if event.type == pygame.KEYDOWN:
  # ... then start playing the sound
  sound.play()
  # and if the button is the "q" letter or the "escape" key...
  if event.unicode == "q" or event.key == pygame.K_ESCAPE:
   # ... then exit from the while loop
   break
  # end if
 # end if
# end while


Have a great day,
Alex
New email address: mehgcap@xxxxxxxxx 

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

Other related posts: