Why does winsound.SND_ASYNC need time to play?

Asked

Viewed 14 times

1

I’m writing a program in python, which at a certain point plays a sound. However, when playing the sound, I would like my program to continue running, so I used winsound.SND_ASYNC. In which my code looked like this:

winsound.PlaySound("Ring01.wav", winsound.SND_ASYNC)

The problem is that the program runs so fast that it ends up not touching the sound, I found it strange, I debug and he played. With that I noticed that this command needs a time to play, until I did some tests putting a Sleep(1) and played for 1 second the sound. But that doesn’t make sense to me, because he should play normal while my show runs, and my show can’t have this delay.

I have tried to use playsound, and this locks the program while playing the sound.

What I can do to make winsound.SND_ASYNC tap quickly before my program finishes?

  • I was able to solve the problem with the code line: winsound.Playsound("Ring01.wav", winsound.SND_ALIAS | winsound.SND_ASYNC)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.