Skip to content

Commit

Permalink
added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kragen committed Sep 22, 2011
1 parent 293b55d commit d19d38b
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion hello0.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
(xx, 20), # punto de inicio
(randrange(ww), hh - 20), # punto de terminar
10) # ancho de rayo
display.flip()
display.flip() # para mostrar
12 changes: 6 additions & 6 deletions hello1.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@

for xx in range(0, ww, 5):
h, s, v, a = color.hsva
color.hsva = xx * 270 / ww, s, v, a
color.hsva = xx * 270 / ww, s, v, a # cambiar hue

draw.line(pantalla,
draw.line(pantalla, # surface
color,
(xx, 20),
(randrange(ww), hh - 20),
10)
display.flip()
(xx, 20), # punto de inicio
(randrange(ww), hh - 20), # punto de terminar
10) # ancho de rayo
display.flip() # para mostrar
8 changes: 4 additions & 4 deletions sintesis0.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
from Numeric import arange, Int16, sin, pi
tasa = 22050 # de muestreo

mixer.pre_init(tasa, -16, 1)
init()
mixer.pre_init(tasa, -16, 1) # 16bit, un canal
init() # porque sin set_mode

hz, pico, n_muestras = 440, 4096, tasa
theta = arange(n_muestras) * (2*pi * hz / tasa)

sndarray.make_sound((pico * sin(theta)).astype(Int16)
).play(-1, 0, 20)
time.wait(1000)
).play(-1, 0, 20) # 20ms fadein
time.wait(1000) # un segundo
6 changes: 3 additions & 3 deletions sintesis1.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ def sinus(hz, pico, n_muestras):
theta = arange(n_muestras) * (2*pi * hz / tasa)
return (pico * sin(theta)).astype(Int16)

mixer.pre_init(tasa, -16, 1)
mixer.pre_init(tasa, -16, 1) # 16bit, un canal
init()

sndarray.make_sound(sinus(440, 4096, tasa) +
sinus(880, 4096, tasa)
).play(-1, 0, 20)
time.wait(1000)
).play(-1, 0, 20) # 20ms fadein
time.wait(1000) # un segundo

8 changes: 4 additions & 4 deletions sintesis2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def sinus(hz, pico, n_muestras):
theta = arange(n_muestras) * (2*pi * hz / tasa)
return (pico * sin(theta)).astype(Int16)

mixer.pre_init(tasa, -16, 1)
mixer.pre_init(tasa, -16, 1) # 16bit, un canal
init()
reloj, sonido = time.Clock(), None
for ii in range(1, 14):
Expand All @@ -21,7 +21,7 @@ def sinus(hz, pico, n_muestras):

nuevo = sndarray.make_sound(muestras)
if sonido is not None:
reloj.tick(1)
sonido.fadeout(20)
nuevo.play(-1, 2000, 20)
reloj.tick(1) # max 1 fps
sonido.fadeout(20) # 20ms fadeout
nuevo.play(-1, 2000, 20) # 2000ms max
sonido = nuevo

0 comments on commit d19d38b

Please sign in to comment.