1

I am trying to layer multiple sounds on top of each other with the built-in winsound library. I start my 1st sound with

winsound.PlaySound("test1.wav", winsound.SND_FILENAME | winsound.SND_ASYNC) 

When I try to start my other sound

winsound.PlaySound("test1.wav", winsound.SND_FILENAME | winsound.SND_ASYNC 
            | winsound.SND_NOSTOP)

I get the not-very-descriptive RuntimeError: Can't play sound.
How do I fix that?

ByteHamster
  • 4,884
  • 9
  • 38
  • 53
  • This looks to be based on the Windows PlaySound API function. After googling around a little bit I get the impression that it is not capable of mixing multiple sounds. The is a SND_NOSTOP flag that you could try but I'm not sure your going to get the exact behavior you desire. See this question:http://stackoverflow.com/questions/16073675/playing-mutiple-files-simultaneously-with-the-playsound-api – jaket Nov 08 '15 at 16:53
  • I have the SND_NOSTOP flag, but it's still not working –  Nov 08 '15 at 20:56
  • I think you need another API. – jaket Nov 08 '15 at 23:30
  • Oh well :( . Any suggestions for something that would work? I've seen PyGame suggested, but it seems a little overkill for just playing some background music. –  Nov 09 '15 at 18:22

1 Answers1

1

I was able to play two sounds by using winsound and playsound:

from playsound import playsound
import winsound
#
filename1 = "C:/Users/sound1.wav"
filename2 = "C:/Users/sound2.wav"
soundfile = filename1
winsound.PlaySound(soundfile, winsound.SND_FILENAME|winsound.SND_ASYNC)
playsound(filename2)
R. Wayne
  • 417
  • 1
  • 9
  • 17