-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmimuzo.py
126 lines (91 loc) · 2.88 KB
/
mimuzo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/python
# -*- coding: utf-8 -*-
# import cProfile
import os, sys
import time
import pygame
from pygame.locals import *
import spot
from statfield import StaticField
#from i_sine import Sine
#from i_fm import Fm
#from sonic import Sonic
#from i_synth import Synth
from i_synth_ctl2 import SynthCtl2
from transmit import Transmitter
from movado_yuv import CamMoves
if not pygame.font: print('Averto, tiparoj neaktivaj')
if not pygame.mixer: print('Averto: sono malŝaltita')
cols=4
rows=3
# screen size
height = 600
width = 800
# cam size
#cam_size = (640,480) # necesas uzi tion por YUV (?)
#cam_size = (320,240)
cam_size = (160,120)
frequence = 10 # kiom ofte en sekundo trakuri la tuton
def main():
"""ĉefa funkcio, kiu rulas ĉion"""
# preparu ekranon
pygame.init()
screen = pygame.display.set_mode((width,height))
pygame.display.set_caption('Mimuzo')
bg = pygame.Surface(screen.get_size())
bg = bg.convert()
bg.fill((230,250,160))
screen.blit(bg,(0,0))
# pygame.display.flip()
####
# preparu objektojn
clock = pygame.time.Clock()
fld = StaticField(screen,rows,cols,width,height,(200,60,90))
#instr = SynthCtl("pnoise",rows,cols)
#fld.charge_factor = 0.1
#instr = SynthCtl("sine",rows,cols)
# instr = SynthCtl2("fm","pretty_bell",rows,cols)
instr = SynthCtl2("bnoise","pretty_bell",rows,cols)
fld.charge_factor = 0.4
# spot.threshold_discharge = 99 # ne sencharghighu en tiu konstelacio
spot.threshold_discharge = 0.2
#### spot.threshold_update = 9999 # evitu shanghon de lauteco provizore
# FIXME ne funkcias tiel, momente mem lanchu jackd kaj sonic-pi mane...
#instr.jack_in()
tr = Transmitter(fld,instr)
pygame.display.flip()
moves = CamMoves((width,height),cam_size)
clock.tick(frequence)
diff = moves.get_diff() # unuan diferencbildon ignoru char chio aperas nove
values = moves.get_values(rows,cols)
# fld.setValue(1,2,1.2)
while 1:
clock.tick(frequence)
diff = moves.get_diff()
values = moves.get_values(rows,cols)
#print values
fld.charge_all(values)
fld.propagate_all()
#fld.dump()
for event in pygame.event.get():
if event.type ==QUIT:
return
elif event.type == KEYDOWN and event.key == K_ESCAPE:
return
elif event.type == MOUSEBUTTONDOWN:
# pentru...
(x,y) = pygame.mouse.get_pos()
c = cols * x / width
r = rows * y / height
fld.charge(r,c,1.0)
# allsprites.update()
# fld.propagate_all()
# fld.dump()
# repentru
screen.blit(bg,(0,0))
# allsprites.draw(screen)
moves.blit(screen)
fld.blit(screen)
pygame.display.flip()
# voku 'main'
if __name__ == '__main__': main()