def main(): global filename, ctx, notes, ledgers, columns, player if len(sys.argv) < 2: print("[IMAGE FILENAME]") exit() filename = sys.argv[1] if len(sys.argv) > 2: notes, ledgers, columns = util.load("scores/%s" % sys.argv[2]) print(len(notes)) from play import Player player = Player() image = Image.open(filename) aspect = image.size[1] / image.size[0] width = int(HEIGHT / aspect) ctx = animation.Context(width, HEIGHT, background=(1., 1., 1., 1.), fullscreen=False, title="score") ctx.add_callback("key_press", on_key_press) ctx.add_callback("mouse_press", on_mouse_press) ctx.add_callback("mouse_drag", on_mouse_drag) ctx.load_image(filename, 0, 0, ctx.width, ctx.height) ctx.start(draw)
# ys = list(sp.remove_shots(ys)) # zs = list(sp.remove_shots(zs)) ys = (np.array(ys) * 2.0) - 0.5 zs = (np.array(zs) * 2.0) - 0.5 ys = sp.smooth(ys, 20) zs = sp.smooth(zs, 20) # combo_yz = [((t_now - sample[0]) / 10.0, (sample[1][2] - RANGE[0]) / (RANGE[1] - RANGE[0]), ((sample[1][1] - RANGE[0]) / (RANGE[1] - RANGE[0])) - 0.5) for sample in list(samples)] combo_yz = [(ts[i], ys[i], zs[i]) for i in range(0, len(ys))] ctx.lines3D(combo_yz, color=colors[s], thickness=2.0) def on_mouse_press(data): x, y, button, modifers = data print(modifiers) stop_session() if current_session is not None else start_session() def on_mouse_drag(data): x, y, dx, dy, button, modifers = data global rotation_x, rotation_y SCALE = -0.5 rotation_x = (dx * SCALE) + rotation_x[0], 0, 1, 0 rotation_y = (dy * SCALE) + rotation_y[0], 1, 0, 0 print(rotation_x, rotation_y) fl = FeatherListener(message_handler=on_message) ctx = animation.Context(1000, 700, background=(0., 0., 0., 1.), fullscreen=False, title="TREE", smooth=True, _3d=True, screen=0) # ctx.add_callback("mouse_press", on_mouse_press) ctx.add_callback("mouse_drag", on_mouse_drag) ctx.start(draw)
first_time = True waiting = True transmitting = False label = None incoming_message = [] coords = [] sender = link.Sender(23232) receiver = link.Receiver(23234) animation.show_fps = False ctx = animation.Context(859, 556, title="OH DEAR ME", background=(1., 1., 1., 1.), screen=1, fullscreen=config['fullscreen'], chrome=not config['fullscreen']) def on_mouse_press(data): global waiting, transmitting, current_string, incoming_message # waiting mode, nothing happens if waiting: log.debug("MODE: waiting") return # transmitting mode, we've clicked, so go into receiving mode if transmitting:
spectrum_sum = spectrum else: sum_multiplier = (num_spectrums - 1) / num_spectrums spectrum_sum *= sum_multiplier add_multiplier = 1 / num_spectrums spectrum *= add_multiplier spectrum_sum += spectrum ds = np.copy(spectrum_sum).astype(np.uint32) # convert to uint32 ds = ((ds & 0xFF) <<8) + ((ds & 0xFF) <<16) + ((ds & 0xFF)) # make white # print(ds[80]) display_spectrums.put(ds) SoundPull() ctx = animation.Context(427, 257, background=(0, 0, 0, 1), fullscreen=False, smooth=False, screen=0) display_spectrum = None def draw(): global display_spectrum try: display_spectrum = display_spectrums.get_nowait() log.info("New spectrum: %sx%s" % (display_spectrum.shape[1], display_spectrum.shape[0])) except queue.Empty: pass if display_spectrum is None: return ctx.pixels(display_spectrum) ctx.start(draw)
bar = 0.01 else: bar = 1.0 - (max(abs(rssi) - 25, 0) / 100) x = (20 + (s * 20)) / ctx.width ctx.line(x, .1, x, (bar * 0.9) + .1, color=COLORS[esp_id % len(COLORS)], thickness=10) if esp_id not in labels: print("Adding label for esp_id %s" % esp_id) labels.append(esp_id) ctx.label(x, .05, str(esp_id), font="Monaco", size=10, width=10, center=True) # data for s, esp_id in enumerate(list(sensor_data)): samples = sensor_data[esp_id] if len(samples): ctx.lines([ ((t_now - sample[0]) / 10.0, (sample[1] - RANGE[0] - 9.8) / (RANGE[1] - RANGE[0]) ) for sample in list(samples)], color=COLORS[esp_id % len(COLORS)]) # subtract 9.8 to center it if __name__ == "__main__": def message_handler(response): # db.branches.insert(data) if response['id'] not in sensor_data: sensor_data[response['id']] = deque() sensor_rssi[response['id']] = None sensor_data[response['id']].appendleft((response['t_utc'], response['mag'])) sensor_rssi[response['id']] = response['t_utc'], response['rssi'] if len(sensor_data[response['id']]) == 1000: sensor_data[response['id']].pop() ESPListener(message_handler=message_handler) ctx = animation.Context(1000, 300, background=(1., 1., 1., 1.), fullscreen=False, title="RAT", smooth=True) ctx.start(draw)
from housepy import config, log, util, osc, crashdb, animation import numpy as np CHANNEL = None if len(sys.argv) > 1: CHANNEL = int(sys.argv[1]) # 1=bass, 2=cello, 3=viola db = crashdb.load("notes.json") notes = db['notes'] nts = [note[0] for note in notes] db.close() ctx = animation.Context(1200, 600, background=(0.9, 0.9, 0.9, 1.), fullscreen=False, title="The Patient Conflict", smooth=False) page_duration = 5.0 margin = 1.0 hitpoint = margin / (page_duration - margin) note_index = 0 start_t = 0 t = 0 last_t = 0 started = False names = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'] treble_ledgers = {