[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Problem copying then playing a wav file
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Problem copying then playing a wav file
- From: Mark Reed <markreed99@xxxxxxxxx>
- Date: Thu, 5 May 2011 07:46:01 +0800
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Wed, 04 May 2011 19:46:07 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=erkyM0MyrU0mYlJ0OegXllrjzcHr6dzktq5vyRahBDU=; b=AWM8j0fi5iqBDo68DNd8Bi/NjKhvQ+Ag7iqAF8zjWqzetx2X7JGldT+DkboxLCd0gG WkvIY1UIvUcxBWmPQ7r0d5w2BV1HIAoKc9WPZf54ZkTSDpa/RW6UgeuG/C8Bzn/B52I1 k61tmKl5sQs8hvw2IcPmnehGz6hE8Gtsyhkpg=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=sGN1rAhv5FtbCaGK9ls0ywhiMWOKSWdaId0q4H4vSOoZdzzFRkBFm4fjQcc2LM/3bk Hm+Ri6aYF8VxZ+f4AjAG7rIhXXTB3bEyRl88BiBInSddW5H7pujUAiK77VHp3MbecJ44 nLv7q7D8eZuQ8k1fyZ8p44+9TtbYPB37NMZQo=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I'm using the pyaudio example to save a wave file called "temp.wav"
http://people.csail.mit.edu/hubert/pyaudio/#docs
The following code correctly plays it:
def Play(self):
if not pygame.mixer.get_init():
pygame.mixer.init()
if os.path.exists("temp.wav"):
self.snd = pygame.mixer.Sound("temp.wav")
self.snd.play()
However when I copy "temp.wav" to a new filename like so:
fd, filename = tempfile.mkstemp(".wav", "myaudio_", dirname)
shutil.copy("temp.wav",filename)
The following code fails to play any wave files I create, I just get a
*pock* then nothing.
self.snd = pygame.mixer.Sound(dirname+filename)
self.channel = self.snd.play()
This is from a wxPython app. If I close the app and reopen it (I save
the list of recorded sound filenames), then the sound file plays
correctly. The sound file exists after the shutil copy is called, and
I can play the file in an external player. Anyone have any ideas why
this would happen?