[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] Re: Re: Re: Re: playing sound on Windows
- To: pygame-users@xxxxxxxx
- Subject: [pygame] Re: Re: Re: Re: playing sound on Windows
- From: "sarah" <sarahbmarques@xxxxxxxxx>
- Date: Tue, 02 Jul 2013 15:42:27 -0700 (PDT)
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Tue, 02 Jul 2013 18:42:34 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:message-id:from:to:subject:mime-version:content-type :content-transfer-encoding:x-mime-autoconverted; bh=wfy0z4fIWFS7O6Okf17LIGXG0xL9rC7Yp9509eacqq8=; b=TMwLCBmoGQAx3ZvJFU30QzMnysgrFDOc5XZh2bR+bjDWscXgu9kMeDZV2h1tqVSBfL HGVvrmSKWNcruPkJtI73qZmAMpwt5P+mHWMtBrv+JUw8lY6T5wcXUbRaWqj0KQ9Qhx8p bOdAowqoK4VvcagOpGxGt60V7Ywk1xIF3Or148+HETgl3Cso64FXSaSAeXoDRArjUkx8 QB+y5sWMiEeosJH6brIu5SMokOi9ErrrVmxn90kUSPCeNzaJgzZ70yT0oPNyDXzASRmI hkTrJJS6mmFZjjMC9fGInkbB/EDoXXodH8XahbRkQlD72ZnTOGlKi5gxsmKiMaWjpGgU UA3A==
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
Dear Lenard, I did it. But the "mixer" comands don't also need to be
changed for it to play? Thanks,
Sarah Barreto Marques
Núcleo de Pesquisa em Sistemas de Informação - NSI/IF Fluminense
Napnee - IF Fluminense
www.audiogames.com.br
@sarahbmarques
-----Mensagem original-----
De: Lenard Lindstrom <len-l@xxxxxxxxx>
Para: pygame-users@xxxxxxxx
Data: Sabado, 29 de Junho de 2013 21:16
Assunto: Re: [pygame] Re: Re: playing sound on Windows
Hi Sarah,
There are two audio drivers pygame.mixer can use on Windows. I believe
the default is "waveout". Try setting the SDL_AUDIOMIXER environment
variable to "dsound" to use the directX. This can be done within Python
by adding these two lines to the top of the file:
import os
os.environ['SDL_AUDIODRIVER'] = "dsound"
This will work for Windows, but not Linux. So add add some conditional
code to only set SDL_AUDIODRIVER when the program is running on Windows.
Hope this helps,
Lenard Lindstrom
On 13-06-29 07:34 PM, sarah wrote:
> Hi, reallyvery strange. I did these tests (actually I had already done
> them, when I was programming it to work on Linux, but unfortunately the
> final user of the program this script is part needs it to work on
> windows). I also tested what Christoph suggested, but the result is the
> same. My wav files still play in windows players. the print of
> get_init() showed the same result you've got. So I'm keeping trying
> comand combinations unsuccessfully, for what I still need you guys'
> help.
>
> Sarah
>
> -----Mensagem original-----
> De: James Paige <Bob@xxxxxxxxxxxxxxxxxxx>
> Para: pygame-users@xxxxxxxx
> Data: Quinta, 27 de Junho de 2013 10:48
> Assunto: Re: [pygame] playing sound on Windows
>
> I don't know why this problem is happening, but I can reproduce it.
>
> I tested your script (with my own 0.wav file) and it worked fine on
> Linux, but on Windows 7 (64 bit) with both python 2.6 + pygame 1.9.1 and
> python 2.7 and pygame 1.9.2 there is no sound.
>
> Although this does not solve your problem, I think you should remove the
> pygame.mixer.pre_init() because inside the class but not inside a
> function is definitely the wrong place for it, and even if you move it,
> all it does is change the defaults for pygame.mixer.init() to the same
> values those defaults have already.
>
> You can also add
>
> print pygame.mixer.get_init()
>
> and it will display the settings with which the mixer was initialized,
> or if mixer init failed entirely it will return None.
>
> When I tested, .get_init() returned (22050, -16, 2) indicating that the
> init succeeded with the default settings.
>
> Before I tested your script on my windows box, I tested my 0.wav file in
> audacity and it sounded fine.
>
> After I tested your script, and the sound failed to play, I tried it
> again in audacity, and then it would not play.
>
> Even though I could not get the .wav file to play anymore either in
> python or in audacity, the windows volume mixer test sound still worked
> find.
>
> Very strange.
>
> On Thu, Jun 27, 2013 at 01:04:12PM -0300, sarah marques wrote:
>> Yes, I meant that. Sorry, I translated my code from Portuguese to send
>> it to the list, and this word 'som' slipped.
>>
>> Sarah Barreto Marques
>>
>> 2013/6/27, James Paige <Bob@xxxxxxxxxxxxxxxxxxx>:
>>> On Thu, Jun 27, 2013 at 08:11:39AM -0700, sarah wrote:
>>>> Hi all,
>>>> I've just subscribed to this list hoping someone can hplease elp me with
>>>> the
>>>> following problem: I wrote the class bellow (I also attached it) that
>>>> simply plays a sound
>>>> file when its method play_file() is called. It works on Linux perfectly,
>>>> but
>>>> on Windows, no sound is played and I do need to find the reason of it.
>>>> Configurations are:
>>>> Windows 7 (32 bits), Python 2.6 and Pygame 1.9.1 (win32). Thank very
>>>> much for any help!
>>>> Sarah Barreto Marques
>>>>
>>>> www.audiogames.com.br
>>>> @sarahbmarques
>>>>
>>>>
>>>>
>>>>
>>>> import sys, pygame
>>>> import time
>>>>
>>>> class Sound:
>>>> pygame.mixer.pre_init(frequency=22050, size=-16, channels=2,
>>>> buffer=1024)
>>>>
>>>> def play_file(self, name):
>>>> # pygame.mixer.pre_init(frequency=44100, size=-16, channels=2,
>>>> buffer=1024)
>>>> # pygame.mixer.get_init()
>>>> sound=pygame.mixer.Sound(name)
>>>>
>>>> print 'playing'
>>>> sound.play()
>>>>
>>>> print 'done'
>>>> time.sleep(2)
>>>> return sound
>>>>
>>>> if __name__=='__main__':
>>>> pygame.init()
>>>> sound=Sound()
>>>> som.play_file('0.wav')
>>>
>>> did you mean:
>>>
>>> sound.play_file('0.wav')
>>>
>>> in the last line? som does not seem to be defined anywhere.
>>>
>>> ---
>>> James Paige
>>>