def display(audio_ft): if audio_ft[0] == 0: return for i in range(data.shape[1] - 1, 0, -1): data[:, i] = data[:, i - 1] data[:, 0] = array([average(audio_ft[s]) for s in slices]) values = dot(data[:, :len(fg_lpf)], fg_lpf) / dot(data, bg_lpf) clap, count = clapper.get(audio_ft) shift = time.time() / 20. + count / 2. for i, val in enumerate(.4 * values): leds[:, 9-i] = bar(val)[:,None] * color(.3 * i + shift) lights.display(clap + (1 - clap) * leds)
#!/usr/bin/python from numpy import * import lights, colorsys, time coords = linspace(-1.5, 1.5, 10) u, v = meshgrid(coords, coords) def ball(x, y, radius=1): return square(radius) - square(x-u) - square(y-v) def color(hue): return colorsys.hsv_to_rgb(hue, 1, 1) # LCM(c1, c2, c3) is enormous -- pattern never repeats c1 = 1.7000000 c2 = 1.8123456 c3 = .1876543 t = 0 while True: x, y, hue = sin(c1*t), sin(c2*t), square(sin(c3*t)) t = t + .03 pixels = ball(x, y)[..., None] * color(hue) lights.display(pixels) time.sleep(.03)
#!/usr/bin/python import lights, colorsys, time hue = 0 while True: hue = (hue + .004) % 1 color = colorsys.hsv_to_rgb(hue, 1, 1) lights.display(color) time.sleep(.03)
#!/usr/bin/python import lights lights.display(0)