[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] play sound delay
- To: pygame-users@xxxxxxxx
- Subject: [pygame] play sound delay
- From: yu <kkndyu@xxxxxxxxx>
- Date: Thu, 25 Mar 2010 11:15:06 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 24 Mar 2010 23:15:20 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=JPQjgZYpRTbGP9du9cvEFaUow3yrTxpOPoBLLobUF/I=; b=aQdl1Ewn7xYJInzn1RDr2iPTbQcSuIhZmYb8Ch29kDqr5ztxluNK1LkPHFYbgXz074 VajRuEfQ/4bixJUYT1c6WDQoARO7nVvYFy0SweOosg61hwS5qq82PzSnXBk9LpBVYttc +VwpGsv/1BTj4ripxSV/v8ZhIJQzdX1K7ZKx4=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=MbW5OHWvdFdFcX8laFaThy/YFHQjS2vBzcsvPOgxUAcvrq6BheqLIu2+NnKSAuAAM7 fiCGsPSqw2hE4FCqke0YIqDs0Lp97bY/v3jvOm4QKyysowwTysEMrbZgbE3EaFUet6hS g4h6gu2EPnu/mg3etagarA5Js3qwz9ob6RsNI=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
hi,all
My function is
press keyboard then in the event "KEYDOWN" play the sound (*.midi *.wav ...)
I need the sound play immediately but it seems always has about 1 second delay
how to solve these?
my code like these:
pickUpSound = pygame.mixer.Sound('/home/yu/work/symphony/pickup.wav')
#pygame.mixer.music.load('/home/yu/work/symphony/background.mid')
#pygame.mixer.music.play(-1, 0.0)
# run the game loop
while True:
# check for the QUIT event
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == KEYDOWN:
# change the keyboard variables
if event.key == K_LEFT or event.key == ord('a'):
pickUpSound.play()
regards
yu