tags:

views:

205

answers:

2

I'm trying to make a siren sound in python with beeps, but had no success..

I'm trying something like

winsound.Beep(700,500)
winsound.Beep(710,500)
winsound.Beep(720,500)
...

It's a better way to do it? And play it?

Without external files...

Thx

+1  A: 

I remember using something similar on QBASIC when I was still a kid:

DO
FOR n = -180 TO 180 STEP .1
f = 440 + 50 * SIN(n)
SOUND f, 1
NEXT
LOOP

SOUND f, 1 should be the same thing as winsound.Beep, with pitch and duration. It used to work great but since I took the snippet here I'm not sure I did exactly this way.

It's just to give you the idea..

Jack
+1  A: 
Marcelo Cantos
but then I will be using external files
Shady
No you won't. The second form uses a Python string directly, and the first version of my answer said as much.
Marcelo Cantos
I see, I've got it, thx
Shady
No probs. I've amended the answer to clarify this.
Marcelo Cantos
Put this in your answer - http://www.motobit.com/util/base64-decoder-encoder.asp - it was very helpfull =)
Shady
you can infact embed any file format as a python string, using the base64 encode; and use it your desires.
phoenix24